summaryrefslogtreecommitdiffstats
path: root/usr.bin/passwd/local_passwd.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1994-11-06 21:08:19 +0000
committerphk <phk@FreeBSD.org>1994-11-06 21:08:19 +0000
commit079f14a8618ff417287261cb8984c50f3ba751de (patch)
tree193bb5a74b07e9cda607aca933026b6537dfe791 /usr.bin/passwd/local_passwd.c
parent3cdc22268f9c7bc1065f1b898e93fd30a70678c7 (diff)
downloadFreeBSD-src-079f14a8618ff417287261cb8984c50f3ba751de.zip
FreeBSD-src-079f14a8618ff417287261cb8984c50f3ba751de.tar.gz
Always make the salt a 8 char string (incl '\0') for algorithms that can use it
Diffstat (limited to 'usr.bin/passwd/local_passwd.c')
-rw-r--r--usr.bin/passwd/local_passwd.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c
index 804c48e..89d485f 100644
--- a/usr.bin/passwd/local_passwd.c
+++ b/usr.bin/passwd/local_passwd.c
@@ -36,6 +36,7 @@ static char sccsid[] = "@(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/types.h>
+#include <sys/time.h>
#include <ctype.h>
#include <err.h>
@@ -78,6 +79,7 @@ getnewpasswd(pw)
int tries;
char *p, *t;
char buf[_PASSWORD_LEN+1], salt[9];
+ struct timeval tv;
(void)printf("Changing local password for %s.\n", pw->pw_name);
@@ -115,7 +117,12 @@ getnewpasswd(pw)
to64(&salt[1], (long)(29 * 25), 4);
to64(&salt[5], random(), 4);
#else
- to64(&salt[0], random(), 2);
+ /* Make a good size salt for algoritms that can use it. */
+ to64(&salt[0], random(), 3);
+ gettimeofday(&tv,0);
+ 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