summaryrefslogtreecommitdiff
path: root/src/cgroup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-18 20:15:34 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-18 20:15:34 +0200
commit33be102a214e7010949496549f4c737b0f8269a3 (patch)
treeb44c8395dbcb7737e275de0500e17481b4baf0ee /src/cgroup.c
parent2cb1a60d14f869023652482a380ca7b659dcf78f (diff)
cgroup: make sure the user cannot accidentaly unmount our cgroup filesystem
Diffstat (limited to 'src/cgroup.c')
-rw-r--r--src/cgroup.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/cgroup.c b/src/cgroup.c
index 108c4fcf5e..291db4e6c9 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -407,7 +407,7 @@ finish:
}
int manager_setup_cgroup(Manager *m) {
- char *mp, *cp;
+ char *cp;
int r;
pid_t pid;
char suffix[32];
@@ -423,15 +423,15 @@ int manager_setup_cgroup(Manager *m) {
if (!(m->cgroup_controller = strdup("name=systemd")))
return -ENOMEM;
- if ((r = cgroup_get_subsys_mount_point(m->cgroup_controller, &mp)))
+ free(m->cgroup_mount_point);
+ m->cgroup_mount_point = NULL;
+ if ((r = cgroup_get_subsys_mount_point(m->cgroup_controller, &m->cgroup_mount_point)))
return translate_error(r, errno);
pid = getpid();
- if ((r = cgroup_get_current_controller_path(pid, m->cgroup_controller, &cp))) {
- free(mp);
+ if ((r = cgroup_get_current_controller_path(pid, m->cgroup_controller, &cp)))
return translate_error(r, errno);
- }
snprintf(suffix, sizeof(suffix), "/systemd-%u", (unsigned) pid);
char_array_0(suffix);
@@ -448,24 +448,20 @@ int manager_setup_cgroup(Manager *m) {
r = asprintf(&m->cgroup_hierarchy, "%s%s", streq(cp, "/") ? "" : cp, suffix);
free(cp);
- if (r < 0) {
- free(mp);
+ if (r < 0)
return -ENOMEM;
- }
}
log_debug("Using cgroup controller <%s>, hierarchy mounted at <%s>, using root group <%s>.",
m->cgroup_controller,
- mp,
+ m->cgroup_mount_point,
m->cgroup_hierarchy);
- if ((r = install_release_agent(m, mp)) < 0)
+ if ((r = install_release_agent(m, m->cgroup_mount_point)) < 0)
log_warning("Failed to install release agent, ignoring: %s", strerror(-r));
else
log_debug("Installed release agent, or already installed.");
- free(mp);
-
if ((r = create_hierarchy_cgroup(m)) < 0)
log_error("Failed to create root cgroup hierarchy: %s", strerror(-r));
else