summaryrefslogtreecommitdiff
path: root/modules/pam_shells/pam_shells.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pam_shells/pam_shells.c')
-rw-r--r--modules/pam_shells/pam_shells.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/pam_shells/pam_shells.c b/modules/pam_shells/pam_shells.c
index bfe7f116..ae67a423 100644
--- a/modules/pam_shells/pam_shells.c
+++ b/modules/pam_shells/pam_shells.c
@@ -2,6 +2,8 @@
#define SHELL_FILE "/etc/shells"
+#define DEFAULT_SHELL "/bin/sh"
+
/*
* by Erik Troan <ewt@redhat.com>, Red Hat Software.
* August 5, 1996.
@@ -37,7 +39,7 @@ static int perform_check(pam_handle_t *pamh)
{
int retval = PAM_AUTH_ERR;
const char *userName;
- char *userShell;
+ const char *userShell;
char shellFileLine[256];
struct stat sb;
struct passwd * pw;
@@ -61,10 +63,12 @@ static int perform_check(pam_handle_t *pamh)
}
pw = pam_modutil_getpwnam(pamh, userName);
- if (!pw) {
+ if (pw == NULL || pw->pw_shell == NULL) {
return PAM_AUTH_ERR; /* user doesn't exist */
}
userShell = pw->pw_shell;
+ if (userShell[0] == '\0')
+ userShell = DEFAULT_SHELL;
if (stat(SHELL_FILE,&sb)) {
pam_syslog(pamh, LOG_ERR, "Cannot stat %s: %m", SHELL_FILE);