Page MenuHomeFreeBSD

D61392.1794408407.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D61392.1794408407.diff

diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -629,7 +629,7 @@
showtype = "gecos field";
} else {
/* See if the name is valid as a userid or group. */
- badchars = " ,\t:+&#%$^()!@~*?<>=|\\/\";";
+ badchars = " ,\t:+&#%$^()!@~*?<>=|\\/\";'`";
showtype = "userid/group name";
/* Userids and groups can not have a leading '-'. */
if (*ch == '-')
diff --git a/usr.sbin/pw/tests/pw_useradd_test.sh b/usr.sbin/pw/tests/pw_useradd_test.sh
--- a/usr.sbin/pw/tests/pw_useradd_test.sh
+++ b/usr.sbin/pw/tests/pw_useradd_test.sh
@@ -186,6 +186,21 @@
atf_check -s exit:1 -o empty grep "^test user:.*" $HOME/master.passwd
}
+atf_test_case user_add_name_with_quotes
+user_add_name_with_quotes_body() {
+ populate_etc_skel
+ for user_name in 'test`id`' "test'user"; do
+ atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} useradd "${user_name}"
+ atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} useradd -n "${user_name}"
+ atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} groupadd "${user_name}"
+ done
+ atf_check -s exit:1 -o empty grep "^test" $HOME/master.passwd
+ atf_check -s exit:1 -o empty grep "^test" $HOME/group
+}
+
atf_test_case user_add_name_with_spaces_and_gid_specified
user_add_name_with_spaces_and_gid_specified_body() {
populate_etc_skel
@@ -578,6 +593,7 @@
atf_add_test_case user_add_password_expiration_date_relative
atf_add_test_case user_add_name_too_long
atf_add_test_case user_add_name_with_spaces
+ atf_add_test_case user_add_name_with_quotes
atf_add_test_case user_add_name_with_spaces_and_gid_specified
atf_add_test_case user_add_expiration
atf_add_test_case user_add_invalid_user_entry

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 11, 2:46 PM (15 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41661022
Default Alt Text
D61392.1794408407.diff (1 KB)

Event Timeline