MFH (r271256, r271617): avoid segfault if PAM_RHOST nor PAM_TTY are unset.
Approved by: re (gjb) PR: 83099
This commit is contained in:
parent
0c17d5e9e8
commit
2bc2377c66
@ -79,7 +79,14 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused,
|
|||||||
|
|
||||||
gethostname(hostname, sizeof hostname);
|
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",
|
PAM_LOG("Checking login.access for user %s on tty %s",
|
||||||
(const char *)user, (const char *)tty);
|
(const char *)user, (const char *)tty);
|
||||||
if (login_access(user, tty) != 0)
|
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",
|
PAM_VERBOSE_ERROR("%s is not allowed to log in on %s",
|
||||||
user, tty);
|
user, tty);
|
||||||
} else {
|
} else {
|
||||||
PAM_LOG("Checking login.access for user %s from host %s",
|
PAM_VERBOSE_ERROR("PAM_RHOST or PAM_TTY required");
|
||||||
(const char *)user, (const char *)rhost);
|
return (PAM_AUTHINFO_UNAVAIL);
|
||||||
if (login_access(user, rhost) != 0)
|
|
||||||
return (PAM_SUCCESS);
|
|
||||||
PAM_VERBOSE_ERROR("%s is not allowed to log in from %s",
|
|
||||||
user, rhost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (PAM_AUTH_ERR);
|
return (PAM_AUTH_ERR);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user