diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2014-11-20 14:53:16 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2014-11-20 14:53:16 +0000 |
commit | fe86f637859a12603040aaf13a9fdefe8f45dda5 (patch) | |
tree | 0008fb210bf330614b0c0625eb4aad9cbba26694 | |
parent | 7345488e16bacba9864a516ad2111f2c8c64ee83 (diff) |
switch to using crypt_newhash interface. ok deraadt
-rw-r--r-- | usr.bin/passwd/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/passwd/local_passwd.c | 16 | ||||
-rw-r--r-- | usr.bin/passwd/yp_passwd.c | 17 |
3 files changed, 20 insertions, 17 deletions
diff --git a/usr.bin/passwd/Makefile b/usr.bin/passwd/Makefile index e73d0478afd..45d09aab3fe 100644 --- a/usr.bin/passwd/Makefile +++ b/usr.bin/passwd/Makefile @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile,v 1.38 2014/04/22 10:21:56 reyk Exp $ +# $OpenBSD: Makefile,v 1.39 2014/11/20 14:53:15 tedu Exp $ .include <bsd.own.mk> PROG= passwd -SRCS= local_passwd.c yp_passwd.c passwd.c pwd_gensalt.c getpwent.c \ +SRCS= local_passwd.c yp_passwd.c passwd.c getpwent.c \ pwd_check.c .PATH: ${.CURDIR}/../../lib/libc/gen DPADD+= ${LIBRPCSVC} ${LIBUTIL} diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c index c135aeecb7a..47d348c017d 100644 --- a/usr.bin/passwd/local_passwd.c +++ b/usr.bin/passwd/local_passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: local_passwd.c,v 1.42 2014/11/11 21:06:24 tedu Exp $ */ +/* $OpenBSD: local_passwd.c,v 1.43 2014/11/20 14:53:15 tedu Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -146,9 +146,10 @@ local_passwd(char *uname, int authenticated) char * getnewpasswd(struct passwd *pw, login_cap_t *lc, int authenticated) { + static char hash[_PASSWORD_LEN]; char *p; int tries, pwd_tries; - char buf[_PASSWORD_LEN+1], salt[_PASSWORD_LEN]; + char buf[1024]; sig_t saveint, savequit; saveint = signal(SIGINT, kbintr); @@ -193,14 +194,15 @@ getnewpasswd(struct passwd *pw, login_cap_t *lc, int authenticated) break; (void)printf("Mismatch; try again, EOF to quit.\n"); } - if (!pwd_gensalt(salt, _PASSWORD_LEN, lc, 'l')) { - (void)printf("Couldn't generate salt.\n"); - pw_error(NULL, 0, 0); - } + (void)signal(SIGINT, saveint); (void)signal(SIGQUIT, savequit); - return(crypt(buf, salt)); + if (crypt_newhash(buf, lc, hash, sizeof(hash)) != 0) { + (void)printf("Couldn't generate hash.\n"); + pw_error(NULL, 0, 0); + } + return hash; } /* ARGSUSED */ diff --git a/usr.bin/passwd/yp_passwd.c b/usr.bin/passwd/yp_passwd.c index e94380240cc..f37c817a794 100644 --- a/usr.bin/passwd/yp_passwd.c +++ b/usr.bin/passwd/yp_passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp_passwd.c,v 1.32 2009/10/27 23:59:41 deraadt Exp $ */ +/* $OpenBSD: yp_passwd.c,v 1.33 2014/11/20 14:53:15 tedu Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -189,8 +189,7 @@ yp_passwd(char *username) char * ypgetnewpasswd(struct passwd *pw, login_cap_t *lc, char **old_pass) { - static char buf[_PASSWORD_LEN+1]; - char salt[_PASSWORD_LEN]; + char buf[1024], hash[_PASSWORD_LEN]; sig_t saveint, savequit; int tries, pwd_tries; char *p; @@ -236,15 +235,17 @@ ypgetnewpasswd(struct passwd *pw, login_cap_t *lc, char **old_pass) break; (void)printf("Mismatch; try again, EOF to quit.\n"); } - if (!pwd_gensalt(salt, _PASSWORD_LEN, lc, 'y')) { - (void)printf("Couldn't generate salt.\n"); + + (void)signal(SIGINT, saveint); + (void)signal(SIGQUIT, savequit); + + if (crypt_newhash(buf, lc, hash, sizeof(hash)) == -1) { + (void)printf("Couldn't generate hash.\n"); pw_error(NULL, 0, 0); } - p = strdup(crypt(buf, salt)); + p = strdup(hash); if (p == NULL) pw_error(NULL, 1, 1); - (void)signal(SIGINT, saveint); - (void)signal(SIGQUIT, savequit); return (p); } |