Treat an empty PAM_RHOST the same as a NULL one.
PR: bin/51508
This commit is contained in:
parent
8ba20a48bd
commit
ccd703cfe4
lib/libpam/modules
pam_lastlog
pam_login_access
pam_opieaccess
pam_unix
@ -129,7 +129,7 @@ pam_sm_open_session(pam_handle_t *pamh, int flags,
|
|||||||
|
|
||||||
/* note: does not need to be NUL-terminated */
|
/* note: does not need to be NUL-terminated */
|
||||||
strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
|
strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
|
||||||
if (rhost != NULL)
|
if (rhost != NULL && *rhost != '\0')
|
||||||
/* note: does not need to be NUL-terminated */
|
/* note: does not need to be NUL-terminated */
|
||||||
strncpy(ll.ll_host, rhost, sizeof(ll.ll_host));
|
strncpy(ll.ll_host, rhost, sizeof(ll.ll_host));
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ pam_sm_open_session(pam_handle_t *pamh, int flags,
|
|||||||
utmp.ut_time = time(NULL);
|
utmp.ut_time = time(NULL);
|
||||||
/* note: does not need to be NUL-terminated */
|
/* note: does not need to be NUL-terminated */
|
||||||
strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
|
strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
|
||||||
if (rhost != NULL)
|
if (rhost != NULL && *rhost != '\0')
|
||||||
strncpy(utmp.ut_host, rhost, sizeof(utmp.ut_host));
|
strncpy(utmp.ut_host, rhost, sizeof(utmp.ut_host));
|
||||||
(void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
|
(void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
|
||||||
login(&utmp);
|
login(&utmp);
|
||||||
|
@ -79,7 +79,7 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused,
|
|||||||
|
|
||||||
gethostname(hostname, sizeof hostname);
|
gethostname(hostname, sizeof hostname);
|
||||||
|
|
||||||
if (rhost == NULL) {
|
if (rhost == NULL || *rhost == '\0') {
|
||||||
PAM_LOG("Checking login.access for user %s on tty %s",
|
PAM_LOG("Checking login.access for user %s on tty %s",
|
||||||
user, tty);
|
user, tty);
|
||||||
if (login_access(user, tty) != 0)
|
if (login_access(user, tty) != 0)
|
||||||
|
@ -73,7 +73,7 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
|
|||||||
r = pam_get_item(pamh, PAM_RHOST, (const void **)&rhost);
|
r = pam_get_item(pamh, PAM_RHOST, (const void **)&rhost);
|
||||||
if (r != PAM_SUCCESS)
|
if (r != PAM_SUCCESS)
|
||||||
return (r);
|
return (r);
|
||||||
if (rhost == NULL)
|
if (rhost == NULL || *rhost == '\0')
|
||||||
rhost = openpam_get_option(pamh, "allow_local") ?
|
rhost = openpam_get_option(pamh, "allow_local") ?
|
||||||
"" : "localhost";
|
"" : "localhost";
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused,
|
|||||||
* PAM_NEW_AUTHTOK_REQD.
|
* PAM_NEW_AUTHTOK_REQD.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (rhost) {
|
if (rhost && *rhost) {
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
if (getaddrinfo(rhost, NULL, &hints, &res) == 0) {
|
if (getaddrinfo(rhost, NULL, &hints, &res) == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user