Blame SOURCES/pam-1.1.8-access-update.patch

c22a38
diff -up Linux-PAM-1.1.8/modules/pam_access/access.conf.access-update Linux-PAM-1.1.8/modules/pam_access/access.conf
c22a38
--- Linux-PAM-1.1.8/modules/pam_access/access.conf.access-update	2013-06-18 16:11:21.000000000 +0200
c22a38
+++ Linux-PAM-1.1.8/modules/pam_access/access.conf	2017-09-08 14:06:16.420102221 +0200
c22a38
@@ -18,7 +18,7 @@
c22a38
 # pam_access with X applications that provide PAM_TTY values that are
c22a38
 # the display variable like "host:0".]
c22a38
 #
c22a38
-# 	permission : users : origins
c22a38
+# 	permission:users:origins
c22a38
 #
c22a38
 # The first field should be a "+" (access granted) or "-" (access denied)
c22a38
 # character.
c22a38
@@ -79,44 +79,44 @@
c22a38
 ##############################################################################
c22a38
 #
c22a38
 # User "root" should be allowed to get access via cron .. tty5 tty6.
c22a38
-#+ : root : cron crond :0 tty1 tty2 tty3 tty4 tty5 tty6
c22a38
+#+:root:cron crond :0 tty1 tty2 tty3 tty4 tty5 tty6
c22a38
 #
c22a38
 # User "root" should be allowed to get access from hosts with ip addresses.
c22a38
-#+ : root : 192.168.200.1 192.168.200.4 192.168.200.9
c22a38
-#+ : root : 127.0.0.1
c22a38
+#+:root:192.168.200.1 192.168.200.4 192.168.200.9
c22a38
+#+:root:127.0.0.1
c22a38
 #
c22a38
 # User "root" should get access from network 192.168.201.
c22a38
 # This term will be evaluated by string matching.
c22a38
 # comment: It might be better to use network/netmask instead.
c22a38
 #          The same is 192.168.201.0/24 or 192.168.201.0/255.255.255.0
c22a38
-#+ : root : 192.168.201.
c22a38
+#+:root:192.168.201.
c22a38
 #
c22a38
 # User "root" should be able to have access from domain.
c22a38
 # Uses string matching also.
c22a38
-#+ : root : .foo.bar.org
c22a38
+#+:root:.foo.bar.org
c22a38
 #
c22a38
 # User "root" should be denied to get access from all other sources.
c22a38
-#- : root : ALL
c22a38
+#-:root:ALL
c22a38
 #
c22a38
 # User "foo" and members of netgroup "nis_group" should be
c22a38
 # allowed to get access from all sources.
c22a38
 # This will only work if netgroup service is available.
c22a38
-#+ : @nis_group foo : ALL
c22a38
+#+:@nis_group foo:ALL
c22a38
 #
c22a38
 # User "john" should get access from ipv4 net/mask
c22a38
-#+ : john : 127.0.0.0/24
c22a38
+#+:john:127.0.0.0/24
c22a38
 #
c22a38
 # User "john" should get access from ipv4 as ipv6 net/mask
c22a38
-#+ : john : ::ffff:127.0.0.0/127
c22a38
+#+:john:::ffff:127.0.0.0/127
c22a38
 #
c22a38
 # User "john" should get access from ipv6 host address
c22a38
-#+ : john : 2001:4ca0:0:101::1
c22a38
+#+:john:2001:4ca0:0:101::1
c22a38
 #
c22a38
 # User "john" should get access from ipv6 host address (same as above)
c22a38
-#+ : john : 2001:4ca0:0:101:0:0:0:1
c22a38
+#+:john:2001:4ca0:0:101:0:0:0:1
c22a38
 #
c22a38
 # User "john" should get access from ipv6 net/mask
c22a38
-#+ : john : 2001:4ca0:0:101::/64
c22a38
+#+:john:2001:4ca0:0:101::/64
c22a38
 #
c22a38
 # All other users should be denied to get access from all sources.
