summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-06-13 16:59:47 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-06-16 17:06:54 -0400
commit4f149c7887bbd8eee17ec5603278e2f78d5c1042 (patch)
treea574138659cf077710fa52d230fd10a78daf0fc3
parentd3be47c483b9e8a5b773b48d18c99b4256b17c70 (diff)
nspawn: if !cg_ns_supported() then force arg_use_cgns = false
It's silly that every time we check arg_use_cgns we also have to check cg_ns_supported(). So, simplify these checks and force arg_use_cgns = false if the kernel doesn't support cg_ns_supported.
-rw-r--r--src/nspawn/nspawn.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index be0dc5e86b..51078feccd 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1157,7 +1157,7 @@ static int parse_argv(int argc, char *argv[]) {
if (r < 0)
arg_use_cgns = cg_ns_supported();
else
- arg_use_cgns = r;
+ arg_use_cgns = r && cg_ns_supported();
return 1;
}
@@ -2706,7 +2706,7 @@ static int inner_child(
return -ESRCH;
}
- if (arg_use_cgns && cg_ns_supported()) {
+ if (arg_use_cgns) {
r = unshare(CLONE_NEWCGROUP);
if (r < 0)
return log_error_errno(errno, "Failed to unshare cgroup namespace");
@@ -3114,7 +3114,7 @@ static int outer_child(
if (r < 0)
return r;
- if (!arg_use_cgns || !cg_ns_supported()) {
+ if (!arg_use_cgns) {
r = mount_cgroups(
directory,
arg_unified_cgroup_hierarchy,