svn commit: r271767 - stable/9/lib/libpam/modules/pam_login_access

Dag-Erling Smørgrav des at FreeBSD.org
Thu Sep 18 14:31:18 UTC 2014


Author: des
Date: Thu Sep 18 14:31:18 2014
New Revision: 271767
URL: http://svnweb.freebsd.org/changeset/base/271767

Log:
  MFH (r271256, r271617): avoid segfault if PAM_RHOST nor PAM_TTY are unset.
  
  PR:		83099

Modified:
  stable/9/lib/libpam/modules/pam_login_access/pam_login_access.c
Directory Properties:
  stable/9/lib/libpam/   (props changed)

Modified: stable/9/lib/libpam/modules/pam_login_access/pam_login_access.c
==============================================================================
--- stable/9/lib/libpam/modules/pam_login_access/pam_login_access.c	Thu Sep 18 14:27:37 2014	(r271766)
+++ stable/9/lib/libpam/modules/pam_login_access/pam_login_access.c	Thu Sep 18 14:31:18 2014	(r271767)
@@ -79,7 +79,14 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int
 
 	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
 		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);


More information about the svn-src-stable-9 mailing list