summaryrefslogtreecommitdiffstats
path: root/usr.bin/passwd
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2000-08-22 02:15:54 +0000
committergreen <green@FreeBSD.org>2000-08-22 02:15:54 +0000
commit67c40ef892e23a375a1eeec51d343ef6be31f5d8 (patch)
tree7fd6719b0a54565971e388646c8ae7f62b08674b /usr.bin/passwd
parent219e29595a8d293c1e81f0136a866f25a69d648e (diff)
downloadFreeBSD-src-67c40ef892e23a375a1eeec51d343ef6be31f5d8.zip
FreeBSD-src-67c40ef892e23a375a1eeec51d343ef6be31f5d8.tar.gz
Add working and easy crypt(3)-switching. Yes, we need a whole new API
for crypt(3) by now. In any case: Add crypt_set_format(3) + documentation to -lcrypt. Add login_setcryptfmt(3) + documentation to -lutil. Support for switching crypt formats in passwd(8). Support for switching crypt formats in pw(8). The simple synopsis is: edit login.conf; add a passwd_format field set to "des" or "md5"; go nuts :) Reviewed by: peter
Diffstat (limited to 'usr.bin/passwd')
-rw-r--r--usr.bin/passwd/local_passwd.c21
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));
}
OpenPOWER on IntegriCloud