diff options
author | Alan Somers <asomers@FreeBSD.org> | 2016-07-13 17:09:20 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2016-07-13 17:09:20 +0000 |
commit | 80285e3e194993731e573e5ffa1eba819e283ddd (patch) | |
tree | a6022c60d1351f1b86c630d2144fa0d1ef11de95 /pw/pw_user.c | |
parent | 2a6f15e0cafa2da2bd94b00b1a7285cb9715b5aa (diff) | |
download | pw-darwin-80285e3e194993731e573e5ffa1eba819e283ddd.tar.gz pw-darwin-80285e3e194993731e573e5ffa1eba819e283ddd.tar.zst pw-darwin-80285e3e194993731e573e5ffa1eba819e283ddd.zip |
pw should sanitize the argument of -w.
Otherwise, it will silently disable the login for the selected account if
the argument is unrecognizable.
usr.sbin/pw/pw.h
usr.sbin/pw/pw_conf.c
usr.sbin/pw/pw_user.c
Use separate rules to validate boolean parameters and passwd
parameters. Error out if a password parameter cannot be parsed.
usr.sbin/pw/tests/Makefile
usr.sbin/pw/tests/crypt.c
usr.sbin/pw/tests/pw_useradd.sh
usr.sbin/pw/tests/pw_usermod.sh
Add tests for the validation. Also, enhance existing
password-related tests to actually validate that the correct hash is
written to master.passwd.
Reviewed by: bapt
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D6840
Diffstat (limited to 'pw/pw_user.c')
-rw-r--r-- | pw/pw_user.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c index 67186c3..75e7fb6 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -1315,7 +1315,7 @@ pw_user_add(int argc, char **argv, char *arg1) mix_config(cmdcnf, cnf); if (default_passwd) - cmdcnf->default_password = boolean_val(default_passwd, + cmdcnf->default_password = passwd_val(default_passwd, cnf->default_password); if (genconf) { if (name != NULL) @@ -1717,7 +1717,7 @@ 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 = passwd_val(passwd, cnf->default_password); pwd->pw_passwd = pw_password(cnf, pwd->pw_name, dryrun); edited = true; |