c22a38
-#- : ALL : ALL
c22a38
+#-:ALL:ALL
c22a38
diff -up Linux-PAM-1.1.8/modules/pam_access/access.conf.5.xml.access-update Linux-PAM-1.1.8/modules/pam_access/access.conf.5.xml
c22a38
--- Linux-PAM-1.1.8/modules/pam_access/access.conf.5.xml.access-update	2013-06-18 16:11:21.000000000 +0200
c22a38
+++ Linux-PAM-1.1.8/modules/pam_access/access.conf.5.xml	2017-09-08 14:05:41.126320653 +0200
c22a38
@@ -21,8 +21,12 @@
c22a38
     <para>
c22a38
       The <filename>/etc/security/access.conf</filename> file specifies
c22a38
       (<replaceable>user/group</replaceable>, <replaceable>host</replaceable>),
c22a38
-      (<replaceable>user/group</replaceable>, <replaceable>network/netmask</replaceable>) or
c22a38
-      (<replaceable>user/group</replaceable>, <replaceable>tty</replaceable>)
c22a38
+      (<replaceable>user/group</replaceable>, <replaceable>network/netmask</replaceable>),
c22a38
+      (<replaceable>user/group</replaceable>, <replaceable>tty</replaceable>),
c22a38
+      (<replaceable>user/group</replaceable>,
c22a38
+      <replaceable>X-$DISPLAY-value</replaceable>), or
c22a38
+      (<replaceable>user/group</replaceable>,
c22a38
+      <replaceable>pam-service-name</replaceable>)
c22a38
       combinations for which a login will be either accepted or refused.
c22a38
     </para>
c22a38
     <para>
c22a38
@@ -33,7 +37,14 @@
c22a38
       combination, or, in case of non-networked logins, the first entry
c22a38
       that matches the
c22a38
       (<replaceable>user/group</replaceable>, <replaceable>tty</replaceable>)
c22a38
-      combination.  The permissions field of that table entry determines
c22a38
+      combination, or in the case of non-networked logins without a
c22a38
+      tty, the first entry that matches the
c22a38
+      (<replaceable>user/group</replaceable>,
c22a38
+      <replaceable>X-$DISPLAY-value</replaceable>) or
c22a38
+      (<replaceable>user/group</replaceable>,
c22a38
+      <replaceable>pam-service-name/</replaceable>)
c22a38
+      combination.  The permissions field of that table entry
c22a38
+      determines
c22a38
       whether the login will be accepted or refused.
c22a38
    </para>
c22a38
 
c22a38
@@ -65,14 +76,27 @@
c22a38
     <para>
c22a38
       The third field, the <replaceable>origins</replaceable>
c22a38
       field, should be a list of one or more tty names (for non-networked
c22a38
-      logins), host names, domain names (begin with "."), host addresses,
c22a38
+      logins), X <varname>$DISPLAY</varname> values or PAM service
c22a38
+      names (for non-networked logins without a tty), host names,
c22a38
+      domain names (begin with "."), host addresses,
c22a38
       internet network numbers (end with "."), internet network addresses
c22a38
       with network mask (where network mask can be a decimal number or an
c22a38
       internet address also), <emphasis>ALL</emphasis> (which always matches)
c22a38
-      or <emphasis>LOCAL</emphasis>. <emphasis>LOCAL</emphasis>
c22a38
-      keyword matches if and only if the <emphasis>PAM_RHOST</emphasis> is
c22a38
-      not set and <origin> field is thus set from
c22a38
-      <emphasis>PAM_TTY</emphasis> or <emphasis>PAM_SERVICE</emphasis>".
c22a38
+      or <emphasis>LOCAL</emphasis>. The <emphasis>LOCAL</emphasis>
c22a38
+      keyword matches if and only if
c22a38
+      <citerefentry><refentrytitle>pam_get_item</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
c22a38
+      when called with an <parameter>item_type</parameter> of
c22a38
+      <emphasis>PAM_RHOST</emphasis>, returns NULL or an
c22a38
+      empty string (and therefore the
c22a38
+      <replaceable>origins</replaceable> field is compared against the
c22a38
+      return value of
c22a38
+      <citerefentry><refentrytitle>pam_get_item</refentrytitle><manvolnum>3</manvolnum></citerefentry>
c22a38
+      called with an <parameter>item_type</parameter> of
c22a38
+      <emphasis>PAM_TTY</emphasis> or, absent that,
c22a38
+      <emphasis>PAM_SERVICE</emphasis>).
c22a38
+    </para>
c22a38
+
c22a38
+    <para>
c22a38
       If supported by the system you can use
