nspawn: reject existing cgroupfs mount if cgns is enabled

This commit is contained in:
Mike Yuan
2025-04-04 14:36:14 +02:00
parent 02c4d27b17
commit b26a994fb8
3 changed files with 7 additions and 4 deletions
+2 -2
View File
@@ -3342,7 +3342,7 @@ static int inner_child(
if (r < 0)
return log_error_errno(errno, "Failed to unshare cgroup namespace: %m");
r = mount_cgroups(/* dest = */ NULL);
r = mount_cgroups(/* dest = */ NULL, /* accept_existing = */ false);
} else
r = bind_mount_cgroup_hierarchy();
if (r < 0)
@@ -4217,7 +4217,7 @@ static int outer_child(
(void) write_string_filef(p, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_MODE_0444, SD_ID128_UUID_FORMAT_STR, SD_ID128_FORMAT_VAL(arg_uuid));
if (!arg_use_cgns) {
r = mount_cgroups(directory);
r = mount_cgroups(directory, /* accept_existing = */ true);
if (r < 0)
return r;
}