summaryrefslogtreecommitdiff
path: root/src/login/sd-login.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-22 23:10:13 -0300
committerLennart Poettering <lennart@poettering.net>2013-04-22 23:14:12 -0300
commitae018d9bc900d6355dea4af05119b49c67945184 (patch)
tree07a311ae16ac331f1044503bbb01a4e111331fb2 /src/login/sd-login.c
parentcd8f53ab1601513cc3407447bfe3359ee7139676 (diff)
cgroup: make sure all our cgroup objects have a suffix and are properly escaped
Session objects will now get the .session suffix, user objects the .user suffix, nspawn containers the .nspawn suffix. This also changes the user cgroups to be named after the numeric UID rather than the username, since this allows us the parse these paths standalone without requiring access to the cgroup file system. This also changes the mapping of instanced units to cgroups. Instead of mapping foo@bar.service to the cgroup path /user/foo@.service/bar we will now map it to /user/foo@.service/foo@bar.service, in order to ensure that all our objects are properly suffixed in the tree.
Diffstat (limited to 'src/login/sd-login.c')
-rw-r--r--src/login/sd-login.c35
1 files changed, 1 insertions, 34 deletions
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index 30e07a9322..157b7e0fb4 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -73,10 +73,6 @@ _public_ int sd_pid_get_machine_name(pid_t pid, char **name) {
}
_public_ int sd_pid_get_owner_uid(pid_t pid, uid_t *uid) {
- int r;
- _cleanup_free_ char *root = NULL, *cgroup = NULL, *cc = NULL;
- char *p;
- struct stat st;
if (pid < 0)
return -EINVAL;
@@ -84,36 +80,7 @@ _public_ int sd_pid_get_owner_uid(pid_t pid, uid_t *uid) {
if (!uid)
return -EINVAL;
- r = cg_pid_get_path_shifted(pid, &root, &cgroup);
- if (r < 0)
- return r;
-
- if (!startswith(cgroup, "/user/"))
- return -ENOENT;
-
- p = strchr(cgroup + 6, '/');
- if (!p)
- return -ENOENT;
-
- p++;
- p += strcspn(p, "/");
- *p = 0;
-
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, root, cgroup, &cc);
-
- if (r < 0)
- return -ENOMEM;
-
- r = lstat(cc, &st);
-
- if (r < 0)
- return -errno;
-
- if (!S_ISDIR(st.st_mode))
- return -ENOTDIR;
-
- *uid = st.st_uid;
- return 0;
+ return cg_pid_get_owner_uid(pid, uid);
}
_public_ int sd_uid_get_state(uid_t uid, char**state) {