diff options
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r-- | src/nspawn/nspawn.c | 16 |
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 |