* src/login.c: Do not mix USE_PAM and !USE_PAM code.

This commit is contained in:
nekral-guest 2008-09-20 14:17:20 +00:00
parent 9fa519c983
commit 5b73a0492d
2 changed files with 21 additions and 9 deletions

View File

@ -1,3 +1,7 @@
2008-09-20 Nicolas François <nicolas.francois@centraliens.net>
* src/login.c: Do not mix USE_PAM and !USE_PAM code.
2008-09-20 Nicolas François <nicolas.francois@centraliens.net> 2008-09-20 Nicolas François <nicolas.francois@centraliens.net>
* src/login.c: Use failent_user to log to audit. username is the * src/login.c: Use failent_user to log to audit. username is the

View File

@ -811,6 +811,19 @@ int main (int argc, char **argv)
hushed (&pwent) ? PAM_SILENT : 0); hushed (&pwent) ? PAM_SILENT : 0);
PAM_FAIL_CHECK; 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 */ #else /* ! USE_PAM */
while (true) { /* repeatedly get login/password pairs */ while (true) { /* repeatedly get login/password pairs */
failed = false; /* haven't failed authentication yet */ failed = false; /* haven't failed authentication yet */
@ -824,17 +837,10 @@ int main (int argc, char **argv)
sizeof username); sizeof username);
continue; continue;
} }
#endif /* ! USE_PAM */
#ifdef USE_PAM
pwd = xgetpwnam (pam_user);
if (NULL == pwd) {
pwent.pw_name = pam_user;
#else
pwd = xgetpwnam (username); pwd = xgetpwnam (username);
if (NULL == pwd) { if (NULL == pwd) {
pwent.pw_name = username; pwent.pw_name = username;
#endif
strcpy (temp_pw, "!"); strcpy (temp_pw, "!");
pwent.pw_passwd = temp_pw; pwent.pw_passwd = temp_pw;
pwent.pw_shell = temp_shell; pwent.pw_shell = temp_shell;
@ -844,7 +850,7 @@ int main (int argc, char **argv)
} else { } else {
pwent = *pwd; pwent = *pwd;
} }
#ifndef USE_PAM
spwd = NULL; spwd = NULL;
if ( (NULL != pwd) if ( (NULL != pwd)
&& (strcmp (pwd->pw_passwd, SHADOW_PASSWD_STRING) == 0)) { && (strcmp (pwd->pw_passwd, SHADOW_PASSWD_STRING) == 0)) {
@ -995,9 +1001,11 @@ int main (int argc, char **argv)
closelog (); closelog ();
exit (1); exit (1);
} }
} /* while (1) */ } /* while (true) */
#endif /* ! USE_PAM */ #endif /* ! USE_PAM */
alarm (0); /* turn off alarm clock */ alarm (0); /* turn off alarm clock */
#ifndef USE_PAM /* PAM does this */ #ifndef USE_PAM /* PAM does this */
/* /*
* porttime checks moved here, after the user has been * porttime checks moved here, after the user has been