nspawn,man: fix parsing of numeric args for --private-users, accept any boolean

This is like the previous reverted commit, but any boolean is still accepted,
not just "yes" and "no". Man page is adjusted to match the code.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2016-10-10 11:55:06 -04:00
parent 6c2058b35e
commit ae209204d8
2 changed files with 38 additions and 30 deletions
+11 -4
View File
@@ -898,15 +898,21 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_PRIVATE_USERS:
case ARG_PRIVATE_USERS: {
int boolean = -1;
r = optarg ? parse_boolean(optarg) : 1;
if (r == 0) {
if (!optarg)
boolean = true;
else if (!in_charset(optarg, DIGITS))
/* do *not* parse numbers as booleans */
boolean = parse_boolean(optarg);
if (boolean == false) {
/* no: User namespacing off */
arg_userns_mode = USER_NAMESPACE_NO;
arg_uid_shift = UID_INVALID;
arg_uid_range = UINT32_C(0x10000);
} else if (r > 0) {
} else if (boolean == true) {
/* yes: User namespacing on, UID range is read from root dir */
arg_userns_mode = USER_NAMESPACE_FIXED;
arg_uid_shift = UID_INVALID;
@@ -947,6 +953,7 @@ static int parse_argv(int argc, char *argv[]) {
arg_settings_mask |= SETTING_USERNS;
break;
}
case 'U':
if (userns_supported()) {