diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-03-14 23:13:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-03-14 23:13:57 +0100 |
commit | 1f73f0f163eeb8a889e3799c0c63bcb437e531ac (patch) | |
tree | 911be730b1044f450394285b6a726db9c16f2aa6 /src/cgroup-util.c | |
parent | 04d391dabcd860e2d0542ece1d1c7e0a9d9cd0ac (diff) |
pam: determine user cgroup tree from cgroup of PID 1
Diffstat (limited to 'src/cgroup-util.c')
-rw-r--r-- | src/cgroup-util.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/cgroup-util.c b/src/cgroup-util.c index 055c906106..bbadc789a1 100644 --- a/src/cgroup-util.c +++ b/src/cgroup-util.c @@ -967,3 +967,31 @@ int cg_fix_path(const char *path, char **result) { return r; } + +int cg_get_user_path(char **path) { + char *root, *p; + + assert(path); + + /* Figure out the place to put user cgroups below. We use the + * same as PID 1 has but with the "/system" suffix replaced by + * "/user" */ + + if (cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &root) < 0) + p = strdup("/user"); + else { + if (endswith(root, "/system")) + root[strlen(root) - 7] = 0; + else if (streq(root, "/")) + root[0] = 0; + + p = strappend(root, "/user"); + free(root); + } + + if (!p) + return -ENOMEM; + + *path = p; + return 0; +} |