summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-22 17:11:05 -0300
committerLennart Poettering <lennart@poettering.net>2013-04-22 23:14:12 -0300
commitdc2c75602dc9f2529e6ba6db02fa53d057ce0f8c (patch)
treed8b4c3ab136645179738a70051411cfba8d50fc0 /src
parent8fc66914c068e6fa0e1c610b9cdbef429e469a88 (diff)
nspawn: always use cg_get_path() to determine fs path for a cgroup
Diffstat (limited to 'src')
-rw-r--r--src/nspawn/nspawn.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index b59b2673cd..0a5a151202 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -923,7 +923,8 @@ static int setup_cgroup(const char *path) {
}
static int save_attributes(const char *cgroup, pid_t pid, const char *uuid, const char *directory) {
- char buf[DECIMAL_STR_MAX(pid_t)], path[PATH_MAX];
+ _cleanup_free_ char *path = NULL;
+ char buf[DECIMAL_STR_MAX(pid_t)];
int r = 0, k;
assert(cgroup);
@@ -933,10 +934,10 @@ static int save_attributes(const char *cgroup, pid_t pid, const char *uuid, cons
#ifdef HAVE_XATTR
assert_se(snprintf(buf, sizeof(buf), "%lu", (unsigned long) pid) < (int) sizeof(buf));
- r = snprintf(path, sizeof(path), "/sys/fs/cgroup/systemd/%s", cgroup);
- if (r >= (int) sizeof(path)) {
- log_error("cgroup name too long");
- return -EINVAL;
+ r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, cgroup, NULL, &path);
+ if (r < 0) {
+ log_error("Failed to get path: %s", strerror(-r));
+ return r;
}
r = setxattr(path, "trusted.init_pid", buf, strlen(buf), XATTR_CREATE);
@@ -954,7 +955,7 @@ static int save_attributes(const char *cgroup, pid_t pid, const char *uuid, cons
k = setxattr(path, "trusted.root_directory", directory, strlen(directory), XATTR_CREATE);
if (k < 0) {
- log_warning("Failed to set %s attribute on %s: %m", "trusted.machine_id", path);
+ log_warning("Failed to set %s attribute on %s: %m", "trusted.root_directory", path);
if (r == 0)
r = k;
}
@@ -1457,8 +1458,7 @@ int main(int argc, char *argv[]) {
if (setup_cgroup(newcg) < 0)
goto child_fail;
- close_nointr_nofail(pipefd2[1]);
- close_nointr_nofail(pipefd2[0]);
+ close_pipe(pipefd2);
/* Mark everything as slave, so that we still
* receive mounts from the real root, but don't