diff options
author | Sam Leonard <sam.leonard@codethink.co.uk> | 2024-01-30 14:24:49 +0100 |
---|---|---|
committer | Sam Leonard <sam.leonard@codethink.co.uk> | 2024-02-12 10:46:01 +0100 |
commit | d4a58877e458e0e81f8810a73ce2d7836cd89db1 (patch) | |
tree | 386c88bc78a00a8095f40fefcca8b304487fffc2 /src/nspawn | |
parent | basic/namespace-util: add parse_userns_uid_range (diff) | |
download | systemd-d4a58877e458e0e81f8810a73ce2d7836cd89db1.tar.xz systemd-d4a58877e458e0e81f8810a73ce2d7836cd89db1.zip |
nspawn: use parse_userns_uid_range
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn.c | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index ae5172853b..e7dd2a370c 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1255,33 +1255,11 @@ static int parse_argv(int argc, char *argv[]) { arg_uid_shift = 0; arg_uid_range = UINT32_C(0x10000); } else { - _cleanup_free_ char *buffer = NULL; - const char *range, *shift; - /* anything else: User namespacing on, UID range is explicitly configured */ - - range = strchr(optarg, ':'); - if (range) { - buffer = strndup(optarg, range - optarg); - if (!buffer) - return log_oom(); - shift = buffer; - - range++; - r = safe_atou32(range, &arg_uid_range); - if (r < 0) - return log_error_errno(r, "Failed to parse UID range \"%s\": %m", range); - } else - shift = optarg; - - r = parse_uid(shift, &arg_uid_shift); + r = parse_userns_uid_range(optarg, &arg_uid_shift, &arg_uid_range); if (r < 0) - return log_error_errno(r, "Failed to parse UID \"%s\": %m", optarg); - + return r; arg_userns_mode = USER_NAMESPACE_FIXED; - - if (!userns_shift_range_valid(arg_uid_shift, arg_uid_range)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "UID range cannot be empty or go beyond " UID_FMT ".", UID_INVALID); } arg_settings_mask |= SETTING_USERNS; |