From ae018d9bc900d6355dea4af05119b49c67945184 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 22 Apr 2013 23:10:13 -0300 Subject: 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. --- src/login/logind-user.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/login/logind-user.c') diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 4b0ac5e737..9e2cbf646b 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -315,7 +315,17 @@ static int user_create_cgroup(User *u) { assert(u); if (!u->cgroup_path) { - if (asprintf(&p, "%s/%s", u->manager->cgroup_path, u->name) < 0) + _cleanup_free_ char *name = NULL, *escaped = NULL; + + if (asprintf(&name, "%lu.user", (unsigned long) u->uid) < 0) + return log_oom(); + + escaped = cg_escape(name); + if (!escaped) + return log_oom(); + + p = strjoin(u->manager->cgroup_path, "/", escaped, NULL); + if (!p) return log_oom(); } else p = u->cgroup_path; -- cgit v1.2.3-54-g00ecf