]> xenbits.xensource.com Git - libvirt.git/commitdiff
rpc: do not fail if the pid of the connecting process is not set
authorGiuseppe Scrivano <gscrivan@redhat.com>
Wed, 19 Nov 2014 14:54:14 +0000 (15:54 +0100)
committerGiuseppe Scrivano <gscrivan@redhat.com>
Thu, 20 Nov 2014 13:22:50 +0000 (14:22 +0100)
getsockopt(sock->fd, SOL_SOCKET, SO_PEERCRED, ...) sets the pid to 0
when the process that opens the connection is in another container.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
src/rpc/virnetsocket.c

index 882fbec15b3805a88acd0673cb1b8f257ab1cab2..6b019cc6160a6d9a3cdc72315b0029b365dbfff5 100644 (file)
@@ -1251,10 +1251,14 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
         goto cleanup;
     }
 
-    if (virProcessGetStartTime(cr.pid, timestamp) < 0)
+    *timestamp = -1;
+    if (cr.pid && virProcessGetStartTime(cr.pid, timestamp) < 0)
         goto cleanup;
 
-    *pid = cr.pid;
+    if (cr.pid)
+        *pid = cr.pid;
+    else
+        *pid = -1;
     *uid = cr.uid;
     *gid = cr.gid;