aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1994-11-06 21:08:19 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1994-11-06 21:08:19 +0000
commit3dfc7586e5e6371845bec073d83ff681c9a0df61 (patch)
tree193bb5a74b07e9cda607aca933026b6537dfe791
parent7bcf49f36861ce8a17575812684899aa6269e0d2 (diff)
downloadsrc-3dfc7586e5e6371845bec073d83ff681c9a0df61.tar.gz
src-3dfc7586e5e6371845bec073d83ff681c9a0df61.zip
Always make the salt a 8 char string (incl '\0') for algorithms that can use it
Notes
Notes: svn path=/head/; revision=4214
-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 804c48e3dd4e..89d485fc7eb2 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));
}