From 4f66d395af37e9419d1a3ae821690c8569c0f87b Mon Sep 17 00:00:00 2001 From: tedu Date: Fri, 24 Jun 2016 17:22:56 +0000 Subject: [PATCH] use crypt_checkpass to simplify password checking logic. --- usr.sbin/pppd/auth.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c index 6bbe5d7eff5..43773e299be 100644 --- a/usr.sbin/pppd/auth.c +++ b/usr.sbin/pppd/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.37 2016/05/17 20:51:56 tedu Exp $ */ +/* $OpenBSD: auth.c,v 1.38 2016/06/24 17:22:56 tedu Exp $ */ /* * auth.c - PPP authentication and phase control. @@ -741,25 +741,12 @@ plogin(user, passwd, msg, msglen) char **msg; int *msglen; { - - struct passwd *pw; char *tty; - pw = getpwnam_shadow(user); - endpwent(); - if (pw == NULL) { - return (UPAP_AUTHNAK); - } - - - /* - * If no passwd, don't let them login. - */ - if (pw->pw_passwd == NULL || *pw->pw_passwd == '\0' - || strcmp(crypt(passwd, pw->pw_passwd), pw->pw_passwd) != 0) - return (UPAP_AUTHNAK); + if (crypt_checkpass(passwd, pw ? pw->pw_passwd : NULL)) + return UPAP_AUTHNAK; /* * Write a wtmp entry for this user. -- 2.20.1