c22a38
       <emphasis>@netgroupname</emphasis> in host or user patterns. The
c22a38
       <emphasis>@@netgroupname</emphasis> syntax is supported in the user
c22a38
@@ -115,7 +139,7 @@
c22a38
       <emphasis>tty1</emphasis>, ..., <emphasis>tty5</emphasis>,
c22a38
       <emphasis>tty6</emphasis>.
c22a38
     </para>
c22a38
-    <para>+ : root : crond :0 tty1 tty2 tty3 tty4 tty5 tty6</para>
c22a38
+    <para>+:root:crond :0 tty1 tty2 tty3 tty4 tty5 tty6</para>
c22a38
 
c22a38
     <para>
c22a38
       User <emphasis>root</emphasis> should be allowed to get access from
c22a38
@@ -123,8 +147,8 @@
c22a38
       connection have to be a IPv4 one, a IPv6 connection from a host with
c22a38
       one of this IPv4 addresses does work, too.
c22a38
     </para>
c22a38
-    <para>+ : root : 192.168.200.1 192.168.200.4 192.168.200.9</para>
c22a38
-    <para>+ : root : 127.0.0.1</para>
c22a38
+    <para>+:root:192.168.200.1 192.168.200.4 192.168.200.9</para>
c22a38
+    <para>+:root:127.0.0.1</para>
c22a38
 
c22a38
     <para>
c22a38
       User <emphasis>root</emphasis> should get access from network
c22a38
@@ -134,44 +158,44 @@
c22a38
       <emphasis>192.168.201.0/24</emphasis> or
c22a38
       <emphasis>192.168.201.0/255.255.255.0</emphasis>.
c22a38
     </para>
c22a38
-    <para>+ : root : 192.168.201.</para>
c22a38
+    <para>+:root:192.168.201.</para>
c22a38
 
c22a38
     <para>
c22a38
       User <emphasis>root</emphasis> should be able to have access from hosts
c22a38
       <emphasis>foo1.bar.org</emphasis> and <emphasis>foo2.bar.org</emphasis>
c22a38
       (uses string matching also).
c22a38
     </para>
c22a38
-    <para>+ : root : foo1.bar.org foo2.bar.org</para>
c22a38
+    <para>+:root:foo1.bar.org foo2.bar.org</para>
c22a38
 
c22a38
     <para>
c22a38
       User <emphasis>root</emphasis> should be able to have access from
c22a38
       domain <emphasis>foo.bar.org</emphasis> (uses string matching also).
c22a38
     </para>
c22a38
-    <para>+ : root : .foo.bar.org</para>
c22a38
+    <para>+:root:.foo.bar.org</para>
c22a38
 
c22a38
     <para>
c22a38
       User <emphasis>root</emphasis> should be denied to get access
c22a38
       from all other sources.
c22a38
     </para>
c22a38
-    <para>- : root : ALL</para>
c22a38
+    <para>-:root:ALL</para>
c22a38
 
c22a38
     <para>
c22a38
       User <emphasis>foo</emphasis> and members of netgroup
c22a38
       <emphasis>admins</emphasis> should be allowed to get access
c22a38
       from all sources. This will only work if netgroup service is available.
c22a38
     </para>
c22a38
-    <para>+ : @admins foo : ALL</para>
c22a38
+    <para>+:@admins foo:ALL</para>
c22a38
 
