summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Mraz <tmraz@fedoraproject.org>2020-02-24 18:53:46 +0100
committerTomas Mraz <tmraz@fedoraproject.org>2020-02-24 18:53:46 +0100
commit28189d80695e320c4bf014232e279671182b502e (patch)
tree677fc62ad803fca40b152a25b6ac301c3115fd76
parentf83fb5f25263356391d71da595def409e8dd90f7 (diff)
pam_shells: Recognize /bin/sh as the default shell.
If the shell is empty in /etc/passwd entry it means /bin/sh. * modules/pam_shells/pam_shells.c (perform_check): Use /bin/sh as default shell.
-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);