pinnwand

bpaste has migrated platforms. We now support self removal of pastes and will automatically import pastes from our old software for the following 2 months (that is, until the end of november 2014).

If you have any pastes you'd like to preserve please visit their URLs and they will be automatically imported with no expiry.

This paste never expires. Pasted by import. View raw.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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..b365aee 100644
--- a/lib/libpam/modules/pam_login_access/pam_login_access.c
+++ b/lib/libpam/modules/pam_login_access/pam_login_access.c
@@ -79,20 +79,23 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused,
 
 	gethostname(hostname, sizeof hostname);
 
-	if (rhost == NULL || *(const char *)rhost == '\0') {
+	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)
 			return (PAM_SUCCESS);
 		PAM_VERBOSE_ERROR("%s is not allowed to log in on %s",
 		    user, tty);
-	} else {
+	} else 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 {
+		PAM_VERBOSE_ERROR("neither host nor tty is set");
+		return (PAM_SUCCESS);
 	}
 
 	return (PAM_AUTH_ERR);