From 0c4addea3407c6268cd01be51e8d56a804e5b15d Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 2 Aug 2015 12:47:50 +0000 Subject: Rewrite parsing subcommands arguments of pw(8) Now each subcommands checks its arguments in a dedicated functions. This helps improving input validation, code readability/maintainability While here: - Add a -y option to pw userdel/usermod so it can maintain NIS servers if nispasswd is not defined in pw.conf(5) - Allow pw -r to remove directory with userdel -r - Fix bug when renaming a user which was not renaming the user name it groups it is a member of. - Only parse pw.conf(5) when needed. --- pw/tests/pw_groupdel.sh | 2 +- pw/tests/pw_useradd.sh | 15 ++++++++++++--- pw/tests/pw_userdel.sh | 2 +- pw/tests/pw_usermod.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 60 insertions(+), 8 deletions(-) (limited to 'pw/tests') diff --git a/pw/tests/pw_groupdel.sh b/pw/tests/pw_groupdel.sh index 75b063a..88cc0e0 100755 --- a/pw/tests/pw_groupdel.sh +++ b/pw/tests/pw_groupdel.sh @@ -13,7 +13,7 @@ group_do_not_delete_wheel_if_group_unknown_head() { group_do_not_delete_wheel_if_group_unknown_body() { populate_etc_skel atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel - atf_check -e inline:"pw: -g expects a number\n" -s exit:64 -x \ + atf_check -e inline:"pw: Bad id 'I_do_not_exist': invalid\n" -s exit:64 -x \ ${PW} groupdel -g I_do_not_exist atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel } diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index 7306387..401769b 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -250,9 +250,9 @@ user_add_R_body() { test -d ${HOME}/home/bar || atf_fail "Directory not created" atf_check -s exit:0 ${RPW} userdel bar test -d ${HOME}/home/bar || atf_fail "Directory removed" -# atf_check -s exit:0 ${RPW} useradd bar -# atf_check -s exit:0 ${RPW} userdel bar -r -# test -d ${HOME}/home/bar && atf_fail "Directory not removed" + atf_check -s exit:0 ${RPW} useradd bar + atf_check -s exit:0 ${RPW} userdel bar -r + [ ! -d ${HOME}/home/bar ] || atf_fail "Directory not removed" } atf_test_case user_add_skel @@ -296,6 +296,14 @@ user_add_uid_too_large_body() { ${PW} useradd -n test1 -u 9999999999999 } +atf_test_case user_add_bad_shell +user_add_bad_shell_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} useradd foo -s sh + atf_check -s exit:78 -e ignore ${PW} useradd bar -s badshell +} + atf_init_test_cases() { atf_add_test_case user_add atf_add_test_case user_add_noupdate @@ -321,4 +329,5 @@ atf_init_test_cases() { atf_add_test_case user_add_skel atf_add_test_case user_add_uid0 atf_add_test_case user_add_uid_too_large + atf_add_test_case user_add_bad_shell } diff --git a/pw/tests/pw_userdel.sh b/pw/tests/pw_userdel.sh index 1305cb7..f608029 100755 --- a/pw/tests/pw_userdel.sh +++ b/pw/tests/pw_userdel.sh @@ -27,7 +27,7 @@ user_do_not_try_to_delete_root_if_user_unknown_head() { } user_do_not_try_to_delete_root_if_user_unknown_body() { populate_etc_skel - atf_check -e inline:"pw: -u expects a number\n" -s exit:64 -x \ + atf_check -e inline:"pw: Bad id 'plop': invalid\n" -s exit:64 -x \ ${PW} userdel -u plop } diff --git a/pw/tests/pw_usermod.sh b/pw/tests/pw_usermod.sh index 006bb2c..7acc7a5 100755 --- a/pw/tests/pw_usermod.sh +++ b/pw/tests/pw_usermod.sh @@ -100,6 +100,36 @@ user_mod_name_noupdate_body() { grep "^foo:.*" $HOME/master.passwd } +atf_test_case user_mod_rename_multigroups +user_mod_rename_multigroups_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} groupadd test1 + atf_check -s exit:0 ${PW} groupadd test2 + atf_check -s exit:0 ${PW} useradd foo -G test1,test2 + atf_check -o match:"foo" -s exit:0 ${PW} groupshow test1 + atf_check -o match:"foo" -s exit:0 ${PW} groupshow test2 + atf_check -s exit:0 ${PW} usermod foo -l bar + atf_check -o match:"bar" -s exit:0 ${PW} groupshow test1 + atf_check -o match:"bar" -s exit:0 ${PW} groupshow test2 +} + +atf_test_case user_mod_nogroups +user_mod_nogroups_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} groupadd test1 + atf_check -s exit:0 ${PW} groupadd test2 + atf_check -s exit:0 ${PW} groupadd test3 + atf_check -s exit:0 ${PW} groupadd test4 + atf_check -s exit:0 ${PW} useradd foo -G test1,test2 + atf_check -o match:"foo" -s exit:0 ${PW} groupshow test1 + atf_check -o match:"foo" -s exit:0 ${PW} groupshow test2 + atf_check -s exit:0 ${PW} usermod foo -G test3,test4 + atf_check -s exit:0 -o inline:"test3\ntest4\n" \ + awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group +} + atf_test_case user_mod_rename user_mod_rename_body() { populate_etc_skel @@ -134,7 +164,7 @@ user_mod_h_body() { EOF atf_check -s exit:0 -o match:"^foo:\*:.*" \ grep "^foo" ${HOME}/master.passwd - atf_check -e inline:"pw: '-h' expects a file descriptor or '-'\n" \ + atf_check -e inline:"pw: Bad file descriptor 'a': invalid\n" \ -s exit:64 ${PW} usermod foo -h a <<- EOF $(echo a) EOF @@ -150,10 +180,21 @@ user_mod_H_body() { EOF atf_check -s exit:0 -o match:"^foo:a:.*" \ grep "^foo" ${HOME}/master.passwd - atf_check -s exit:64 -e inline:"pw: '-H' expects a file descriptor\n" \ + atf_check -s exit:64 -e inline:"pw: -H expects a file descriptor\n" \ ${PW} usermod foo -H - } +atf_test_case user_mod_renamehome +user_mod_renamehome_body() { + populate_root_etc_skel + + mkdir -p ${HOME}/home + atf_check -s exit:0 ${RPW} useradd foo -m + test -d ${HOME}/home/foo || atf_fail "Directory not created" + atf_check -s exit:0 ${RPW} usermod foo -l bar -d /home/bar -m + test -d ${HOME}/home/bar || atf_fail "Directory not created" +} + atf_init_test_cases() { atf_add_test_case user_mod atf_add_test_case user_mod_noupdate @@ -161,10 +202,12 @@ atf_init_test_cases() { atf_add_test_case user_mod_comments_noupdate atf_add_test_case user_mod_comments_invalid atf_add_test_case user_mod_comments_invalid_noupdate + atf_add_test_case user_mod_nogroups atf_add_test_case user_mod_rename atf_add_test_case user_mod_name_noupdate - atf_add_test_case user_mod_rename atf_add_test_case user_mod_rename_too_long + atf_add_test_case user_mod_rename_multigroups atf_add_test_case user_mod_h atf_add_test_case user_mod_H + atf_add_test_case user_mod_renamehome } -- cgit v1.2.3-56-ge451 From 86b70b831eed513183b8ad9ad2dc3c46acb483f0 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 2 Aug 2015 13:02:53 +0000 Subject: Add regression tests about adding already existsing groups/users --- pw/tests/pw_groupadd.sh | 11 +++++++++++ pw/tests/pw_useradd.sh | 11 +++++++++++ 2 files changed, 22 insertions(+) (limited to 'pw/tests') diff --git a/pw/tests/pw_groupadd.sh b/pw/tests/pw_groupadd.sh index 9c8fdf1..5fa7bef 100755 --- a/pw/tests/pw_groupadd.sh +++ b/pw/tests/pw_groupadd.sh @@ -10,6 +10,17 @@ group_add_gid_too_large_body() { ${PW} groupadd -n test1 -g 9999999999999 } +atf_test_case group_add_already_exists +group_add_already_exists_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} groupadd foo + atf_check -s exit:65 \ + -e inline:"pw: group name \`foo' already exists\n" \ + ${PW} groupadd foo +} + atf_init_test_cases() { atf_add_test_case group_add_gid_too_large + atf_add_test_case group_add_already_exists } diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index 401769b..f42980d 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -304,6 +304,16 @@ user_add_bad_shell_body() { atf_check -s exit:78 -e ignore ${PW} useradd bar -s badshell } +atf_test_case user_add_already_exists +user_add_already_exists_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} useradd foo + atf_check -s exit:65 \ + -e inline:"pw: login name \`foo' already exists\n" \ + ${PW} useradd foo +} + atf_init_test_cases() { atf_add_test_case user_add atf_add_test_case user_add_noupdate @@ -330,4 +340,5 @@ atf_init_test_cases() { atf_add_test_case user_add_uid0 atf_add_test_case user_add_uid_too_large atf_add_test_case user_add_bad_shell + atf_add_test_case user_add_already_exists } -- cgit v1.2.3-56-ge451 From b1b00058669f8b922b52845bb7f0175de6df27c3 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 2 Aug 2015 18:20:36 +0000 Subject: Convert the year used for regression test fro 2043 to 2037 This makes the regression tests pass on systems where time_t is 32bits --- pw/tests/pw_useradd.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'pw/tests') diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index f42980d..2ac31c9 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -181,29 +181,29 @@ user_add_expiration_body() { populate_etc_skel atf_check -s exit:0 \ - ${PW} useradd foo -e 20-03-2043 - atf_check -o inline:"foo:*:1001:1001::0:2310422400:User &:/home/foo:/bin/sh\n" \ + ${PW} useradd foo -e 20-03-2037 + atf_check -o inline:"foo:*:1001:1001::0:2121120000:User &:/home/foo:/bin/sh\n" \ -s exit:0 grep "^foo" ${HOME}/master.passwd atf_check -s exit:0 ${PW} userdel foo atf_check -s exit:0 \ - ${PW} useradd foo -e 20-03-43 - atf_check -o inline:"foo:*:1001:1001::0:2310422400:User &:/home/foo:/bin/sh\n" \ + ${PW} useradd foo -e 20-03-37 + atf_check -o inline:"foo:*:1001:1001::0:2121120000:User &:/home/foo:/bin/sh\n" \ -s exit:0 grep "^foo" ${HOME}/master.passwd atf_check -s exit:0 ${PW} userdel foo atf_check -s exit:0 \ - ${PW} useradd foo -e 20-Mar-2043 - atf_check -o inline:"foo:*:1001:1001::0:2310422400:User &:/home/foo:/bin/sh\n" \ + ${PW} useradd foo -e 20-Mar-2037 + atf_check -o inline:"foo:*:1001:1001::0:2121120000:User &:/home/foo:/bin/sh\n" \ -s exit:0 grep "^foo" ${HOME}/master.passwd atf_check -s exit:0 ${PW} userdel foo atf_check -e inline:"pw: Invalid date\n" -s exit:1 \ - ${PW} useradd foo -e 20-Foo-2043 + ${PW} useradd foo -e 20-Foo-2037 atf_check -e inline:"pw: Invalid date\n" -s exit:1 \ - ${PW} useradd foo -e 20-13-2043 - atf_check -s exit:0 ${PW} useradd foo -e "12:00 20-03-2043" + ${PW} useradd foo -e 20-13-2037 + atf_check -s exit:0 ${PW} useradd foo -e "12:00 20-03-2037" atf_check -s exit:0 ${PW} userdel foo atf_check -e inline:"pw: Invalid date\n" -s exit:1 \ - ${PW} useradd foo -e "12 20-03-2043" - atf_check -s exit:0 ${PW} useradd foo -e "20-03-2043 12:00" + ${PW} useradd foo -e "12 20-03-2037" + atf_check -s exit:0 ${PW} useradd foo -e "20-03-2037 12:00" atf_check -s exit:0 ${PW} userdel foo } -- cgit v1.2.3-56-ge451 From 26d91ea7b62878a83a10861f1411e02f428816b4 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 5 Aug 2015 21:11:32 +0000 Subject: Add regression tests for a bug reported in stable/10 While pw(8) on head is not affected it is worth adding more regression tests ensuring this bug will not happen unnoticed in the futur --- pw/tests/pw_usermod.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pw/tests') diff --git a/pw/tests/pw_usermod.sh b/pw/tests/pw_usermod.sh index 7acc7a5..236fd27 100755 --- a/pw/tests/pw_usermod.sh +++ b/pw/tests/pw_usermod.sh @@ -195,6 +195,14 @@ user_mod_renamehome_body() { test -d ${HOME}/home/bar || atf_fail "Directory not created" } +atf_test_case user_mod_uid +user_mod_uid_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} useradd foo + atf_check -s exit:0 ${PW} usermod foo -u 5000 +} + atf_init_test_cases() { atf_add_test_case user_mod atf_add_test_case user_mod_noupdate @@ -210,4 +218,5 @@ atf_init_test_cases() { atf_add_test_case user_mod_h atf_add_test_case user_mod_H atf_add_test_case user_mod_renamehome + atf_add_test_case user_mod_uid } -- cgit v1.2.3-56-ge451 From 6c4600fad1456d0ed5e8aeb976ef717bf821e879 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 14 Aug 2015 13:39:55 +0000 Subject: Regression: fix pw usermod -w xxx Reported by: gjb --- pw/pw_user.c | 2 ++ pw/tests/pw_useradd.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'pw/tests') diff --git a/pw/pw_user.c b/pw/pw_user.c index d9bce87..5ccbd53 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -1645,6 +1645,8 @@ pw_user_mod(int argc, char **argv, char *arg1) if (lc == NULL || login_setcryptfmt(lc, "sha512", NULL) == NULL) warn("setting crypt(3) format"); login_close(lc); + cnf->default_password = boolean_val(passwd, + cnf->default_password); pwd->pw_passwd = pw_password(cnf, pwd->pw_name, dryrun); edited = true; } diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index 2ac31c9..f126bf0 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -314,6 +314,19 @@ user_add_already_exists_body() { ${PW} useradd foo } +atf_test_case user_add_w_yes +user_add_w_yes_body() { + populate_etc_skel + atf_check -s exit:0 ${PW} useradd foo -w yes + atf_check -s exit:0 \ + -o match:'^foo:\$.*' \ + grep "^foo" ${HOME}/master.passwd + atf_check -s exit:0 ${PW} usermod foo -w yes + atf_check -s exit:0 \ + -o match:'^foo:\$.*' \ + grep "^foo" ${HOME}/master.passwd +} + atf_init_test_cases() { atf_add_test_case user_add atf_add_test_case user_add_noupdate @@ -341,4 +354,5 @@ atf_init_test_cases() { atf_add_test_case user_add_uid_too_large atf_add_test_case user_add_bad_shell atf_add_test_case user_add_already_exists + atf_add_test_case user_add_w_yes } -- cgit v1.2.3-56-ge451 From 48159f268a0b0a6f5a378fa469e16c779ec1d49b Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 21 Aug 2015 07:09:53 +0000 Subject: Fix useradd regression: Readd the function to create the parents home directory if it does not exists. if it is only a directory at the top level of the hierarchy symlink it into /usr as it used to be done before. Reported by: kevlo, adrian --- pw/pw_user.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ pw/tests/pw_useradd.sh | 3 +-- 2 files changed, 67 insertions(+), 2 deletions(-) (limited to 'pw/tests') diff --git a/pw/pw_user.c b/pw/pw_user.c index 5ccbd53..35eb1fb 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -38,6 +38,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -84,12 +85,77 @@ static char *shell_path(char const * path, char *shells[], char *sh); static void rmat(uid_t uid); static void rmopie(char const * name); +static void +mkdir_home_parents(int dfd, const char *dir) +{ + struct stat st; + char *dirs, *tmp; + + if (*dir != '/') + errx(EX_DATAERR, "invalid base directory for home '%s'", dir); + + dir++; + + if (fstatat(dfd, dir, &st, 0) != -1) { + if (S_ISDIR(st.st_mode)) + return; + errx(EX_OSFILE, "root home `/%s' is not a directory", dir); + } + + dirs = strdup(dir); + if (dirs == NULL) + errx(EX_UNAVAILABLE, "out of memory"); + + tmp = strrchr(dirs, '/'); + if (tmp == NULL) + return; + tmp[0] = '\0'; + + /* + * This is a kludge especially for Joerg :) + * If the home directory would be created in the root partition, then + * we really create it under /usr which is likely to have more space. + * But we create a symlink from cnf->home -> "/usr" -> cnf->home + */ + if (strchr(dirs, '/') == NULL) { + asprintf(&tmp, "usr/%s", dirs); + if (tmp == NULL) + errx(EX_UNAVAILABLE, "out of memory"); + if (mkdirat(dfd, tmp, _DEF_DIRMODE) != -1 || errno == EEXIST) { + fchownat(dfd, tmp, 0, 0, 0); + symlinkat(tmp, dfd, dirs + 1); + } + free(tmp); + } + tmp = dirs; + if (fstatat(dfd, dirs, &st, 0) == -1) { + while ((tmp = strchr(tmp + 1, '/')) != NULL) { + *tmp = '\0'; + if (fstatat(dfd, dirs, &st, 0) == -1) { + if (mkdirat(dfd, dirs, _DEF_DIRMODE) == -1) + err(EX_OSFILE, "'%s' (root home parent) is not a directory", dirs); + } + *tmp = '/'; + } + } + if (fstatat(dfd, dirs, &st, 0) == -1) { + if (mkdirat(dfd, dirs, _DEF_DIRMODE) == -1) + err(EX_OSFILE, "'%s' (root home parent) is not a directory", dirs); + fchownat(dfd, dirs, 0, 0, 0); + } + + free(dirs); +} + static void create_and_populate_homedir(struct userconf *cnf, struct passwd *pwd, const char *skeldir, mode_t homemode, bool update) { int skelfd = -1; + /* Create home parents directories */ + mkdir_home_parents(conf.rootfd, pwd->pw_dir); + if (skeldir != NULL && *skeldir != '\0') { if (*skeldir == '/') skeldir++; diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index f126bf0..d27df73 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -245,7 +245,6 @@ user_add_R_body() { populate_root_etc_skel atf_check -s exit:0 ${RPW} useradd foo - mkdir -p ${HOME}/home atf_check -s exit:0 ${RPW} useradd bar -m test -d ${HOME}/home/bar || atf_fail "Directory not created" atf_check -s exit:0 ${RPW} userdel bar @@ -260,7 +259,7 @@ user_add_skel_body() { populate_root_etc_skel mkdir ${HOME}/skel - echo "a" > ${HOME}/skel/.a + echo "a" > ${HOME}/skel/.ae echo "b" > ${HOME}/skel/b mkdir ${HOME}/skel/c mkdir ${HOME}/skel/c/d -- cgit v1.2.3-56-ge451 From 05dcc5f83aecfd44010756bea5114896033cfb1b Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 21 Aug 2015 09:28:20 +0000 Subject: Fix /home symlink creation Add regression test about it --- pw/pw_user.c | 2 +- pw/tests/pw_useradd.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'pw/tests') diff --git a/pw/pw_user.c b/pw/pw_user.c index 35eb1fb..61d468a 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -123,7 +123,7 @@ mkdir_home_parents(int dfd, const char *dir) errx(EX_UNAVAILABLE, "out of memory"); if (mkdirat(dfd, tmp, _DEF_DIRMODE) != -1 || errno == EEXIST) { fchownat(dfd, tmp, 0, 0, 0); - symlinkat(tmp, dfd, dirs + 1); + symlinkat(tmp, dfd, dirs); } free(tmp); } diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index d27df73..10c7816 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -246,6 +246,7 @@ user_add_R_body() { atf_check -s exit:0 ${RPW} useradd foo atf_check -s exit:0 ${RPW} useradd bar -m + test -d ${HOME}/home || atf_fail "Home parent directory not created" test -d ${HOME}/home/bar || atf_fail "Directory not created" atf_check -s exit:0 ${RPW} userdel bar test -d ${HOME}/home/bar || atf_fail "Directory removed" @@ -254,6 +255,17 @@ user_add_R_body() { [ ! -d ${HOME}/home/bar ] || atf_fail "Directory not removed" } +atf_test_case user_add_R_symlink +user_add_R_symlink_body() { + populate_root_etc_skel + + mkdir ${HOME}/usr + atf_check -s exit:0 ${RPW} useradd foo -m + test -d ${HOME}/usr/home || atf_fail "Home parent directory not created" + test -h ${HOME}/home || atf_fail "/home directory is not a symlink" + atf_check -s exit:0 -o inline:"usr/home\n" readlink ${HOME}/home +} + atf_test_case user_add_skel user_add_skel_body() { populate_root_etc_skel @@ -348,6 +360,7 @@ atf_init_test_cases() { atf_add_test_case user_add_invalid_group_entry atf_add_test_case user_add_password_from_h atf_add_test_case user_add_R + atf_add_test_case user_add_R_symlink atf_add_test_case user_add_skel atf_add_test_case user_add_uid0 atf_add_test_case user_add_uid_too_large -- cgit v1.2.3-56-ge451 From 151854066c201774b371039259b8130d6f32235c Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 21 Aug 2015 11:25:42 +0000 Subject: Fix typo in regression test --- pw/tests/pw_useradd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pw/tests') diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index 10c7816..0c3a39e 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -271,7 +271,7 @@ user_add_skel_body() { populate_root_etc_skel mkdir ${HOME}/skel - echo "a" > ${HOME}/skel/.ae + echo "a" > ${HOME}/skel/.a echo "b" > ${HOME}/skel/b mkdir ${HOME}/skel/c mkdir ${HOME}/skel/c/d -- cgit v1.2.3-56-ge451 From 405476b14c422483c28c44621a1a652a499baa49 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 21 Aug 2015 14:28:14 +0000 Subject: Fix err pointer not initialized to NULL resulting Reported by: "O. Hartmann" --- pw/strtounum.c | 1 + pw/tests/pw_useradd.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'pw/tests') diff --git a/pw/strtounum.c b/pw/strtounum.c index be57276..b2fefeb 100644 --- a/pw/strtounum.c +++ b/pw/strtounum.c @@ -41,6 +41,7 @@ strtounum(const char * __restrict np, uintmax_t minval, uintmax_t maxval, char *endp; uintmax_t ret; + *errpp = NULL; if (minval > maxval) { errno = EINVAL; if (errpp != NULL) diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index 0c3a39e..cb62944 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -338,6 +338,20 @@ user_add_w_yes_body() { grep "^foo" ${HOME}/master.passwd } +atf_test_case user_add_with_pw_conf +user_add_with_pw_conf_body() +{ + populate_etc_skel + atf_check -s exit:0 \ + ${PW} useradd -D -C ${HOME}/pw.conf \ + -u 2000,32767 -i 2000,32767 + atf_check -s exit:0 \ + -o inline:"minuid = 2000\nmaxuid = 32767\nmingid = 2000\nmaxgid = 32767\n" \ + grep "^m.*id =" ${HOME}/pw.conf + atf_check -s exit:0 \ + ${PW} useradd foo -C ${HOME}/pw.conf +} + atf_init_test_cases() { atf_add_test_case user_add atf_add_test_case user_add_noupdate @@ -367,4 +381,5 @@ atf_init_test_cases() { atf_add_test_case user_add_bad_shell atf_add_test_case user_add_already_exists atf_add_test_case user_add_w_yes + atf_add_test_case user_add_with_pw_conf } -- cgit v1.2.3-56-ge451 From 14af77aebe6b5dc81bb06083fe651696beac1546 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 12 Oct 2015 08:16:03 +0000 Subject: Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and netbsd-tests.test.mk (r289151) - Eliminate explicit OBJTOP/SRCTOP setting - Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk - Remove unnecessary TESTSDIR setting - Use SRCTOP where possible for clarity MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Divison --- pw/tests/Makefile | 2 -- 1 file changed, 2 deletions(-) (limited to 'pw/tests') diff --git a/pw/tests/Makefile b/pw/tests/Makefile index a1605aa..27f0ac4 100644 --- a/pw/tests/Makefile +++ b/pw/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.sbin/pw - ATF_TESTS_SH= pw_etcdir \ pw_lock \ pw_config \ -- cgit v1.2.3-56-ge451