diff options
author | Steve Langasek <vorlon@debian.org> | 2003-07-13 06:43:04 +0000 |
---|---|---|
committer | Steve Langasek <vorlon@debian.org> | 2003-07-13 06:43:04 +0000 |
commit | eaffa5288f918a542c5322b79975793efc1b3a10 (patch) | |
tree | 8e8912378ecf6362fd925e991e2e0a74ada0ce7a /modules | |
parent | a6562ebb2728c6493f3bdd6e2d5505dd9f962fe3 (diff) | |
download | pam-eaffa5288f918a542c5322b79975793efc1b3a10.tar.gz pam-eaffa5288f918a542c5322b79975793efc1b3a10.tar.bz2 pam-eaffa5288f918a542c5322b79975793efc1b3a10.zip |
Relevant BUGIDs: patch 476984
Purpose of commit: bugfix
Commit summary:
---------------
Patch from Nalin Dahyabhai: always compare tty names without the "/dev",
working around inconsistent handling among apps.
Also, make minor adjustments for robustness (handle DOS EOL chars, and
don't hardcode array sizes).
Diffstat (limited to 'modules')
-rw-r--r-- | modules/pam_listfile/pam_listfile.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/modules/pam_listfile/pam_listfile.c b/modules/pam_listfile/pam_listfile.c index 527d036f..bc677be3 100644 --- a/modules/pam_listfile/pam_listfile.c +++ b/modules/pam_listfile/pam_listfile.c @@ -280,8 +280,14 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **ar if (retval != PAM_SUCCESS) return PAM_SERVICE_ERR; } + if((citem == PAM_TTY) && citemp) { + /* Normalize the TTY name. */ + if(strncmp(citemp, "/dev/", 5) == 0) { + citemp += 5; + } + } - if(!citemp || (strlen(citemp) <= 0)) { + if(!citemp || (strlen(citemp) == 0)) { /* The item was NULL - we are sure not to match */ return sense?PAM_SUCCESS:PAM_AUTH_ERR; } @@ -370,8 +376,10 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **ar assert(PAM_AUTH_ERR != 0); #endif if(extitem == EI_GROUP) { - while((fgets(aline,255,inf) != NULL) + while((fgets(aline,sizeof(aline),inf) != NULL) && retval) { + if(strlen(aline) == 0) + continue; if(aline[strlen(aline) - 1] == '\n') aline[strlen(aline) - 1] = '\0'; for(i=0;itemlist[i];) @@ -382,11 +390,21 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **ar for(i=0;itemlist[i];) free(itemlist[i++]); } else { - while((fgets(aline,255,inf) != NULL) + while((fgets(aline,sizeof(aline),inf) != NULL) && retval) { + char *a = aline; + if(strlen(aline) == 0) + continue; if(aline[strlen(aline) - 1] == '\n') aline[strlen(aline) - 1] = '\0'; - retval = strcmp(aline,citemp); + if(strlen(aline) == 0) + continue; + if(aline[strlen(aline) - 1] == '\r') + aline[strlen(aline) - 1] = '\0'; + if(citem == PAM_TTY) + if(strncmp(a, "/dev/", 5) == 0) + a += 5; + retval = strcmp(a,citemp); } } fclose(inf); |