|
|
43fe83 |
From 8e0ffba00072a27a03ce78e9623a826f8e79dca2 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <8e0ffba00072a27a03ce78e9623a826f8e79dca2.1379597659.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Wed, 28 Aug 2013 15:22:05 +0100
|
|
|
43fe83 |
Subject: [PATCH] Ensure system identity includes process start time
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1006272
|
|
|
43fe83 |
|
|
|
43fe83 |
The polkit access driver will want to use the process start
|
|
|
43fe83 |
time field. This was already set for network identities, but
|
|
|
43fe83 |
not for the system identity.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit e65667c0c6e016d42abea077e31628ae43f57b74)
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/util/viridentity.c | 16 ++++++++++++++++
|
|
|
43fe83 |
1 file changed, 16 insertions(+)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
|
|
|
43fe83 |
index 03c375b..f681f85 100644
|
|
|
43fe83 |
--- a/src/util/viridentity.c
|
|
|
43fe83 |
+++ b/src/util/viridentity.c
|
|
|
43fe83 |
@@ -35,6 +35,7 @@
|
|
|
43fe83 |
#include "virthread.h"
|
|
|
43fe83 |
#include "virutil.h"
|
|
|
43fe83 |
#include "virstring.h"
|
|
|
43fe83 |
+#include "virprocess.h"
|
|
|
43fe83 |
|
|
|
43fe83 |
#define VIR_FROM_THIS VIR_FROM_IDENTITY
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -142,11 +143,20 @@ virIdentityPtr virIdentityGetSystem(void)
|
|
|
43fe83 |
security_context_t con;
|
|
|
43fe83 |
#endif
|
|
|
43fe83 |
char *processid = NULL;
|
|
|
43fe83 |
+ unsigned long long timestamp;
|
|
|
43fe83 |
+ char *processtime = NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (virAsprintf(&processid, "%llu",
|
|
|
43fe83 |
(unsigned long long)getpid()) < 0)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
|
|
|
43fe83 |
+ if (virProcessGetStartTime(getpid(), ×tamp) < 0)
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ if (timestamp != 0 &&
|
|
|
43fe83 |
+ virAsprintf(&processtime, "%llu", timestamp) < 0)
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
if (!(username = virGetUserName(getuid())))
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
if (virAsprintf(&userid, "%d", (int)getuid()) < 0)
|
|
|
43fe83 |
@@ -198,6 +208,11 @@ virIdentityPtr virIdentityGetSystem(void)
|
|
|
43fe83 |
VIR_IDENTITY_ATTR_UNIX_PROCESS_ID,
|
|
|
43fe83 |
processid) < 0)
|
|
|
43fe83 |
goto error;
|
|
|
43fe83 |
+ if (processtime &&
|
|
|
43fe83 |
+ virIdentitySetAttr(ret,
|
|
|
43fe83 |
+ VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME,
|
|
|
43fe83 |
+ processtime) < 0)
|
|
|
43fe83 |
+ goto error;
|
|
|
43fe83 |
|
|
|
43fe83 |
cleanup:
|
|
|
43fe83 |
VIR_FREE(username);
|
|
|
43fe83 |
@@ -206,6 +221,7 @@ cleanup:
|
|
|
43fe83 |
VIR_FREE(groupid);
|
|
|
43fe83 |
VIR_FREE(seccontext);
|
|
|
43fe83 |
VIR_FREE(processid);
|
|
|
43fe83 |
+ VIR_FREE(processtime);
|
|
|
43fe83 |
return ret;
|
|
|
43fe83 |
|
|
|
43fe83 |
error:
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|