From 5b73a0492df621df21a2d8b611d1918b0bc0cd9e Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sat, 20 Sep 2008 14:17:20 +0000 Subject: [PATCH] * src/login.c: Do not mix USE_PAM and !USE_PAM code. --- ChangeLog | 4 ++++ src/login.c | 26 +++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15223d9c..4fff43ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-09-20 Nicolas François + + * src/login.c: Do not mix USE_PAM and !USE_PAM code. + 2008-09-20 Nicolas François * src/login.c: Use failent_user to log to audit. username is the diff --git a/src/login.c b/src/login.c index e82ead10..99a05513 100644 --- a/src/login.c +++ b/src/login.c @@ -811,6 +811,19 @@ int main (int argc, char **argv) hushed (&pwent) ? PAM_SILENT : 0); PAM_FAIL_CHECK; + pwd = xgetpwnam (pam_user); + if (NULL == pwd) { + pwent.pw_name = pam_user; + strcpy (temp_pw, "!"); + pwent.pw_passwd = temp_pw; + pwent.pw_shell = temp_shell; + + preauth_flag = false; + failed = true; + } else { + pwent = *pwd; + } + #else /* ! USE_PAM */ while (true) { /* repeatedly get login/password pairs */ failed = false; /* haven't failed authentication yet */ @@ -824,17 +837,10 @@ int main (int argc, char **argv) sizeof username); continue; } -#endif /* ! USE_PAM */ -#ifdef USE_PAM - pwd = xgetpwnam (pam_user); - if (NULL == pwd) { - pwent.pw_name = pam_user; -#else pwd = xgetpwnam (username); if (NULL == pwd) { pwent.pw_name = username; -#endif strcpy (temp_pw, "!"); pwent.pw_passwd = temp_pw; pwent.pw_shell = temp_shell; @@ -844,7 +850,7 @@ int main (int argc, char **argv) } else { pwent = *pwd; } -#ifndef USE_PAM + spwd = NULL; if ( (NULL != pwd) && (strcmp (pwd->pw_passwd, SHADOW_PASSWD_STRING) == 0)) { @@ -995,9 +1001,11 @@ int main (int argc, char **argv) closelog (); exit (1); } - } /* while (1) */ + } /* while (true) */ #endif /* ! USE_PAM */ + alarm (0); /* turn off alarm clock */ + #ifndef USE_PAM /* PAM does this */ /* * porttime checks moved here, after the user has been