[libvirt] [PATCH] Set process ID in system identity
Michal Privoznik
mprivozn at redhat.com
Mon Jun 24 14:35:33 UTC 2013
On 24.06.2013 15:50, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> When creating a virIdentityPtr for the system identity, include
> the current process ID as an attribute.
> ---
> src/util/viridentity.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/src/util/viridentity.c b/src/util/viridentity.c
> index 034a12a..6d93d0f 100644
> --- a/src/util/viridentity.c
> +++ b/src/util/viridentity.c
> @@ -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:
>
ACK
Michal
More information about the libvir-list
mailing list