mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Set process ID in system identity
When creating a virIdentityPtr for the system identity, include the current process ID as an attribute.
This commit is contained in:
parent
15af5e5f70
commit
5de708c1b9
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user