diff options
Diffstat (limited to 'usr.bin/passwd/local_passwd.c')
-rw-r--r-- | usr.bin/passwd/local_passwd.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c index 6508529..e239683 100644 --- a/usr.bin/passwd/local_passwd.c +++ b/usr.bin/passwd/local_passwd.c @@ -172,20 +172,13 @@ getnewpasswd(pw, nis) #else /* Make a good size salt for algoritms that can use it. */ gettimeofday(&tv,0); - if (strncmp(pw->pw_passwd, "$1$", 3)) { - /* DES Salt */ - to64(&salt[0], random(), 3); - to64(&salt[3], tv.tv_usec, 3); - to64(&salt[6], tv.tv_sec, 2); - salt[8] = '\0'; - } - else { - /* MD5 Salt */ - strncpy(&salt[0], "$1$", 3); - to64(&salt[3], random(), 3); - to64(&salt[6], tv.tv_usec, 3); - salt[8] = '\0'; - } + if (login_setcryptfmt(lc, "md5", NULL) == NULL) + pw_error("cannot set password cipher", 1, 1); + /* Salt suitable for anything */ + to64(&salt[0], random(), 3); + to64(&salt[3], tv.tv_usec, 3); + to64(&salt[6], tv.tv_sec, 2); + salt[8] = '\0'; #endif return (crypt(buf, salt)); } |