diff options
author | des <des@FreeBSD.org> | 2014-09-18 14:27:37 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2014-09-18 14:27:37 +0000 |
commit | 2bc2377c6618fb65f929f92715f7b128fe6e9a27 (patch) | |
tree | 66a4b44bd100671d3852be72e7c63233c17756ff /lib | |
parent | 0c17d5e9e880e762faece188f13ea647804fa9e2 (diff) | |
download | FreeBSD-src-2bc2377c6618fb65f929f92715f7b128fe6e9a27.zip FreeBSD-src-2bc2377c6618fb65f929f92715f7b128fe6e9a27.tar.gz |
MFH (r271256, r271617): avoid segfault if PAM_RHOST nor PAM_TTY are unset.
Approved by: re (gjb)
PR: 83099
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libpam/modules/pam_login_access/pam_login_access.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libpam/modules/pam_login_access/pam_login_access.c b/lib/libpam/modules/pam_login_access/pam_login_access.c index 945d5eb..a29eb7d 100644 --- a/lib/libpam/modules/pam_login_access/pam_login_access.c +++ b/lib/libpam/modules/pam_login_access/pam_login_access.c @@ -79,7 +79,14 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, gethostname(hostname, sizeof hostname); - if (rhost == NULL || *(const char *)rhost == '\0') { + if (rhost != NULL && *(const char *)rhost != '\0') { + PAM_LOG("Checking login.access for user %s from host %s", + (const char *)user, (const char *)rhost); + if (login_access(user, rhost) != 0) + return (PAM_SUCCESS); + PAM_VERBOSE_ERROR("%s is not allowed to log in from %s", + user, rhost); + } else if (tty != NULL && *(const char *)tty != '\0') { PAM_LOG("Checking login.access for user %s on tty %s", (const char *)user, (const char *)tty); if (login_access(user, tty) != 0) @@ -87,12 +94,8 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, PAM_VERBOSE_ERROR("%s is not allowed to log in on %s", user, tty); } else { - PAM_LOG("Checking login.access for user %s from host %s", - (const char *)user, (const char *)rhost); - if (login_access(user, rhost) != 0) - return (PAM_SUCCESS); - PAM_VERBOSE_ERROR("%s is not allowed to log in from %s", - user, rhost); + PAM_VERBOSE_ERROR("PAM_RHOST or PAM_TTY required"); + return (PAM_AUTHINFO_UNAVAIL); } return (PAM_AUTH_ERR); |