diff options
author | Antoine Brodin <antoine@FreeBSD.org> | 2008-05-27 19:04:31 +0000 |
---|---|---|
committer | Antoine Brodin <antoine@FreeBSD.org> | 2008-05-27 19:04:31 +0000 |
commit | 09b467206915e719fe1be4e13130bbd7dab65ebe (patch) | |
tree | a35b23dc04f2b733735839b07b4bd33db7dc6332 /pw | |
parent | 97cc03f4f3328180c8f49cd61c406bb7bc8a2dcb (diff) | |
download | pw-darwin-09b467206915e719fe1be4e13130bbd7dab65ebe.tar.gz pw-darwin-09b467206915e719fe1be4e13130bbd7dab65ebe.tar.zst pw-darwin-09b467206915e719fe1be4e13130bbd7dab65ebe.zip |
- Increase the size of the salt in pw(8) from 8 to 32 (same as in pam_unix(8)).
This makes blowfish password hashes look normal when set using
pw(8)/adduser(8). [1]
- Make it possible to have a '/' in the salt.
PR: 121146 [1]
Submitted by: Jaakko Heinonen [1]
Approved by: rwatson (mentor)
MFC after: 1 month
Diffstat (limited to 'pw')
-rw-r--r-- | pw/pw_user.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c index 0eb1b53..7da16f8 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -1029,22 +1029,24 @@ pw_shellpolicy(struct userconf * cnf, struct cargs * args, char *newshell) return shell_path(cnf->shelldir, cnf->shells, sh ? sh : cnf->shell_default); } -static char const chars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ."; +#define SALTSIZE 32 + +static char const chars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./"; char * pw_pwcrypt(char *password) { int i; - char salt[12]; + char salt[SALTSIZE + 1]; static char buf[256]; /* * Calculate a salt value */ - for (i = 0; i < 8; i++) - salt[i] = chars[arc4random() % 63]; - salt[i] = '\0'; + for (i = 0; i < SALTSIZE; i++) + salt[i] = chars[arc4random() % (sizeof(chars) - 1)]; + salt[SALTSIZE] = '\0'; return strcpy(buf, crypt(password, salt)); } |