summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn.c
diff options
context:
space:
mode:
authorDjalal Harouni <djalal@endocode.com>2015-06-16 17:30:45 +0100
committerDjalal Harouni <djalal@endocode.com>2015-06-16 17:30:45 +0100
commitb774fb7f002c9877391e8d4fe8e6b6d0ea8647da (patch)
tree96b273cb32a60b9028144928a0b6ecfe0e9be92a /src/nspawn/nspawn.c
parent265d3f718bf50152d83e9f0d7cab3aa39c0ecae2 (diff)
nspawn: check if kernel supports userns as early as possible
If the kernel do not support user namespace then one of the children created by nspawn parent will fail at clone(CLONE_NEWUSER) with the generic error EINVAL and without logging the error. At the same time the parent may also try to setup the user namespace and will fail with another error. To improve this, check if the kernel supports user namespace as early as possible.
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r--src/nspawn/nspawn.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index eea994d0b3..3c31629d1e 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1013,6 +1013,9 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
+ if (arg_userns && access("/proc/self/uid_map", F_OK) < 0)
+ return log_error_errno(EOPNOTSUPP, "--private-users= is not supported, kernel compiled without user namespace support.");
+
arg_retain = (arg_retain | plus | (arg_private_network ? 1ULL << CAP_NET_ADMIN : 0)) & ~minus;
if (arg_boot && arg_kill_signal <= 0)