summaryrefslogtreecommitdiff
path: root/src/nspawn
diff options
context:
space:
mode:
Diffstat (limited to 'src/nspawn')
-rw-r--r--src/nspawn/nspawn.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 40e3d5a3fe..c8a7ec71a3 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -866,11 +866,14 @@ static int parse_argv(int argc, char *argv[]) {
break;
case 'U':
- arg_userns_mode = USER_NAMESPACE_PICK;
- arg_uid_shift = UID_INVALID;
- arg_uid_range = UINT32_C(0x10000);
+ if (userns_supported()) {
+ arg_userns_mode = USER_NAMESPACE_PICK;
+ arg_uid_shift = UID_INVALID;
+ arg_uid_range = UINT32_C(0x10000);
+
+ arg_settings_mask |= SETTING_USERNS;
+ }
- arg_settings_mask |= SETTING_USERNS;
break;
case ARG_PRIVATE_USERS_CHOWN:
@@ -990,7 +993,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
- if (arg_userns_mode != USER_NAMESPACE_NO && access("/proc/self/uid_map", F_OK) < 0) {
+ if (arg_userns_mode != USER_NAMESPACE_NO && !userns_supported()) {
log_error("--private-users= is not supported, kernel compiled without user namespace support.");
return -EOPNOTSUPP;
}