summaryrefslogtreecommitdiff
path: root/Linux-PAM/modules/pam_access
diff options
context:
space:
mode:
authorSteve Langasek <steve.langasek@ubuntu.com>2019-01-03 16:15:40 -0800
committerSteve Langasek <steve.langasek@ubuntu.com>2019-01-03 17:00:25 -0800
commit9727ff2a3fa0e94a42b34a579027bacf4146d571 (patch)
tree893f3d050906e7cb2284f97cf4577bb5e8ccbb60 /Linux-PAM/modules/pam_access
parent281e859131adad49301befbc50cfc5cd282c6937 (diff)
parentb2661a54ac276d20268dba45b4e025d58458241e (diff)
New upstream version 0.99.10.0
Diffstat (limited to 'Linux-PAM/modules/pam_access')
-rw-r--r--Linux-PAM/modules/pam_access/README7
-rw-r--r--Linux-PAM/modules/pam_access/access.conf.592
-rw-r--r--Linux-PAM/modules/pam_access/pam_access.865
-rw-r--r--Linux-PAM/modules/pam_access/pam_access.8.xml18
-rw-r--r--Linux-PAM/modules/pam_access/pam_access.c170
5 files changed, 205 insertions, 147 deletions
diff --git a/Linux-PAM/modules/pam_access/README b/Linux-PAM/modules/pam_access/README
index a3adcc8f..ec0d67e0 100644
--- a/Linux-PAM/modules/pam_access/README
+++ b/Linux-PAM/modules/pam_access/README
@@ -12,6 +12,9 @@ of non-networked logins.
By default rules for access management are taken from config file /etc/security
/access.conf if you don't specify another file.
+If Linux PAM is compiled with audit support the module will report when it
+denies access based on origin (host or tty).
+
OPTIONS
accessfile=/path/to/access.conf
@@ -24,6 +27,10 @@ debug
A lot of debug informations are printed with syslog(3).
+noaudit
+
+ Do not report logins from disallowed hosts and ttys to the audit subsystem.
+
fieldsep=separators
This option modifies the field separator character that pam_access will
diff --git a/Linux-PAM/modules/pam_access/access.conf.5 b/Linux-PAM/modules/pam_access/access.conf.5
index fcd33bb4..9b8fb70b 100644
--- a/Linux-PAM/modules/pam_access/access.conf.5
+++ b/Linux-PAM/modules/pam_access/access.conf.5
@@ -1,32 +1,32 @@
.\" Title: access.conf
.\" Author:
-.\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
-.\" Date: 06/22/2007
-.\" Manual: Linux\-PAM Manual
-.\" Source: Linux\-PAM Manual
+.\" Generator: DocBook XSL Stylesheets v1.73.1 <http://docbook.sf.net/>
+.\" Date: 01/08/2008
+.\" Manual: Linux-PAM Manual
+.\" Source: Linux-PAM Manual
.\"
-.TH "ACCESS.CONF" "5" "06/22/2007" "Linux\-PAM Manual" "Linux\-PAM Manual"
+.TH "ACCESS\.CONF" "5" "01/08/2008" "Linux-PAM Manual" "Linux\-PAM Manual"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
-access.conf \- the login access control table file
+access.conf - the login access control table file
.SH "DESCRIPTION"
.PP
The
-\fI/etc/security/access.conf\fR
+\fI/etc/security/access\.conf\fR
file specifies (\fIuser/group\fR,
\fIhost\fR), (\fIuser/group\fR,
\fInetwork/netmask\fR) or (\fIuser/group\fR,
-\fItty\fR) combinations for which a login will be either accepted or refused.
+\fItty\fR) combinations for which a login will be either accepted or refused\.
.PP
When someone logs in, the file
-\fIaccess.conf\fR
+\fIaccess\.conf\fR
is scanned for the first entry that matches the (\fIuser/group\fR,
\fIhost\fR) or (\fIuser/group\fR,
\fInetwork/netmask\fR) combination, or, in case of non\-networked logins, the first entry that matches the (\fIuser/group\fR,
-\fItty\fR) combination. The permissions field of that table entry determines whether the login will be accepted or refused.
+\fItty\fR) combination\. The permissions field of that table entry determines whether the login will be accepted or refused\.
.PP
Each line of the login access control table has three fields separated by a ":" character (colon):
.PP
@@ -35,92 +35,92 @@ Each line of the login access control table has three fields separated by a ":"
.PP
The first field, the
\fIpermission\fR
-field, can be either a "\fI+\fR" character (plus) for access granted or a "\fI\-\fR" character (minus) for access denied.
+field, can be either a "\fI+\fR" character (plus) for access granted or a "\fI\-\fR" character (minus) for access denied\.
.PP
The second field, the
\fIusers\fR/\fIgroup\fR
field, should be a list of one or more login names, group names, or
\fIALL\fR
-(which always matches). To differentiate user entries from group entries, group entries should be written with brackets, e.g.
-\fI(group)\fR.
+(which always matches)\. To differentiate user entries from group entries, group entries should be written with brackets, e\.g\.
+\fI(group)\fR\.
.PP
The third field, the
\fIorigins\fR
-field, should be a list of one or more tty names (for non\-networked logins), host names, domain names (begin with "."), host addresses, internet network numbers (end with "."), internet network addresses with network mask (where network mask can be a decimal number or an internet address also),
+field, should be a list of one or more tty names (for non\-networked logins), host names, domain names (begin with "\."), host addresses, internet network numbers (end with "\."), internet network addresses with network mask (where network mask can be a decimal number or an internet address also),
\fIALL\fR
(which always matches) or
\fILOCAL\fR
-(which matches any string that does not contain a "." character). If supported by the system you can use
+(which matches any string that does not contain a "\." character)\. If supported by the system you can use
\fI@netgroupname\fR
-in host or user patterns.
+in host or user patterns\.
.PP
The
\fIEXCEPT\fR
-operator makes it possible to write very compact rules.
+operator makes it possible to write very compact rules\.
.PP
If the
\fBnodefgroup\fR
-is not set, the group file is searched when a name does not match that of the logged\-in user. Only groups are matched in which users are explicitly listed. However the PAM module does not look at the primary group id of a user.
+is not set, the group file is searched when a name does not match that of the logged\-in user\. Only groups are matched in which users are explicitly listed\. However the PAM module does not look at the primary group id of a user\.
.PP
-The "\fI#\fR" character at start of line (no space at front) can be used to mark this line as a comment line.
+The "\fI#\fR" character at start of line (no space at front) can be used to mark this line as a comment line\.
.SH "EXAMPLES"
.PP
These are some example lines which might be specified in
-\fI/etc/security/access.conf\fR.
+\fI/etc/security/access\.conf\fR\.
.PP
User
\fIroot\fR
should be allowed to get access via
\fIcron\fR, X11 terminal
\fI:0\fR,
-\fItty1\fR, ...,
+\fItty1\fR, \.\.\.,
\fItty5\fR,
-\fItty6\fR.
+\fItty6\fR\.
.PP
+ : root : crond :0 tty1 tty2 tty3 tty4 tty5 tty6
.PP
User
\fIroot\fR
-should be allowed to get access from hosts which own the IPv4 addresses. This does not mean that the connection have to be a IPv4 one, a IPv6 connection from a host with one of this IPv4 addresses does work, too.
+should be allowed to get access from hosts which own the IPv4 addresses\. This does not mean that the connection have to be a IPv4 one, a IPv6 connection from a host with one of this IPv4 addresses does work, too\.
.PP
-+ : root : 192.168.200.1 192.168.200.4 192.168.200.9
++ : root : 192\.168\.200\.1 192\.168\.200\.4 192\.168\.200\.9
.PP
-+ : root : 127.0.0.1
++ : root : 127\.0\.0\.1
.PP
User
\fIroot\fR
should get access from network
-192.168.201.
-where the term will be evaluated by string matching. But it might be better to use network/netmask instead. The same meaning of
-192.168.201.
+192\.168\.201\.
+where the term will be evaluated by string matching\. But it might be better to use network/netmask instead\. The same meaning of
+192\.168\.201\.
is
-\fI192.168.201.0/24\fR
+\fI192\.168\.201\.0/24\fR
or
-\fI192.168.201.0/255.255.255.0\fR.
+\fI192\.168\.201\.0/255\.255\.255\.0\fR\.
.PP
-+ : root : 192.168.201.
++ : root : 192\.168\.201\.
.PP
User
\fIroot\fR
should be able to have access from hosts
-\fIfoo1.bar.org\fR
+\fIfoo1\.bar\.org\fR
and
-\fIfoo2.bar.org\fR
-(uses string matching also).
+\fIfoo2\.bar\.org\fR
+(uses string matching also)\.
.PP
-+ : root : foo1.bar.org foo2.bar.org
++ : root : foo1\.bar\.org foo2\.bar\.org
.PP
User
\fIroot\fR
should be able to have access from domain
-\fIfoo.bar.org\fR
-(uses string matching also).
+\fIfoo\.bar\.org\fR
+(uses string matching also)\.
.PP
-+ : root : .foo.bar.org
++ : root : \.foo\.bar\.org
.PP
User
\fIroot\fR
-should be denied to get access from all other sources.
+should be denied to get access from all other sources\.
.PP
\- : root : ALL
.PP
@@ -128,7 +128,7 @@ User
\fIfoo\fR
and members of netgroup
\fIadmins\fR
-should be allowed to get access from all sources. This will only work if netgroup service is available.
+should be allowed to get access from all sources\. This will only work if netgroup service is available\.
.PP
+ : @admins foo : ALL
.PP
@@ -136,21 +136,21 @@ User
\fIjohn\fR
and
\fIfoo\fR
-should get access from IPv6 host address.
+should get access from IPv6 host address\.
.PP
+ : john foo : 2001:4ca0:0:101::1
.PP
User
\fIjohn\fR
-should get access from IPv6 net/mask.
+should get access from IPv6 net/mask\.
.PP
+ : john : 2001:4ca0:0:101::/64
.PP
-Disallow console logins to all but the shutdown, sync and all other accounts, which are a member of the wheel group.
+Disallow console logins to all but the shutdown, sync and all other accounts, which are a member of the wheel group\.
.PP
\-:ALL EXCEPT (wheel) shutdown sync:LOCAL
.PP
-All other users should be denied to get access from all sources.
+All other users should be denied to get access from all sources\.
.PP
\- : ALL : ALL
.SH "SEE ALSO"
@@ -165,6 +165,6 @@ Original
\fBlogin.access\fR(5)
manual was provided by Guido van Rooij which was renamed to
\fBaccess.conf\fR(5)
-to reflect relation to default config file.
+to reflect relation to default config file\.
.PP
-Network address / netmask description and example text was introduced by Mike Becher <mike.becher@lrz\-muenchen.de>.
+Network address / netmask description and example text was introduced by Mike Becher <mike\.becher@lrz\-muenchen\.de>\.
diff --git a/Linux-PAM/modules/pam_access/pam_access.8 b/Linux-PAM/modules/pam_access/pam_access.8
index ca8cc5b0..415df624 100644
--- a/Linux-PAM/modules/pam_access/pam_access.8
+++ b/Linux-PAM/modules/pam_access/pam_access.8
@@ -1,96 +1,103 @@
.\" Title: pam_access
.\" Author:
-.\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
-.\" Date: 06/22/2007
-.\" Manual: Linux\-PAM Manual
-.\" Source: Linux\-PAM Manual
+.\" Generator: DocBook XSL Stylesheets v1.73.1 <http://docbook.sf.net/>
+.\" Date: 01/08/2008
+.\" Manual: Linux-PAM Manual
+.\" Source: Linux-PAM Manual
.\"
-.TH "PAM_ACCESS" "8" "06/22/2007" "Linux\-PAM Manual" "Linux\-PAM Manual"
+.TH "PAM_ACCESS" "8" "01/08/2008" "Linux-PAM Manual" "Linux-PAM Manual"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
-pam_access \- PAM module for logdaemon style login access control
+pam_access - PAM module for logdaemon style login access control
.SH "SYNOPSIS"
.HP 14
-\fBpam_access.so\fR [debug] [nodefgroup] [accessfile=\fIfile\fR] [fieldsep=\fIsep\fR] [listsep=\fIsep\fR]
+\fBpam_access\.so\fR [debug] [nodefgroup] [noaudit] [accessfile=\fIfile\fR] [fieldsep=\fIsep\fR] [listsep=\fIsep\fR]
.SH "DESCRIPTION"
.PP
-The pam_access PAM module is mainly for access management. It provides logdaemon style login access control based on login names, host or domain names, internet addresses or network numbers, or on terminal line names in case of non\-networked logins.
+The pam_access PAM module is mainly for access management\. It provides logdaemon style login access control based on login names, host or domain names, internet addresses or network numbers, or on terminal line names in case of non\-networked logins\.
.PP
By default rules for access management are taken from config file
-\fI/etc/security/access.conf\fR
-if you don't specify another file.
+\fI/etc/security/access\.conf\fR
+if you don\'t specify another file\.
+.PP
+If Linux PAM is compiled with audit support the module will report when it denies access based on origin (host or tty)\.
.SH "OPTIONS"
.PP
-\fBaccessfile=\fR\fB\fI/path/to/access.conf\fR\fR
+\fBaccessfile=\fR\fB\fI/path/to/access\.conf\fR\fR
.RS 4
Indicate an alternative
-\fIaccess.conf\fR
-style configuration file to override the default. This can be useful when different services need different access lists.
+\fIaccess\.conf\fR
+style configuration file to override the default\. This can be useful when different services need different access lists\.
.RE
.PP
\fBdebug\fR
.RS 4
A lot of debug informations are printed with
-\fBsyslog\fR(3).
+\fBsyslog\fR(3)\.
+.RE
+.PP
+\fBnoaudit\fR
+.RS 4
+Do not report logins from disallowed hosts and ttys to the audit subsystem\.
.RE
.PP
\fBfieldsep=\fR\fB\fIseparators\fR\fR
.RS 4
-This option modifies the field separator character that pam_access will recognize when parsing the access configuration file. For example:
+This option modifies the field separator character that pam_access will recognize when parsing the access configuration file\. For example:
\fBfieldsep=|\fR
-will cause the default `:' character to be treated as part of a field value and `|' becomes the field separator. Doing this may be useful in conjuction with a system that wants to use pam_access with X based applications, since the
+will cause the default `:\' character to be treated as part of a field value and `|\' becomes the field separator\. Doing this may be useful in conjuction with a system that wants to use pam_access with X based applications, since the
\fBPAM_TTY\fR
-item is likely to be of the form "hostname:0" which includes a `:' character in its value. But you should not need this.
+item is likely to be of the form "hostname:0" which includes a `:\' character in its value\. But you should not need this\.
.RE
.PP
\fBlistsep=\fR\fB\fIseparators\fR\fR
.RS 4
-This option modifies the list separator character that pam_access will recognize when parsing the access configuration file. For example:
+This option modifies the list separator character that pam_access will recognize when parsing the access configuration file\. For example:
\fBlistsep=,\fR
-will cause the default ` ' (space) and `\\t' (tab) characters to be treated as part of a list element value and `,' becomes the only list element separator. Doing this may be useful on a system with group information obtained from a Windows domain, where the default built\-in groups "Domain Users", "Domain Admins" contain a space.
+will cause the default ` \' (space) and `\et\' (tab) characters to be treated as part of a list element value and `,\' becomes the only list element separator\. Doing this may be useful on a system with group information obtained from a Windows domain, where the default built\-in groups "Domain Users", "Domain Admins" contain a space\.
.RE
.PP
\fBnodefgroup\fR
.RS 4
-The group database will not be used for tokens not identified as account name.
+The group database will not be used for tokens not identified as account name\.
.RE
.SH "MODULE SERVICES PROVIDED"
.PP
-All services are supported.
+All services are supported\.
.SH "RETURN VALUES"
.PP
PAM_SUCCESS
.RS 4
-Access was granted.
+Access was granted\.
.RE
.PP
PAM_PERM_DENIED
.RS 4
-Access was not granted.
+Access was not granted\.
.RE
.PP
PAM_IGNORE
.RS 4
\fBpam_setcred\fR
-was called which does nothing.
+was called which does nothing\.
.RE
.PP
PAM_ABORT
.RS 4
-Not all relevant data or options could be gotten.
+Not all relevant data or options could be gotten\.
.RE
.PP
PAM_USER_UNKNOWN
.RS 4
-The user is not known to the system.
+The user is not known to the system\.
.RE
.SH "FILES"
.PP
-\fI/etc/security/access.conf\fR
+\fI/etc/security/access\.conf\fR
.RS 4
Default configuration file
.RE
@@ -99,7 +106,7 @@ Default configuration file
\fBaccess.conf\fR(5),
\fBpam.d\fR(8),
-\fBpam\fR(8).
+\fBpam\fR(8)\.
.SH "AUTHORS"
.PP
-The logdaemon style login access control scheme was designed and implemented by Wietse Venema. The pam_access PAM module was developed by Alexei Nogin <alexei@nogin.dnttm.ru>. The IPv6 support and the network(address) / netmask feature was developed and provided by Mike Becher <mike.becher@lrz\-muenchen.de>.
+The logdaemon style login access control scheme was designed and implemented by Wietse Venema\. The pam_access PAM module was developed by Alexei Nogin <alexei@nogin\.dnttm\.ru>\. The IPv6 support and the network(address) / netmask feature was developed and provided by Mike Becher <mike\.becher@lrz\-muenchen\.de>\.
diff --git a/Linux-PAM/modules/pam_access/pam_access.8.xml b/Linux-PAM/modules/pam_access/pam_access.8.xml
index 1d814e88..21970d49 100644
--- a/Linux-PAM/modules/pam_access/pam_access.8.xml
+++ b/Linux-PAM/modules/pam_access/pam_access.8.xml
@@ -29,6 +29,9 @@
nodefgroup
</arg>
<arg choice="opt">
+ noaudit
+ </arg>
+ <arg choice="opt">
accessfile=<replaceable>file</replaceable>
</arg>
<arg choice="opt">
@@ -54,6 +57,10 @@
<filename>/etc/security/access.conf</filename> if you don't specify
another file.
</para>
+ <para>
+ If Linux PAM is compiled with audit support the module will report
+ when it denies access based on origin (host or tty).
+ </para>
</refsect1>
<refsect1 id="pam_access-options">
@@ -87,6 +94,17 @@
<varlistentry>
<term>
+ <option>noaudit</option>
+ </term>
+ <listitem>
+ <para>
+ Do not report logins from disallowed hosts and ttys to the audit subsystem.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
<option>fieldsep=<replaceable>separators</replaceable></option>
</term>
<listitem>
diff --git a/Linux-PAM/modules/pam_access/pam_access.c b/Linux-PAM/modules/pam_access/pam_access.c
index e12bc721..edb8fb0a 100644
--- a/Linux-PAM/modules/pam_access/pam_access.c
+++ b/Linux-PAM/modules/pam_access/pam_access.c
@@ -46,6 +46,10 @@
#include <netdb.h>
#include <sys/socket.h>
+#ifdef HAVE_LIBAUDIT
+#include <libaudit.h>
+#endif
+
/*
* here, we make definitions for the externally accessible functions
* in this file (these definitions are required for static modules
@@ -81,17 +85,11 @@
/* Delimiters for fields and for lists of users, ttys or hosts. */
-static const char *fs = ":"; /* field separator */
-static const char *sep = ", \t"; /* list-element separator */
-
- /* Constants to be used in assignments only, not in comparisons... */
+#define ALL 2
#define YES 1
#define NO 0
-/* Only allow group entries of the form "(xyz)" */
-static int only_new_group_syntax = NO;
-
/*
* A structure to bundle up all login-related information to keep the
* functional interfaces as generic as possible.
@@ -100,12 +98,13 @@ struct login_info {
const struct passwd *user;
const char *from;
const char *config_file;
+ int debug; /* Print debugging messages. */
+ int only_new_group_syntax; /* Only allow group entries of the form "(xyz)" */
+ int noaudit; /* Do not audit denials */
+ const char *fs; /* field separator */
+ const char *sep; /* list-element separator */
};
-/* Print debugging messages.
- Default is NO which means don't print debugging messages. */
-static char pam_access_debug = NO;
-
/* Parse module config arguments */
static int
@@ -113,17 +112,22 @@ parse_args(pam_handle_t *pamh, struct login_info *loginfo,
int argc, const char **argv)
{
int i;
-
+
+ loginfo->noaudit = NO;
+ loginfo->debug = NO;
+ loginfo->only_new_group_syntax = NO;
+ loginfo->fs = ":";
+ loginfo->sep = ", \t";
for (i=0; i<argc; ++i) {
if (!strncmp("fieldsep=", argv[i], 9)) {
/* the admin wants to override the default field separators */
- fs = argv[i]+9;
+ loginfo->fs = argv[i]+9;
} else if (!strncmp("listsep=", argv[i], 8)) {
/* the admin wants to override the default list separators */
- sep = argv[i]+8;
+ loginfo->sep = argv[i]+8;
} else if (!strncmp("accessfile=", argv[i], 11)) {
FILE *fp = fopen(11 + argv[i], "r");
@@ -138,9 +142,11 @@ parse_args(pam_handle_t *pamh, struct login_info *loginfo,
}
} else if (strcmp (argv[i], "debug") == 0) {
- pam_access_debug = YES;
+ loginfo->debug = YES;
} else if (strcmp (argv[i], "nodefgroup") == 0) {
- only_new_group_syntax = YES;
+ loginfo->only_new_group_syntax = YES;
+ } else if (strcmp (argv[i], "noaudit") == 0) {
+ loginfo->noaudit = YES;
} else {
pam_syslog(pamh, LOG_ERR, "unrecognized option [%s]", argv[i]);
}
@@ -156,10 +162,10 @@ typedef int match_func (pam_handle_t *, char *, struct login_info *);
static int list_match (pam_handle_t *, char *, char *, struct login_info *,
match_func *);
static int user_match (pam_handle_t *, char *, struct login_info *);
-static int group_match (pam_handle_t *, const char *, const char *);
+static int group_match (pam_handle_t *, const char *, const char *, int);
static int from_match (pam_handle_t *, char *, struct login_info *);
-static int string_match (pam_handle_t *, const char *, const char *);
-static int network_netmask_match (pam_handle_t *, const char *, const char *);
+static int string_match (pam_handle_t *, const char *, const char *, int);
+static int network_netmask_match (pam_handle_t *, const char *, const char *, int);
/* isipaddr - find out if string provided is an IP address or not */
@@ -325,11 +331,12 @@ login_access (pam_handle_t *pamh, struct login_info *item)
char *users; /* becomes list of login names */
char *froms; /* becomes list of terminals or hosts */
int match = NO;
+ int nonall_match = NO;
int end;
int lineno = 0; /* for diagnostics */
char *sptr;
- if (pam_access_debug)
+ if (item->debug)
pam_syslog (pamh, LOG_DEBUG,
"login_access: user=%s, from=%s, file=%s",
item->user->pw_name,
@@ -361,8 +368,8 @@ login_access (pam_handle_t *pamh, struct login_info *item)
continue;
/* Allow field seperator in last field of froms */
- if (!(perm = strtok_r(line, fs, &sptr))
- || !(users = strtok_r(NULL, fs, &sptr))
+ if (!(perm = strtok_r(line, item->fs, &sptr))
+ || !(users = strtok_r(NULL, item->fs, &sptr))
|| !(froms = strtok_r(NULL, "\n", &sptr))) {
pam_syslog(pamh, LOG_ERR, "%s: line %d: bad field count",
item->config_file, lineno);
@@ -373,17 +380,22 @@ login_access (pam_handle_t *pamh, struct login_info *item)
item->config_file, lineno);
continue;
}
- if (pam_access_debug)
+ if (item->debug)
pam_syslog (pamh, LOG_DEBUG,
"line %d: %s : %s : %s", lineno, perm, users, froms);
- match = list_match(pamh, froms, NULL, item, from_match);
- if (pam_access_debug)
- pam_syslog (pamh, LOG_DEBUG,
- "from_match=%d, \"%s\"", match, item->from);
- match = match && list_match (pamh, users, NULL, item, user_match);
- if (pam_access_debug)
+ match = list_match(pamh, users, NULL, item, user_match);
+ if (item->debug)
pam_syslog (pamh, LOG_DEBUG, "user_match=%d, \"%s\"",
match, item->user->pw_name);
+ if (match) {
+ match = list_match(pamh, froms, NULL, item, from_match);
+ if (!match && perm[0] == '+') {
+ nonall_match = YES;
+ }
+ if (item->debug)
+ pam_syslog (pamh, LOG_DEBUG,
+ "from_match=%d, \"%s\"", match, item->from);
+ }
}
(void) fclose(fp);
} else if (errno == ENOENT) {
@@ -394,6 +406,13 @@ login_access (pam_handle_t *pamh, struct login_info *item)
pam_syslog(pamh, LOG_ERR, "cannot open %s: %m", item->config_file);
return NO;
}
+#ifdef HAVE_LIBAUDIT
+ if (!item->noaudit && line[0] == '-' && (match == YES || (match == ALL &&
+ nonall_match == YES))) {
+ pam_modutil_audit_write(pamh, AUDIT_ANOM_LOGIN_LOCATION,
+ "pam_access", 0);
+ }
+#endif
return (match == NO || (line[0] == '+'));
}
@@ -407,7 +426,7 @@ list_match(pam_handle_t *pamh, char *list, char *sptr,
char *tok;
int match = NO;
- if (pam_access_debug && list != NULL)
+ if (item->debug && list != NULL)
pam_syslog (pamh, LOG_DEBUG,
"list_match: list=%s, item=%s", list, item->user->pw_name);
@@ -418,8 +437,8 @@ list_match(pam_handle_t *pamh, char *list, char *sptr,
* the match is affected by any exceptions.
*/
- for (tok = strtok_r(list, sep, &sptr); tok != 0;
- tok = strtok_r(NULL, sep, &sptr)) {
+ for (tok = strtok_r(list, item->sep, &sptr); tok != 0;
+ tok = strtok_r(NULL, item->sep, &sptr)) {
if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */
break;
if ((match = (*match_fn) (pamh, tok, item))) /* YES */
@@ -428,10 +447,12 @@ list_match(pam_handle_t *pamh, char *list, char *sptr,
/* Process exceptions to matches. */
if (match != NO) {
- while ((tok = strtok_r(NULL, sep, &sptr)) && strcasecmp(tok, "EXCEPT"))
+ while ((tok = strtok_r(NULL, item->sep, &sptr)) && strcasecmp(tok, "EXCEPT"))
/* VOID */ ;
- if (tok == 0 || list_match(pamh, NULL, sptr, item, match_fn) == NO)
- return (match);
+ if (tok == 0)
+ return match;
+ if (list_match(pamh, NULL, sptr, item, match_fn) == NO)
+ return YES; /* drop special meaning of ALL */
}
return (NO);
}
@@ -453,7 +474,7 @@ static char *myhostname(void)
static int
netgroup_match (pam_handle_t *pamh, const char *netgroup,
- const char *machine, const char *user)
+ const char *machine, const char *user, int debug)
{
char *mydomain = NULL;
int retval;
@@ -462,7 +483,7 @@ netgroup_match (pam_handle_t *pamh, const char *netgroup,
retval = innetgr (netgroup, machine, user, mydomain);
- if (pam_access_debug == YES)
+ if (debug == YES)
pam_syslog (pamh, LOG_DEBUG,
"netgroup_match: %d (netgroup=%s, machine=%s, user=%s, domain=%s)",
retval, netgroup ? netgroup : "NULL",
@@ -480,8 +501,9 @@ user_match (pam_handle_t *pamh, char *tok, struct login_info *item)
char *string = item->user->pw_name;
struct login_info fake_item;
char *at;
+ int rv;
- if (pam_access_debug)
+ if (item->debug)
pam_syslog (pamh, LOG_DEBUG,
"user_match: tok=%s, item=%s", tok, string);
@@ -500,12 +522,12 @@ user_match (pam_handle_t *pamh, char *tok, struct login_info *item)
return (user_match (pamh, tok, item) &&
from_match (pamh, at + 1, &fake_item));
} else if (tok[0] == '@') /* netgroup */
- return (netgroup_match (pamh, tok + 1, (char *) 0, string));
+ return (netgroup_match (pamh, tok + 1, (char *) 0, string, item->debug));
else if (tok[0] == '(' && tok[strlen(tok) - 1] == ')')
- return (group_match (pamh, tok, string));
- else if (string_match (pamh, tok, string)) /* ALL or exact match */
- return YES;
- else if (only_new_group_syntax == NO &&
+ return (group_match (pamh, tok, string, item->debug));
+ else if ((rv=string_match (pamh, tok, string, item->debug)) != NO) /* ALL or exact match */
+ return rv;
+ else if (item->only_new_group_syntax == NO &&
pam_modutil_user_in_group_nam_nam (pamh,
item->user->pw_name, tok))
/* try group membership */
@@ -518,11 +540,12 @@ user_match (pam_handle_t *pamh, char *tok, struct login_info *item)
/* group_match - match a username against token named group */
static int
-group_match (pam_handle_t *pamh, const char *tok, const char* usr)
+group_match (pam_handle_t *pamh, const char *tok, const char* usr,
+ int debug)
{
char grptok[BUFSIZ];
- if (pam_access_debug)
+ if (debug)
pam_syslog (pamh, LOG_DEBUG,
"group_match: grp=%s, user=%s", grptok, usr);
@@ -548,8 +571,9 @@ from_match (pam_handle_t *pamh UNUSED, char *tok, struct login_info *item)
const char *string = item->from;
int tok_len;
int str_len;
+ int rv;
- if (pam_access_debug)
+ if (item->debug)
pam_syslog (pamh, LOG_DEBUG,
"from_match: tok=%s, item=%s", tok, string);
@@ -565,10 +589,10 @@ from_match (pam_handle_t *pamh UNUSED, char *tok, struct login_info *item)
if (string == NULL) {
return NO;
} else if (tok[0] == '@') { /* netgroup */
- return (netgroup_match (pamh, tok + 1, string, (char *) 0));
- } else if (string_match(pamh, tok, string)) {
+ return (netgroup_match (pamh, tok + 1, string, (char *) 0, item->debug));
+ } else if ((rv = string_match(pamh, tok, string, item->debug)) != NO) {
/* ALL or exact match */
- return (YES);
+ return rv;
} else if (tok[0] == '.') { /* domain: match last fields */
if ((str_len = strlen(string)) > (tok_len = strlen(tok))
&& strcasecmp(tok, string + str_len - tok_len) == 0)
@@ -614,7 +638,7 @@ from_match (pam_handle_t *pamh UNUSED, char *tok, struct login_info *item)
}
} else if (isipaddr(string, NULL, NULL) == YES) {
/* Assume network/netmask with a IP of a host. */
- if (network_netmask_match(pamh, tok, string))
+ if (network_netmask_match(pamh, tok, string, item->debug))
return YES;
} else {
/* Assume network/netmask with a name of a host. */
@@ -641,7 +665,7 @@ from_match (pam_handle_t *pamh UNUSED, char *tok, struct login_info *item)
: (void *) &((struct sockaddr_in6 *) runp->ai_addr)->sin6_addr,
buf, sizeof (buf));
- if (network_netmask_match(pamh, tok, buf))
+ if (network_netmask_match(pamh, tok, buf, item->debug))
{
freeaddrinfo (res);
return YES;
@@ -658,10 +682,11 @@ from_match (pam_handle_t *pamh UNUSED, char *tok, struct login_info *item)
/* string_match - match a string against one token */
static int
-string_match (pam_handle_t *pamh, const char *tok, const char *string)
+string_match (pam_handle_t *pamh, const char *tok, const char *string,
+ int debug)
{
- if (pam_access_debug)
+ if (debug)
pam_syslog (pamh, LOG_DEBUG,
"string_match: tok=%s, item=%s", tok, string);
@@ -672,7 +697,7 @@ string_match (pam_handle_t *pamh, const char *tok, const char *string)
*/
if (strcasecmp(tok, "ALL") == 0) { /* all: always matches */
- return (YES);
+ return (ALL);
} else if (string != NULL) {
if (strcasecmp(tok, string) == 0) { /* try exact match */
return (YES);
@@ -690,9 +715,9 @@ string_match (pam_handle_t *pamh, const char *tok, const char *string)
*/
static int
network_netmask_match (pam_handle_t *pamh,
- const char *tok, const char *string)
+ const char *tok, const char *string, int debug)
{
- if (pam_access_debug)
+ if (debug)
pam_syslog (pamh, LOG_DEBUG,
"network_netmask_match: tok=%s, item=%s", tok, string);
@@ -771,6 +796,22 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED,
return PAM_USER_UNKNOWN;
}
+ if ((user_pw=pam_modutil_getpwnam(pamh, user))==NULL)
+ return (PAM_USER_UNKNOWN);
+
+ /*
+ * Bundle up the arguments to avoid unnecessary clumsiness later on.
+ */
+ loginfo.user = user_pw;
+ loginfo.config_file = PAM_ACCESS_CONFIG;
+
+ /* parse the argument list */
+
+ if (!parse_args(pamh, &loginfo, argc, argv)) {
+ pam_syslog(pamh, LOG_ERR, "failed to parse the module arguments");
+ return PAM_ABORT;
+ }
+
/* remote host name */
if (pam_get_item(pamh, PAM_RHOST, &void_from)
@@ -799,7 +840,7 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED,
return PAM_ABORT;
}
from = void_from;
- if (pam_access_debug)
+ if (loginfo.debug)
pam_syslog (pamh, LOG_DEBUG,
"cannot determine tty or remote hostname, using service %s",
from);
@@ -817,22 +858,7 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED,
}
}
- if ((user_pw=pam_modutil_getpwnam(pamh, user))==NULL)
- return (PAM_USER_UNKNOWN);
-
- /*
- * Bundle up the arguments to avoid unnecessary clumsiness later on.
- */
- loginfo.user = user_pw;
loginfo.from = from;
- loginfo.config_file = PAM_ACCESS_CONFIG;
-
- /* parse the argument list */
-
- if (!parse_args(pamh, &loginfo, argc, argv)) {
- pam_syslog(pamh, LOG_ERR, "failed to parse the module arguments");
- return PAM_ABORT;
- }
if (login_access(pamh, &loginfo)) {
return (PAM_SUCCESS);