From 97c26c1924b076ef23ebe4381558e8aa025712b2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:54:37 +0200 Subject: Adding upstream version 1:4.13+dfsg1. Signed-off-by: Daniel Baumann --- libmisc/pwdcheck.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 libmisc/pwdcheck.c (limited to 'libmisc/pwdcheck.c') diff --git a/libmisc/pwdcheck.c b/libmisc/pwdcheck.c new file mode 100644 index 0000000..15fc3a3 --- /dev/null +++ b/libmisc/pwdcheck.c @@ -0,0 +1,38 @@ +/* + * SPDX-FileCopyrightText: 2000 - 2005, Tomasz Kłoczko + * SPDX-FileCopyrightText: 2007 - 2008, Nicolas François + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#ident "$Id$" + +#ifndef USE_PAM + +#include +#include +#include "prototypes.h" +#include "defines.h" +#include "pwauth.h" +#include "shadowlog.h" + +void passwd_check (const char *user, const char *passwd, unused const char *progname) +{ + struct spwd *sp; + + sp = getspnam (user); /* !USE_PAM, no need for xgetspnam */ + if (NULL != sp) { + passwd = sp->sp_pwdp; + } + if (pw_auth (passwd, user, PW_LOGIN, (char *) 0) != 0) { + SYSLOG ((LOG_WARN, "incorrect password for `%s'", user)); + (void) sleep (1); + fprintf (log_get_logfd(), _("Incorrect password for %s.\n"), user); + exit (EXIT_FAILURE); + } +} +#else /* USE_PAM */ +extern int errno; /* warning: ANSI C forbids an empty source file */ +#endif /* USE_PAM */ -- cgit v1.2.3