summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-01-15 03:00:43 +0100
committerLennart Poettering <lennart@poettering.net>2013-01-15 03:04:41 +0100
commit59164be40e6b520315d87e1ef16a3be65c854224 (patch)
tree381c9d105aeed7e12ae87c74c530467dd8d3f577 /src/shared/util.c
parentc84f5e4a825f17163ead0f60308d548b415334a5 (diff)
systemctl: when inhibiting shutdown/suspend also check for other login sessions
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 49b58444c7..a87828d451 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4444,6 +4444,23 @@ int get_user_creds(
return 0;
}
+char* uid_to_name(uid_t uid) {
+ struct passwd *p;
+ char *r;
+
+ if (uid == 0)
+ return strdup("root");
+
+ p = getpwuid(uid);
+ if (p)
+ return strdup(p->pw_name);
+
+ if (asprintf(&r, "%lu", (unsigned long) uid) < 0)
+ return NULL;
+
+ return r;
+}
+
int get_group_creds(const char **groupname, gid_t *gid) {
struct group *g;
gid_t id;