Revert r277652
uid and gid are never and should never be negative. The pw(8) manpage clearly states the -u and -g arguments are for uids/gids, hence using negative values is abusing a bug in former versions of pw(8)
This commit is contained in:
parent
6258d2aa15
commit
798d728a63
@ -68,11 +68,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
|
||||
};
|
||||
|
||||
if (a_gid != NULL) {
|
||||
const char *teststr;
|
||||
teststr = a_gid->val;
|
||||
if (*teststr == '-')
|
||||
teststr++;
|
||||
if (strspn(teststr, "0123456789") != strlen(teststr))
|
||||
if (strspn(a_gid->val, "0123456789") != strlen(a_gid->val))
|
||||
errx(EX_USAGE, "-g expects a number");
|
||||
}
|
||||
|
||||
|
@ -322,10 +322,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
|
||||
a_name = NULL;
|
||||
}
|
||||
} else {
|
||||
const char *teststr = a_uid->val;
|
||||
if (*teststr == '-')
|
||||
teststr++;
|
||||
if (strspn(teststr, "0123456789") != strlen(teststr))
|
||||
if (strspn(a_uid->val, "0123456789") != strlen(a_uid->val))
|
||||
errx(EX_USAGE, "-u expects a number");
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,9 @@ ATF_TESTS_SH= pw_etcdir \
|
||||
pw_lock \
|
||||
pw_groupdel \
|
||||
pw_groupmod \
|
||||
pw_groupshow \
|
||||
pw_useradd \
|
||||
pw_userdel \
|
||||
pw_usermod \
|
||||
pw_usershow
|
||||
pw_usermod
|
||||
|
||||
.for tp in ${ATF_TESTS_SH}
|
||||
TEST_METADATA.${tp}+= required_user="root"
|
||||
|
@ -1,19 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# Import helper functions
|
||||
. $(atf_get_srcdir)/helper_functions.shin
|
||||
|
||||
|
||||
# Test negative uid are still valid
|
||||
# PR: 196514
|
||||
atf_test_case show_group_with_negative_number
|
||||
show_group_with_negative_number_body() {
|
||||
populate_etc_skel
|
||||
atf_check -s exit:0 \
|
||||
-o inline:"wheel:*:0:root\n" \
|
||||
${PW} groupshow -n wheel -g -1
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case show_group_with_negative_number
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# Import helper functions
|
||||
. $(atf_get_srcdir)/helper_functions.shin
|
||||
|
||||
|
||||
# Test negative uid are still valid
|
||||
# PR: 196514
|
||||
atf_test_case show_user_with_negative_number
|
||||
show_user_with_negative_number_body() {
|
||||
populate_etc_skel
|
||||
atf_check -s exit:0 \
|
||||
-o inline:"root:*:0:0::0:0:Charlie &:/root:/bin/csh\n" \
|
||||
${PW} usershow -n root -u -1
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case show_user_with_negative_number
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user