c22a38
     <para>
c22a38
       User <emphasis>john</emphasis> and <emphasis>foo</emphasis>
c22a38
       should get access from IPv6 host address.
c22a38
     </para>
c22a38
-    <para>+ : john foo : 2001:db8:0:101::1</para>
c22a38
+    <para>+:john foo:2001:db8:0:101::1</para>
c22a38
 
c22a38
     <para>
c22a38
       User <emphasis>john</emphasis> should get access from IPv6 net/mask.
c22a38
     </para>
c22a38
-    <para>+ : john : 2001:db8:0:101::/64</para>
c22a38
+    <para>+:john:2001:db8:0:101::/64</para>
c22a38
 
c22a38
     <para>
c22a38
       Disallow console logins to all but the shutdown, sync and all
c22a38
@@ -182,10 +206,22 @@
c22a38
     <para>
c22a38
       All other users should be denied to get access from all sources.
c22a38
     </para>
c22a38
-    <para>- : ALL : ALL</para>
c22a38
+    <para>-:ALL:ALL</para>
c22a38
 
c22a38
   </refsect1>
c22a38
 
c22a38
+  <refsect1 id="access.conf-notes">
c22a38
+    <title>NOTES</title>
c22a38
+    <para>
c22a38
+      The default separators of list items in a field are space, ',', and tabulator
c22a38
+      characters. Thus conveniently if spaces are put at the beginning and the end of
c22a38
+      the fields they are ignored. However if the list separator is changed with the
c22a38
+      <emphasis>listsep</emphasis> option, the spaces will become part of the actual
c22a38
+      item and the line will be most probably ignored. For this reason, it is not
c22a38
+      recommended to put spaces around the ':' characters.
c22a38
+    </para>
c22a38
+  </refsect1>
c22a38
+
c22a38
   <refsect1 id="access.conf-see_also">
c22a38
     <title>SEE ALSO</title>
c22a38
     <para>
c22a38
diff -up Linux-PAM-1.1.8/modules/pam_access/Makefile.am.access-update Linux-PAM-1.1.8/modules/pam_access/Makefile.am
c22a38
--- Linux-PAM-1.1.8/modules/pam_access/Makefile.am.access-update	2013-06-18 16:11:21.000000000 +0200
c22a38
+++ Linux-PAM-1.1.8/modules/pam_access/Makefile.am	2017-09-08 14:10:47.223163175 +0200
c22a38
@@ -15,7 +15,8 @@ securelibdir = $(SECUREDIR)
c22a38
 secureconfdir = $(SCONFIGDIR)
c22a38
 
c22a38
 AM_CFLAGS = -I$(top_srcdir)/libpam/include -I$(top_srcdir)/libpamc/include \
c22a38
-	-DPAM_ACCESS_CONFIG=\"$(SCONFIGDIR)/access.conf\" $(NIS_CFLAGS)
c22a38
+	-DPAM_ACCESS_CONFIG=\"$(SCONFIGDIR)/access.conf\" \
c22a38
+	-DACCESS_CONF_GLOB=\"$(SCONFIGDIR)/access.d/*.conf\" $(NIS_CFLAGS)
c22a38
 AM_LDFLAGS =  -no-undefined -avoid-version -module
c22a38
 if HAVE_VERSIONING
c22a38
   AM_LDFLAGS += -Wl,--version-script=$(srcdir)/../modules.map
c22a38
diff -up Linux-PAM-1.1.8/modules/pam_access/pam_access.c.access-update Linux-PAM-1.1.8/modules/pam_access/pam_access.c
c22a38
--- Linux-PAM-1.1.8/modules/pam_access/pam_access.c.access-update	2013-06-18 16:11:21.000000000 +0200
c22a38
+++ Linux-PAM-1.1.8/modules/pam_access/pam_access.c	2017-09-08 14:03:45.620762824 +0200
c22a38
@@ -44,6 +44,7 @@
c22a38
 #include <arpa/inet.h>
c22a38
 #include <netdb.h>
