summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pw
diff options
context:
space:
mode:
authorantoine <antoine@FreeBSD.org>2008-05-27 19:04:31 +0000
committerantoine <antoine@FreeBSD.org>2008-05-27 19:04:31 +0000
commit13eb9498862d4684ad59847a7c0dafa93dae8b47 (patch)
tree34fe3a0a9de9963deb2594d4e1356bdb3f8fef43 /usr.sbin/pw
parent005545d9160591079540a22302dec37c33fc5979 (diff)
downloadFreeBSD-src-13eb9498862d4684ad59847a7c0dafa93dae8b47.zip
FreeBSD-src-13eb9498862d4684ad59847a7c0dafa93dae8b47.tar.gz
- 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 'usr.sbin/pw')
-rw-r--r--usr.sbin/pw/pw_user.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 0eb1b53..7da16f8 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/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));
}
OpenPOWER on IntegriCloud