summaryrefslogtreecommitdiff
path: root/src/login/logind-user.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login/logind-user.c')
-rw-r--r--src/login/logind-user.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index b692b533e2..9e2cbf646b 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -29,6 +29,7 @@
#include "cgroup-util.h"
#include "hashmap.h"
#include "strv.h"
+#include "fileio.h"
User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name) {
User *u;
@@ -314,12 +315,22 @@ 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;
- r = cg_create(SYSTEMD_CGROUP_CONTROLLER, p);
+ r = cg_create(SYSTEMD_CGROUP_CONTROLLER, p, NULL);
if (r < 0) {
log_error("Failed to create cgroup "SYSTEMD_CGROUP_CONTROLLER":%s: %s", p, strerror(-r));
free(p);
@@ -334,7 +345,7 @@ static int user_create_cgroup(User *u) {
if (strv_contains(u->manager->reset_controllers, *k))
continue;
- r = cg_create(*k, p);
+ r = cg_create(*k, p, NULL);
if (r < 0)
log_warning("Failed to create cgroup %s:%s: %s", *k, p, strerror(-r));
}