c22a38
 #include <sys/socket.h>
c22a38
+#include <glob.h>
c22a38
 #ifdef HAVE_RPCSVC_YPCLNT_H
c22a38
 #include <rpcsvc/ypclnt.h>
c22a38
 #endif
c22a38
@@ -90,6 +91,7 @@
c22a38
 #define ALL             2
c22a38
 #define YES             1
c22a38
 #define NO              0
c22a38
+#define NOMATCH        -1
c22a38
 
c22a38
  /*
c22a38
   * A structure to bundle up all login-related information to keep the
c22a38
@@ -412,13 +414,17 @@ login_access (pam_handle_t *pamh, struct
c22a38
 	return NO;
c22a38
     }
c22a38
 #ifdef HAVE_LIBAUDIT
c22a38
-    if (!item->noaudit && line[0] == '-' && (match == YES || (match == ALL &&
c22a38
-	nonall_match == YES))) {
c22a38
+    if (!item->noaudit && (match == YES || (match == ALL &&
c22a38
+	nonall_match == YES)) && line[0] == '-') {
c22a38
 	pam_modutil_audit_write(pamh, AUDIT_ANOM_LOGIN_LOCATION,
c22a38
 	    "pam_access", 0);
c22a38
     }
c22a38
 #endif
c22a38
-    return (match == NO || (line[0] == '+'));
c22a38
+    if (match == NO)
c22a38
+	return NOMATCH;
c22a38
+    if (line[0] == '+')
c22a38
+	return YES;
c22a38
+    return NO;
c22a38
 }
c22a38
 
c22a38
 
c22a38
@@ -524,7 +530,9 @@ user_match (pam_handle_t *pamh, char *to
c22a38
     /* Try to split on a pattern (@*[^@]+)(@+.*) */
c22a38
     for (at = tok; *at == '@'; ++at);
c22a38
 
c22a38
-    if ((at = strchr(at, '@')) != NULL) {
c22a38
+    if (tok[0] == '(' && tok[strlen(tok) - 1] == ')') {
c22a38
+      return (group_match (pamh, tok, string, item->debug));
c22a38
+    } else if ((at = strchr(at, '@')) != NULL) {
c22a38
         /* split user@host pattern */
c22a38
 	if (item->hostname == NULL)
c22a38
 	    return NO;
c22a38
@@ -549,9 +557,7 @@ user_match (pam_handle_t *pamh, char *to
c22a38
 		hostname = item->hostname;
c22a38
 	}
c22a38
         return (netgroup_match (pamh, tok + 1, hostname, string, item->debug));
c22a38
-    } else if (tok[0] == '(' && tok[strlen(tok) - 1] == ')')
c22a38
-      return (group_match (pamh, tok, string, item->debug));
c22a38
-    else if ((rv=string_match (pamh, tok, string, item->debug)) != NO) /* ALL or exact match */
c22a38
+    } else if ((rv=string_match (pamh, tok, string, item->debug)) != NO) /* ALL or exact match */
c22a38
       return rv;
c22a38
     else if (item->only_new_group_syntax == NO &&
c22a38
 	     pam_modutil_user_in_group_nam_nam (pamh,
c22a38
@@ -573,7 +579,7 @@ group_match (pam_handle_t *pamh, const c
c22a38
 
c22a38
     if (debug)
c22a38
         pam_syslog (pamh, LOG_DEBUG,
c22a38
-		    "group_match: grp=%s, user=%s", grptok, usr);
c22a38
+		    "group_match: grp=%s, user=%s", tok, usr);
c22a38
 
c22a38
     if (strlen(tok) < 3)
c22a38
         return NO;
c22a38
@@ -808,6 +814,7 @@ pam_sm_authenticate (pam_handle_t *pamh,
c22a38
     const char *user=NULL;
c22a38
     const void *void_from=NULL;
c22a38
     const char *from;
c22a38
+    const char const *default_config = PAM_ACCESS_CONFIG;
c22a38
     struct passwd *user_pw;
c22a38
     char hostname[MAXHOSTNAMELEN + 1];
c22a38
     int rv;
c22a38
@@ -829,7 +836,7 @@ pam_sm_authenticate (pam_handle_t *pamh,
c22a38
      */
c22a38
     memset(&loginfo, '\0', sizeof(loginfo));
c22a38
     loginfo.user = user_pw;
c22a38
-    loginfo.config_file = PAM_ACCESS_CONFIG;
c22a38
+    loginfo.config_file = default_config;
c22a38
 
c22a38
     /* parse the argument list */
c22a38
 
c22a38
@@ -900,6 +907,26 @@ pam_sm_authenticate (pam_handle_t *pamh,
c22a38
 
c22a38
     rv = login_access(pamh, &loginfo);
c22a38
 
c22a38
+    if (rv == NOMATCH && loginfo.config_file == default_config) {
c22a38
+	glob_t globbuf;
c22a38
+	int i, glob_rv;
c22a38
+
c22a38
+	/* We do not manipulate locale as setlocale() is not
c22a38
+	 * thread safe. We could use uselocale() in future.
c22a38
+	 */
c22a38
+	glob_rv = glob(ACCESS_CONF_GLOB, GLOB_ERR, NULL, &globbuf);
c22a38
+	if (!glob_rv) {
c22a38
+	    /* Parse the *.conf files. */
c22a38
+	    for (i = 0; globbuf.gl_pathv[i] != NULL; i++) {
c22a38
+		loginfo.config_file = globbuf.gl_pathv[i];
c22a38
+		rv = login_access(pamh, &loginfo);
c22a38
+		if (rv != NOMATCH)
c22a38
+		    break;
c22a38
+	    }
c22a38
+	    globfree(&globbuf);
c22a38
+	}
c22a38
+    }
c22a38
+
c22a38
     if (loginfo.gai_rv == 0 && loginfo.res)
c22a38
 	freeaddrinfo(loginfo.res);
c22a38
 
c22a38
diff -up Linux-PAM-1.1.8/modules/pam_access/pam_access.8.xml.access-update Linux-PAM-1.1.8/modules/pam_access/pam_access.8.xml
c22a38
--- Linux-PAM-1.1.8/modules/pam_access/pam_access.8.xml.access-update	2013-06-18 16:11:21.000000000 +0200
c22a38
+++ Linux-PAM-1.1.8/modules/pam_access/pam_access.8.xml	2017-09-08 14:04:25.365642960 +0200
c22a38
@@ -50,16 +50,25 @@
c22a38
       The pam_access PAM module is mainly for access management.
c22a38
       It provides logdaemon style login access control based on login
c22a38
       names, host or domain names, internet addresses or network numbers,
c22a38
-      or on terminal line names in case of non-networked logins.
c22a38
+      or on terminal line names, X <varname>$DISPLAY</varname> values,
c22a38
+      or PAM service names in case of non-networked logins.
c22a38
     </para>
c22a38
     <para>
c22a38
       By default rules for access management are taken from config file
c22a38
       <filename>/etc/security/access.conf</filename> if you don't specify
c22a38
       another file.
c22a38
+      Then individual <filename>*.conf</filename> files from the
c22a38
+      <filename>/etc/security/access.d/</filename> directory are read.
c22a38
+      The files are parsed one after another in the order of the system locale.
c22a38
+      The effect of the individual files is the same as if all the files were
c22a38
+      concatenated together in the order of parsing. This means that once
c22a38
+      a pattern is matched in some file no further files are parsed.
c22a38
+      If a config file is explicitly specified with the <option>accessfile</option>
c22a38
+      option the files in the above directory are not parsed.
c22a38
     </para>
c22a38
     <para>
c22a38
       If Linux PAM is compiled with audit support the module will report
c22a38
-      when it denies access based on origin (host or tty).
c22a38
+      when it denies access based on origin (host, tty, etc.).
c22a38
     </para>
c22a38
   </refsect1>
c22a38