summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-08-14 13:39:55 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-08-14 13:39:55 +0000
commit6c4600fad1456d0ed5e8aeb976ef717bf821e879 (patch)
treee9904ae3fafb9d73c2ed46f63bc499cdbd19d0d9
parent26d91ea7b62878a83a10861f1411e02f428816b4 (diff)
downloadpw-darwin-6c4600fad1456d0ed5e8aeb976ef717bf821e879.tar.gz
pw-darwin-6c4600fad1456d0ed5e8aeb976ef717bf821e879.tar.zst
pw-darwin-6c4600fad1456d0ed5e8aeb976ef717bf821e879.zip
Regression: fix pw usermod -w xxx
Reported by: gjb
-rw-r--r--pw/pw_user.c2
-rwxr-xr-xpw/tests/pw_useradd.sh14
2 files changed, 16 insertions, 0 deletions
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
}