summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2002-02-04 00:28:54 +0000
committermarkm <markm@FreeBSD.org>2002-02-04 00:28:54 +0000
commit01ec73592ad8a9c1cf6e6dbdfdafd45b3f1b48c7 (patch)
tree49a680aa74268957c8e9840ecf4f32da53125457
parent686fec549ba9cb492e3a686382c21bd0b4d4e555 (diff)
downloadFreeBSD-src-01ec73592ad8a9c1cf6e6dbdfdafd45b3f1b48c7.zip
FreeBSD-src-01ec73592ad8a9c1cf6e6dbdfdafd45b3f1b48c7.tar.gz
Add the other half of the salt-generating code. No functional
difference except that the salt is slightly harder to build dictionaries against, and the code does not use srandom[dev]().
-rw-r--r--lib/libpam/modules/pam_unix/pam_unix.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/libpam/modules/pam_unix/pam_unix.c b/lib/libpam/modules/pam_unix/pam_unix.c
index 6f58586..6eb4437 100644
--- a/lib/libpam/modules/pam_unix/pam_unix.c
+++ b/lib/libpam/modules/pam_unix/pam_unix.c
@@ -668,15 +668,14 @@ yp_passwd(const char *user, const char *pass)
syslog(LOG_ERR, "cannot set password cipher");
login_close(lc);
/* Salt suitable for anything */
- srandomdev();
gettimeofday(&tv, 0);
- to64(&salt[0], random(), 3);
- to64(&salt[3], tv.tv_usec, 3);
- to64(&salt[6], tv.tv_sec, 2);
- to64(&salt[8], random(), 5);
- to64(&salt[13], random(), 5);
- to64(&salt[17], random(), 5);
- to64(&salt[22], random(), 5);
+ to64(&salt[0], (tv.tv_sec ^ random()) * tv.tv_usec, 3);
+ to64(&salt[3], (getpid() ^ random()) * tv.tv_usec, 2);
+ to64(&salt[5], (getppid() ^ random()) * tv.tv_usec, 3);
+ to64(&salt[8], (getuid() ^ random()) * tv.tv_usec, 5);
+ to64(&salt[13], (getgid() ^ random()) * tv.tv_usec, 5);
+ to64(&salt[17], random() * tv.tv_usec, 5);
+ to64(&salt[22], random() * tv.tv_usec, 5);
salt[27] = '\0';
if (suser_override)
OpenPOWER on IntegriCloud