]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
Set process ID in system identity
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 24 Jun 2013 13:47:31 +0000 (14:47 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 24 Jun 2013 14:39:56 +0000 (15:39 +0100)
When creating a virIdentityPtr for the system identity, include
the current process ID as an attribute.

src/util/viridentity.c

index 034a12a612d165e23bd4022448a81f0f2760620a..6d93d0f92633dccceeaf3bbd5a319c79378cef2e 100644 (file)
@@ -139,6 +139,13 @@ virIdentityPtr virIdentityGetSystem(void)
 #if WITH_SELINUX
     security_context_t con;
 #endif
+    char *processid = NULL;
+
+    if (virAsprintf(&processid, "%llu",
+                    (unsigned long long)getpid()) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
 
     if (!(username = virGetUserName(getuid())))
         goto cleanup;
@@ -176,11 +183,16 @@ virIdentityPtr virIdentityGetSystem(void)
                            VIR_IDENTITY_ATTR_SELINUX_CONTEXT,
                            seccontext) < 0)
         goto error;
+    if (virIdentitySetAttr(ret,
+                           VIR_IDENTITY_ATTR_UNIX_PROCESS_ID,
+                           processid) < 0)
+        goto error;
 
 cleanup:
     VIR_FREE(username);
     VIR_FREE(groupname);
     VIR_FREE(seccontext);
+    VIR_FREE(processid);
     return ret;
 
 error: