summaryrefslogtreecommitdiff
path: root/modules/pam_shells
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pam_shells')
-rw-r--r--modules/pam_shells/pam_shells.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/pam_shells/pam_shells.c b/modules/pam_shells/pam_shells.c
index 37d740dc..c9e2ed6c 100644
--- a/modules/pam_shells/pam_shells.c
+++ b/modules/pam_shells/pam_shells.c
@@ -59,11 +59,16 @@ static int perform_check(pam_handle_t *pamh, int flags)
return PAM_SERVICE_ERR;
}
- if (!userName || (strlen(userName) <= 0)) {
+ if (!userName || (userName[0] == '\0')) {
+
/* Don't let them use a NULL username... */
- pam_get_user(pamh,&userName,NULL);
+ retval = pam_get_user(pamh,&userName,NULL);
if (retval != PAM_SUCCESS)
return PAM_SERVICE_ERR;
+
+ /* It could still be NULL the second time. */
+ if (!userName || (userName[0] == '\0'))
+ return PAM_SERVICE_ERR;
}
pw = getpwnam(userName);
@@ -93,7 +98,7 @@ static int perform_check(pam_handle_t *pamh, int flags)
retval = 1;
- while((fgets(shellFileLine, 255, shellFile) != NULL) && retval) {
+ while(retval && (fgets(shellFileLine, 255, shellFile) != NULL)) {
if (shellFileLine[strlen(shellFileLine) - 1] == '\n')
shellFileLine[strlen(shellFileLine) - 1] = '\0';
retval = strcmp(shellFileLine, userShell);