summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-03 01:13:03 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-03 01:13:48 +0100
commit674eb68520107d771e3458287025a73387f938c4 (patch)
treeba06e158593b6d4933a9b5d61e4ea9ec68acd8d7 /src/shared
parente821075a23fdfa3ca7738fc30bb2d4c430fe10c0 (diff)
bus: add generator that turns old dbus1 activation files into .busname + .service units
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/cgroup-util.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index 4e0211a7a0..88bc33e3d5 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -1337,36 +1337,41 @@ int cg_pid_get_session(pid_t pid, char **session) {
int cg_path_get_owner_uid(const char *path, uid_t *uid) {
_cleanup_free_ char *slice = NULL;
- const char *e;
+ const char *start, *end;
char *s;
+ uid_t u;
int r;
assert(path);
- assert(uid);
r = cg_path_get_slice(path, &slice);
if (r < 0)
return r;
- e = startswith(slice, "user-");
- if (!e)
+ start = startswith(slice, "user-");
+ if (!start)
return -ENOENT;
- if (!endswith(slice, ".slice"))
+ end = endswith(slice, ".slice");
+ if (!end)
return -ENOENT;
- s = strndupa(e, strlen(e) - 6);
+ s = strndupa(start, end - start);
if (!s)
- return -ENOMEM;
+ return -ENOENT;
- return parse_uid(s, uid);
+ if (parse_uid(s, &u) < 0)
+ return -EIO;
+
+ if (uid)
+ *uid = u;
+
+ return 0;
}
int cg_pid_get_owner_uid(pid_t pid, uid_t *uid) {
_cleanup_free_ char *cgroup = NULL;
int r;
- assert(uid);
-
r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
if (r < 0)
return r;