diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-22 23:10:13 -0300 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-22 23:14:12 -0300 |
commit | ae018d9bc900d6355dea4af05119b49c67945184 (patch) | |
tree | 07a311ae16ac331f1044503bbb01a4e111331fb2 /src/login/logind-session.c | |
parent | cd8f53ab1601513cc3407447bfe3359ee7139676 (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/logind-session.c')
-rw-r--r-- | src/login/logind-session.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 2f7ab3451f..662273b07f 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -465,7 +465,18 @@ static int session_create_cgroup(Session *s) { assert(s->user->cgroup_path); if (!s->cgroup_path) { - if (asprintf(&p, "%s/%s", s->user->cgroup_path, s->id) < 0) + _cleanup_free_ char *name = NULL, *escaped = NULL; + + name = strappend(s->id, ".session"); + if (!name) + return log_oom(); + + escaped = cg_escape(name); + if (!escaped) + return log_oom(); + + p = strjoin(s->user->cgroup_path, "/", escaped, NULL); + if (!p) return log_oom(); } else p = s->cgroup_path; |