From 133dfdf24686821d5c716a711c26ee141bd96843 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Mon, 24 Nov 2003 14:46:06 +0000 Subject: Relevant BUGIDs: Purpose of commit: bugfix for pam_securetty Commit summary: --------------- Move the first usage of uttyname ofter the initialisation (Bug # 848316). This move was forgetten with the last changes. --- modules/pam_securetty/pam_securetty.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/pam_securetty/pam_securetty.c b/modules/pam_securetty/pam_securetty.c index a5ae0df8..274b3b74 100644 --- a/modules/pam_securetty/pam_securetty.c +++ b/modules/pam_securetty/pam_securetty.c @@ -97,11 +97,6 @@ static int securetty_perform_check(pam_handle_t *pamh, int flags, int ctrl, return (retval == PAM_CONV_AGAIN ? PAM_INCOMPLETE:PAM_SERVICE_ERR); } - /* The PAM_TTY item may be prefixed with "/dev/" - skip that */ - if (strncmp(TTY_PREFIX, uttyname, sizeof(TTY_PREFIX)-1) == 0) { - uttyname += sizeof(TTY_PREFIX)-1; - } - user_pwd = getpwnam(username); if (user_pwd == NULL) { return PAM_IGNORE; @@ -119,6 +114,11 @@ static int securetty_perform_check(pam_handle_t *pamh, int flags, int ctrl, return PAM_SERVICE_ERR; } + /* The PAM_TTY item may be prefixed with "/dev/" - skip that */ + if (strncmp(TTY_PREFIX, uttyname, sizeof(TTY_PREFIX)-1) == 0) { + uttyname += sizeof(TTY_PREFIX)-1; + } + if (stat(SECURETTY_FILE, &ttyfileinfo)) { _pam_log(LOG_NOTICE, "Couldn't open " SECURETTY_FILE); return PAM_SUCCESS; /* for compatibility with old securetty handling, @@ -146,10 +146,10 @@ static int securetty_perform_check(pam_handle_t *pamh, int flags, int ctrl, } else { ptname[0] = '\0'; } - + retval = 1; - while ((fgets(ttyfileline, sizeof(ttyfileline)-1, ttyfile) != NULL) + while ((fgets(ttyfileline, sizeof(ttyfileline)-1, ttyfile) != NULL) && retval) { if (ttyfileline[strlen(ttyfileline) - 1] == '\n') ttyfileline[strlen(ttyfileline) - 1] = '\0'; -- cgit v1.2.3