upgrade to new upstream release
This commit is contained in:
parent
d31d5587d4
commit
412141d627
@ -1,8 +0,0 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.9 (GNU/Linux)
|
||||
Comment: See http://www.kernel.org/signature.html for info
|
||||
|
||||
iD8DBQBMyYZZyGugalF9Dw4RAtMkAJwIeAEXVkGZ3mL4YQKixP5zx3D6iACghePh
|
||||
sG43bk6Idz0UGC24QRQPDYE=
|
||||
=lJnB
|
||||
-----END PGP SIGNATURE-----
|
8
Linux-PAM-1.1.4.tar.bz2.sign
Normal file
8
Linux-PAM-1.1.4.tar.bz2.sign
Normal file
@ -0,0 +1,8 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.11 (GNU/Linux)
|
||||
Comment: See http://www.kernel.org/signature.html for info
|
||||
|
||||
iD8DBQBOBHzAyGugalF9Dw4RAvUUAJ0SfOT7ITyalk4JsmIe5tJSdIB5ygCfZ2ku
|
||||
aHp5ptRfKYgWdlnFv+3F7H4=
|
||||
=kqy6
|
||||
-----END PGP SIGNATURE-----
|
@ -1,64 +0,0 @@
|
||||
diff -up Linux-PAM-1.1.3/modules/pam_limits/pam_limits.c.nosetreuid Linux-PAM-1.1.3/modules/pam_limits/pam_limits.c
|
||||
--- Linux-PAM-1.1.3/modules/pam_limits/pam_limits.c.nosetreuid 2009-02-20 14:27:14.000000000 +0100
|
||||
+++ Linux-PAM-1.1.3/modules/pam_limits/pam_limits.c 2010-11-11 12:31:04.000000000 +0100
|
||||
@@ -103,7 +103,6 @@ struct pam_limit_s {
|
||||
/* argument parsing */
|
||||
|
||||
#define PAM_DEBUG_ARG 0x0001
|
||||
-#define PAM_DO_SETREUID 0x0002
|
||||
#define PAM_UTMP_EARLY 0x0004
|
||||
#define PAM_NO_AUDIT 0x0008
|
||||
|
||||
@@ -127,8 +126,6 @@ _pam_parse (const pam_handle_t *pamh, in
|
||||
ctrl |= PAM_DEBUG_ARG;
|
||||
} else if (!strncmp(*argv,"conf=",5)) {
|
||||
pl->conf_file = *argv+5;
|
||||
- } else if (!strncmp(*argv,"change_uid",10)) {
|
||||
- ctrl |= PAM_DO_SETREUID;
|
||||
} else if (!strcmp(*argv,"utmp_early")) {
|
||||
ctrl |= PAM_UTMP_EARLY;
|
||||
} else if (!strcmp(*argv,"noaudit")) {
|
||||
@@ -777,10 +774,6 @@ out:
|
||||
return retval;
|
||||
}
|
||||
|
||||
- if (ctrl & PAM_DO_SETREUID) {
|
||||
- setreuid(pwd->pw_uid, -1);
|
||||
- }
|
||||
-
|
||||
retval = setup_limits(pamh, pwd->pw_name, pwd->pw_uid, ctrl, pl);
|
||||
if (retval & LOGIN_ERR)
|
||||
pam_error(pamh, _("Too many logins for '%s'."), pwd->pw_name);
|
||||
diff -up Linux-PAM-1.1.3/modules/pam_limits/pam_limits.8.xml.nosetreuid Linux-PAM-1.1.3/modules/pam_limits/pam_limits.8.xml
|
||||
--- Linux-PAM-1.1.3/modules/pam_limits/pam_limits.8.xml.nosetreuid 2009-06-01 09:03:20.000000000 +0200
|
||||
+++ Linux-PAM-1.1.3/modules/pam_limits/pam_limits.8.xml 2010-11-11 12:32:35.000000000 +0100
|
||||
@@ -23,9 +23,6 @@
|
||||
<cmdsynopsis id="pam_limits-cmdsynopsis">
|
||||
<command>pam_limits.so</command>
|
||||
<arg choice="opt">
|
||||
- change_uid
|
||||
- </arg>
|
||||
- <arg choice="opt">
|
||||
conf=<replaceable>/path/to/limits.conf</replaceable>
|
||||
</arg>
|
||||
<arg choice="opt">
|
||||
@@ -72,19 +69,6 @@
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
- <option>change_uid</option>
|
||||
- </term>
|
||||
- <listitem>
|
||||
- <para>
|
||||
- Change real uid to the user for who the limits are set up. Use this
|
||||
- option if you have problems like login not forking a shell for user
|
||||
- who has no processes. Be warned that something else may break when
|
||||
- you do this.
|
||||
- </para>
|
||||
- </listitem>
|
||||
- </varlistentry>
|
||||
- <varlistentry>
|
||||
- <term>
|
||||
<option>conf=<replaceable>/path/to/limits.conf</replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
@ -1,351 +0,0 @@
|
||||
Index: modules/pam_limits/limits.conf.5.xml
|
||||
===================================================================
|
||||
RCS file: /cvsroot/pam/Linux-PAM/modules/pam_limits/limits.conf.5.xml,v
|
||||
retrieving revision 1.9
|
||||
retrieving revision 1.11
|
||||
diff -u -p -r1.9 -r1.11
|
||||
--- modules/pam_limits/limits.conf.5.xml 20 Feb 2009 13:27:14 -0000 1.9
|
||||
+++ modules/pam_limits/limits.conf.5.xml 14 Dec 2010 08:40:40 -0000 1.11
|
||||
@@ -53,7 +53,38 @@
|
||||
<listitem>
|
||||
<para>
|
||||
the wildcard <emphasis remap='B'>%</emphasis>, for maxlogins limit only,
|
||||
- can also be used with <emphasis remap='b'>%group</emphasis> syntax.
|
||||
+ can also be used with <emphasis remap='B'>%group</emphasis> syntax. If the
|
||||
+ <emphasis remap='B'>%</emphasis> wildcard is used alone it is identical
|
||||
+ to using <emphasis remap='B'>*</emphasis> with maxsyslogins limit. With
|
||||
+ a group specified after <emphasis remap='B'>%</emphasis> it limits the total
|
||||
+ number of logins of all users that are member of the group.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ an uid range specified as <replaceable><min_uid></replaceable><emphasis
|
||||
+ remap='B'>:</emphasis><replaceable><max_uid></replaceable>. If min_uid
|
||||
+ is omitted, the match is exact for the max_uid. If max_uid is omitted, all
|
||||
+ uids greater than or equal min_uid match.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ a gid range specified as <emphasis
|
||||
+ remap='B'>@</emphasis><replaceable><min_gid></replaceable><emphasis
|
||||
+ remap='B'>:</emphasis><replaceable><max_gid></replaceable>. If min_gid
|
||||
+ is omitted, the match is exact for the max_gid. If max_gid is omitted, all
|
||||
+ gids greater than or equal min_gid match. For the exact match all groups including
|
||||
+ the user's supplementary groups are examined. For the range matches only
|
||||
+ the user's primary group is examined.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ a gid specified as <emphasis
|
||||
+ remap='B'>%:</emphasis><replaceable><gid></replaceable> applicable
|
||||
+ to maxlogins limit only. It limits the total number of logins of all users
|
||||
+ that are member of the group with the specified gid.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
@@ -182,7 +213,7 @@
|
||||
<varlistentry>
|
||||
<term><option>maxsyslogins</option></term>
|
||||
<listitem>
|
||||
- <para>maximum number of logins on system</para>
|
||||
+ <para>maximum number of all logins on system</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@@ -272,12 +303,15 @@
|
||||
</para>
|
||||
<programlisting>
|
||||
* soft core 0
|
||||
-* hard rss 10000
|
||||
+* hard nofile 512
|
||||
@student hard nproc 20
|
||||
@faculty soft nproc 20
|
||||
@faculty hard nproc 50
|
||||
ftp hard nproc 0
|
||||
@student - maxlogins 4
|
||||
+:123 hard cpu 5000
|
||||
+@500: soft cpu 10000
|
||||
+600:700 hard locks 10
|
||||
</programlisting>
|
||||
</refsect1>
|
||||
|
||||
Index: modules/pam_limits/pam_limits.c
|
||||
===================================================================
|
||||
RCS file: /cvsroot/pam/Linux-PAM/modules/pam_limits/pam_limits.c,v
|
||||
retrieving revision 1.48
|
||||
retrieving revision 1.49
|
||||
diff -u -p -r1.48 -r1.49
|
||||
--- modules/pam_limits/pam_limits.c 18 Nov 2010 09:37:32 -0000 1.48
|
||||
+++ modules/pam_limits/pam_limits.c 14 Dec 2010 08:40:40 -0000 1.49
|
||||
@@ -55,6 +55,12 @@
|
||||
#define LIMITS_DEF_DEFAULT 4 /* limit was set by an default entry */
|
||||
#define LIMITS_DEF_NONE 5 /* this limit was not set yet */
|
||||
|
||||
+#define LIMIT_RANGE_ERR -1 /* error in specified uid/gid range */
|
||||
+#define LIMIT_RANGE_NONE 0 /* no range specified */
|
||||
+#define LIMIT_RANGE_ONE 1 /* exact uid/gid specified (:max_uid)*/
|
||||
+#define LIMIT_RANGE_MIN 2 /* only minimum uid/gid specified (min_uid:) */
|
||||
+#define LIMIT_RANGE_MM 3 /* both min and max uid/gid specified (min_uid:max_uid) */
|
||||
+
|
||||
static const char *limits_def_names[] = {
|
||||
"USER",
|
||||
"GROUP",
|
||||
@@ -520,8 +526,57 @@ process_limit (const pam_handle_t *pamh,
|
||||
return;
|
||||
}
|
||||
|
||||
-static int parse_config_file(pam_handle_t *pamh, const char *uname, int ctrl,
|
||||
- struct pam_limit_s *pl)
|
||||
+static int
|
||||
+parse_uid_range(pam_handle_t *pamh, const char *domain,
|
||||
+ uid_t *min_uid, uid_t *max_uid)
|
||||
+{
|
||||
+ const char *range = domain;
|
||||
+ char *pmax;
|
||||
+ char *endptr;
|
||||
+ int rv = LIMIT_RANGE_MM;
|
||||
+
|
||||
+ if ((pmax=strchr(range, ':')) == NULL)
|
||||
+ return LIMIT_RANGE_NONE;
|
||||
+ ++pmax;
|
||||
+
|
||||
+ if (range[0] == '@' || range[0] == '%')
|
||||
+ ++range;
|
||||
+
|
||||
+ if (range[0] == ':')
|
||||
+ rv = LIMIT_RANGE_ONE;
|
||||
+ else {
|
||||
+ errno = 0;
|
||||
+ *min_uid = strtoul (range, &endptr, 10);
|
||||
+ if (errno != 0 || (range == endptr) || *endptr != ':') {
|
||||
+ pam_syslog(pamh, LOG_DEBUG,
|
||||
+ "wrong min_uid/gid value in '%s'", domain);
|
||||
+ return LIMIT_RANGE_ERR;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (*pmax == '\0') {
|
||||
+ if (rv == LIMIT_RANGE_ONE)
|
||||
+ return LIMIT_RANGE_ERR;
|
||||
+ else
|
||||
+ return LIMIT_RANGE_MIN;
|
||||
+ }
|
||||
+
|
||||
+ errno = 0;
|
||||
+ *max_uid = strtoul (pmax, &endptr, 10);
|
||||
+ if (errno != 0 || (pmax == endptr) || *endptr != '\0') {
|
||||
+ pam_syslog(pamh, LOG_DEBUG,
|
||||
+ "wrong max_uid/gid value in '%s'", domain);
|
||||
+ return LIMIT_RANGE_ERR;
|
||||
+ }
|
||||
+
|
||||
+ if (rv == LIMIT_RANGE_ONE)
|
||||
+ *min_uid = *max_uid;
|
||||
+ return rv;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+parse_config_file(pam_handle_t *pamh, const char *uname, uid_t uid, gid_t gid,
|
||||
+ int ctrl, struct pam_limit_s *pl)
|
||||
{
|
||||
FILE *fil;
|
||||
char buf[LINE_LENGTH];
|
||||
@@ -543,8 +598,10 @@ static int parse_config_file(pam_handle_
|
||||
char item[LINE_LENGTH];
|
||||
char value[LINE_LENGTH];
|
||||
int i;
|
||||
+ int rngtype;
|
||||
size_t j;
|
||||
char *tptr,*line;
|
||||
+ uid_t min_uid = (uid_t)-1, max_uid = (uid_t)-1;
|
||||
|
||||
line = buf;
|
||||
/* skip the leading white space */
|
||||
@@ -572,6 +629,11 @@ static int parse_config_file(pam_handle_
|
||||
for(j=0; j < strlen(ltype); j++)
|
||||
ltype[j]=tolower(ltype[j]);
|
||||
|
||||
+ if ((rngtype=parse_uid_range(pamh, domain, &min_uid, &max_uid)) < 0) {
|
||||
+ pam_syslog(pamh, LOG_WARNING, "invalid uid range '%s' - skipped", domain);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
if (i == 4) { /* a complete line */
|
||||
for(j=0; j < strlen(item); j++)
|
||||
item[j]=tolower(item[j]);
|
||||
@@ -581,47 +643,133 @@ static int parse_config_file(pam_handle_
|
||||
if (strcmp(uname, domain) == 0) /* this user have a limit */
|
||||
process_limit(pamh, LIMITS_DEF_USER, ltype, item, value, ctrl, pl);
|
||||
else if (domain[0]=='@') {
|
||||
- if (ctrl & PAM_DEBUG_ARG) {
|
||||
+ if (ctrl & PAM_DEBUG_ARG) {
|
||||
pam_syslog(pamh, LOG_DEBUG,
|
||||
"checking if %s is in group %s",
|
||||
uname, domain + 1);
|
||||
- }
|
||||
- if (pam_modutil_user_in_group_nam_nam(pamh, uname, domain+1))
|
||||
- process_limit(pamh, LIMITS_DEF_GROUP, ltype, item, value, ctrl,
|
||||
+ }
|
||||
+ switch(rngtype) {
|
||||
+ case LIMIT_RANGE_NONE:
|
||||
+ if (pam_modutil_user_in_group_nam_nam(pamh, uname, domain+1))
|
||||
+ process_limit(pamh, LIMITS_DEF_GROUP, ltype, item, value, ctrl,
|
||||
+ pl);
|
||||
+ break;
|
||||
+ case LIMIT_RANGE_ONE:
|
||||
+ if (pam_modutil_user_in_group_nam_gid(pamh, uname, (gid_t)max_uid))
|
||||
+ process_limit(pamh, LIMITS_DEF_GROUP, ltype, item, value, ctrl,
|
||||
pl);
|
||||
+ break;
|
||||
+ case LIMIT_RANGE_MM:
|
||||
+ if (gid > (gid_t)max_uid)
|
||||
+ break;
|
||||
+ /* fallthrough */
|
||||
+ case LIMIT_RANGE_MIN:
|
||||
+ if (gid >= (gid_t)min_uid)
|
||||
+ process_limit(pamh, LIMITS_DEF_GROUP, ltype, item, value, ctrl,
|
||||
+ pl);
|
||||
+ }
|
||||
} else if (domain[0]=='%') {
|
||||
- if (ctrl & PAM_DEBUG_ARG) {
|
||||
+ if (ctrl & PAM_DEBUG_ARG) {
|
||||
pam_syslog(pamh, LOG_DEBUG,
|
||||
"checking if %s is in group %s",
|
||||
uname, domain + 1);
|
||||
- }
|
||||
- if (strcmp(domain,"%") == 0)
|
||||
- process_limit(pamh, LIMITS_DEF_ALL, ltype, item, value, ctrl,
|
||||
- pl);
|
||||
- else if (pam_modutil_user_in_group_nam_nam(pamh, uname, domain+1)) {
|
||||
- strcpy(pl->login_group, domain+1);
|
||||
- process_limit(pamh, LIMITS_DEF_ALLGROUP, ltype, item, value, ctrl,
|
||||
- pl);
|
||||
}
|
||||
- } else if (strcmp(domain, "*") == 0)
|
||||
- process_limit(pamh, LIMITS_DEF_DEFAULT, ltype, item, value, ctrl,
|
||||
- pl);
|
||||
+ switch(rngtype) {
|
||||
+ case LIMIT_RANGE_NONE:
|
||||
+ if (strcmp(domain,"%") == 0)
|
||||
+ process_limit(pamh, LIMITS_DEF_ALL, ltype, item, value, ctrl,
|
||||
+ pl);
|
||||
+ else if (pam_modutil_user_in_group_nam_nam(pamh, uname, domain+1)) {
|
||||
+ strcpy(pl->login_group, domain+1);
|
||||
+ process_limit(pamh, LIMITS_DEF_ALLGROUP, ltype, item, value, ctrl,
|
||||
+ pl);
|
||||
+ }
|
||||
+ break;
|
||||
+ case LIMIT_RANGE_ONE:
|
||||
+ if (pam_modutil_user_in_group_nam_gid(pamh, uname, (gid_t)max_uid)) {
|
||||
+ struct group *grp;
|
||||
+ grp = pam_modutil_getgrgid(pamh, (gid_t)max_uid);
|
||||
+ strncpy(pl->login_group, grp->gr_name, sizeof(pl->login_group));
|
||||
+ pl->login_group[sizeof(pl->login_group)-1] = '\0';
|
||||
+ process_limit(pamh, LIMITS_DEF_ALLGROUP, ltype, item, value, ctrl,
|
||||
+ pl);
|
||||
+ }
|
||||
+ break;
|
||||
+ case LIMIT_RANGE_MIN:
|
||||
+ case LIMIT_RANGE_MM:
|
||||
+ pam_syslog(pamh, LOG_WARNING, "range unsupported for %%group matching - ignored");
|
||||
+ }
|
||||
+ } else {
|
||||
+ switch(rngtype) {
|
||||
+ case LIMIT_RANGE_NONE:
|
||||
+ if (strcmp(domain, "*") == 0)
|
||||
+ process_limit(pamh, LIMITS_DEF_DEFAULT, ltype, item, value, ctrl,
|
||||
+ pl);
|
||||
+ break;
|
||||
+ case LIMIT_RANGE_ONE:
|
||||
+ if (uid != max_uid)
|
||||
+ break;
|
||||
+ /* fallthrough */
|
||||
+ case LIMIT_RANGE_MM:
|
||||
+ if (uid > max_uid)
|
||||
+ break;
|
||||
+ /* fallthrough */
|
||||
+ case LIMIT_RANGE_MIN:
|
||||
+ if (uid >= min_uid)
|
||||
+ process_limit(pamh, LIMITS_DEF_USER, ltype, item, value, ctrl, pl);
|
||||
+ }
|
||||
+ }
|
||||
} else if (i == 2 && ltype[0] == '-') { /* Probably a no-limit line */
|
||||
if (strcmp(uname, domain) == 0) {
|
||||
if (ctrl & PAM_DEBUG_ARG) {
|
||||
pam_syslog(pamh, LOG_DEBUG, "no limits for '%s'", uname);
|
||||
}
|
||||
- fclose(fil);
|
||||
- return PAM_IGNORE;
|
||||
- } else if (domain[0] == '@' && pam_modutil_user_in_group_nam_nam(pamh, uname, domain+1)) {
|
||||
+ } else if (domain[0] == '@') {
|
||||
+ switch(rngtype) {
|
||||
+ case LIMIT_RANGE_NONE:
|
||||
+ if (!pam_modutil_user_in_group_nam_nam(pamh, uname, domain+1))
|
||||
+ continue; /* next line */
|
||||
+ break;
|
||||
+ case LIMIT_RANGE_ONE:
|
||||
+ if (!pam_modutil_user_in_group_nam_gid(pamh, uname, (gid_t)max_uid))
|
||||
+ continue; /* next line */
|
||||
+ break;
|
||||
+ case LIMIT_RANGE_MM:
|
||||
+ if (gid > (gid_t)max_uid)
|
||||
+ continue; /* next line */
|
||||
+ /* fallthrough */
|
||||
+ case LIMIT_RANGE_MIN:
|
||||
+ if (gid < (gid_t)min_uid)
|
||||
+ continue; /* next line */
|
||||
+ }
|
||||
if (ctrl & PAM_DEBUG_ARG) {
|
||||
pam_syslog(pamh, LOG_DEBUG,
|
||||
"no limits for '%s' in group '%s'",
|
||||
uname, domain+1);
|
||||
}
|
||||
- fclose(fil);
|
||||
- return PAM_IGNORE;
|
||||
+ } else {
|
||||
+ switch(rngtype) {
|
||||
+ case LIMIT_RANGE_NONE:
|
||||
+ continue; /* next line */
|
||||
+ case LIMIT_RANGE_ONE:
|
||||
+ if (uid != max_uid)
|
||||
+ continue; /* next line */
|
||||
+ break;
|
||||
+ case LIMIT_RANGE_MM:
|
||||
+ if (uid > max_uid)
|
||||
+ continue; /* next line */
|
||||
+ /* fallthrough */
|
||||
+ case LIMIT_RANGE_MIN:
|
||||
+ if (uid >= min_uid)
|
||||
+ break;
|
||||
+ continue; /* next line */
|
||||
+ }
|
||||
+ if (ctrl & PAM_DEBUG_ARG) {
|
||||
+ pam_syslog(pamh, LOG_DEBUG, "no limits for '%s'", uname);
|
||||
+ }
|
||||
}
|
||||
+ fclose(fil);
|
||||
+ return PAM_IGNORE;
|
||||
} else {
|
||||
pam_syslog(pamh, LOG_WARNING, "invalid line '%s' - skipped", line);
|
||||
}
|
||||
@@ -731,7 +879,7 @@ pam_sm_open_session (pam_handle_t *pamh,
|
||||
return PAM_ABORT;
|
||||
}
|
||||
|
||||
- retval = parse_config_file(pamh, pwd->pw_name, ctrl, pl);
|
||||
+ retval = parse_config_file(pamh, pwd->pw_name, pwd->pw_uid, pwd->pw_gid, ctrl, pl);
|
||||
if (retval == PAM_IGNORE) {
|
||||
D(("the configuration file ('%s') has an applicable '<domain> -' entry", CONF_FILE));
|
||||
return PAM_SUCCESS;
|
||||
@@ -755,7 +903,7 @@ pam_sm_open_session (pam_handle_t *pamh,
|
||||
/* Parse the *.conf files. */
|
||||
for (i = 0; globbuf.gl_pathv[i] != NULL; i++) {
|
||||
pl->conf_file = globbuf.gl_pathv[i];
|
||||
- retval = parse_config_file(pamh, pwd->pw_name, ctrl, pl);
|
||||
+ retval = parse_config_file(pamh, pwd->pw_name, pwd->pw_uid, pwd->pw_gid, ctrl, pl);
|
||||
if (retval == PAM_IGNORE) {
|
||||
D(("the configuration file ('%s') has an applicable '<domain> -' entry", pl->conf_file));
|
||||
globfree(&globbuf);
|
@ -1,275 +0,0 @@
|
||||
diff -up Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.c.private Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.c
|
||||
--- Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.c.private 2010-10-22 09:41:09.000000000 +0200
|
||||
+++ Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.c 2011-06-07 17:28:04.000000000 +0200
|
||||
@@ -61,9 +61,11 @@ static void add_polydir_entry(struct ins
|
||||
|
||||
static void del_polydir(struct polydir_s *poly)
|
||||
{
|
||||
- free(poly->uid);
|
||||
- free(poly->init_script);
|
||||
- free(poly);
|
||||
+ if (poly) {
|
||||
+ free(poly->uid);
|
||||
+ free(poly->init_script);
|
||||
+ free(poly);
|
||||
+ }
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -307,10 +309,6 @@ static int process_line(char *line, cons
|
||||
const char *rvar_values[] = {rhome, idata->ruser};
|
||||
int len;
|
||||
|
||||
- poly = calloc(1, sizeof(*poly));
|
||||
- if (poly == NULL)
|
||||
- goto erralloc;
|
||||
-
|
||||
/*
|
||||
* skip the leading white space
|
||||
*/
|
||||
@@ -337,6 +335,10 @@ static int process_line(char *line, cons
|
||||
if (line[0] == 0)
|
||||
return 0;
|
||||
|
||||
+ poly = calloc(1, sizeof(*poly));
|
||||
+ if (poly == NULL)
|
||||
+ goto erralloc;
|
||||
+
|
||||
/*
|
||||
* Initialize and scan the five strings from the line from the
|
||||
* namespace configuration file.
|
||||
@@ -1001,7 +1003,7 @@ static int protect_mount(int dfd, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int protect_dir(const char *path, mode_t mode, int do_mkdir,
|
||||
+static int protect_dir(const char *path, mode_t mode, int do_mkdir, int always,
|
||||
struct instance_data *idata)
|
||||
{
|
||||
char *p = strdup(path);
|
||||
@@ -1080,7 +1082,7 @@ static int protect_dir(const char *path,
|
||||
}
|
||||
}
|
||||
|
||||
- if (flags & O_NOFOLLOW) {
|
||||
+ if ((flags & O_NOFOLLOW) || always) {
|
||||
/* we are inside user-owned dir - protect */
|
||||
if (protect_mount(rv, p, idata) == -1) {
|
||||
save_errno = errno;
|
||||
@@ -1093,7 +1095,7 @@ static int protect_dir(const char *path,
|
||||
error:
|
||||
save_errno = errno;
|
||||
free(p);
|
||||
- if (dfd != AT_FDCWD)
|
||||
+ if (dfd != AT_FDCWD && dfd >= 0)
|
||||
close(dfd);
|
||||
errno = save_errno;
|
||||
|
||||
@@ -1122,7 +1124,7 @@ static int check_inst_parent(char *ipath
|
||||
if (trailing_slash)
|
||||
*trailing_slash = '\0';
|
||||
|
||||
- dfd = protect_dir(inst_parent, 0, 1, idata);
|
||||
+ dfd = protect_dir(inst_parent, 0, 1, 0, idata);
|
||||
|
||||
if (dfd == -1 || fstat(dfd, &instpbuf) < 0) {
|
||||
pam_syslog(idata->pamh, LOG_ERR,
|
||||
@@ -1257,7 +1259,7 @@ static int create_polydir(struct polydir
|
||||
}
|
||||
#endif
|
||||
|
||||
- rc = protect_dir(dir, mode, 1, idata);
|
||||
+ rc = protect_dir(dir, mode, 1, idata->flags & PAMNS_MOUNT_PRIVATE, idata);
|
||||
if (rc == -1) {
|
||||
pam_syslog(idata->pamh, LOG_ERR,
|
||||
"Error creating directory %s: %m", dir);
|
||||
@@ -1445,7 +1447,7 @@ static int ns_setup(struct polydir_s *po
|
||||
pam_syslog(idata->pamh, LOG_DEBUG,
|
||||
"Set namespace for directory %s", polyptr->dir);
|
||||
|
||||
- retval = protect_dir(polyptr->dir, 0, 0, idata);
|
||||
+ retval = protect_dir(polyptr->dir, 0, 0, idata->flags & PAMNS_MOUNT_PRIVATE, idata);
|
||||
|
||||
if (retval < 0 && errno != ENOENT) {
|
||||
pam_syslog(idata->pamh, LOG_ERR, "Polydir %s access error: %m",
|
||||
@@ -1453,8 +1455,9 @@ static int ns_setup(struct polydir_s *po
|
||||
return PAM_SESSION_ERR;
|
||||
}
|
||||
|
||||
- if (retval < 0 && (polyptr->flags & POLYDIR_CREATE)) {
|
||||
- if (create_polydir(polyptr, idata) != PAM_SUCCESS)
|
||||
+ if (retval < 0) {
|
||||
+ if ((polyptr->flags & POLYDIR_CREATE) &&
|
||||
+ create_polydir(polyptr, idata) != PAM_SUCCESS)
|
||||
return PAM_SESSION_ERR;
|
||||
} else {
|
||||
close(retval);
|
||||
@@ -1531,6 +1534,22 @@ static int ns_setup(struct polydir_s *po
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
+ if (idata->flags & PAMNS_MOUNT_PRIVATE) {
|
||||
+ /*
|
||||
+ * Make the polyinstantiated dir private mount. This depends
|
||||
+ * on making the dir a mount point in the protect_dir call.
|
||||
+ */
|
||||
+ if (mount(polyptr->dir, polyptr->dir, NULL, MS_PRIVATE|MS_REC, NULL) < 0) {
|
||||
+ pam_syslog(idata->pamh, LOG_ERR, "Error making %s a private mount, %m",
|
||||
+ polyptr->dir);
|
||||
+ goto error_out;
|
||||
+ }
|
||||
+ if (idata->flags & PAMNS_DEBUG)
|
||||
+ pam_syslog(idata->pamh, LOG_DEBUG,
|
||||
+ "Polyinstantiated directory %s made as private mount", polyptr->dir);
|
||||
+
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* Bind mount instance directory on top of the polyinstantiated
|
||||
* directory to provide an instance of polyinstantiated directory
|
||||
@@ -1871,6 +1890,53 @@ static int ctxt_based_inst_needed(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
+static int root_shared(void)
|
||||
+{
|
||||
+ FILE *f;
|
||||
+ char *line = NULL;
|
||||
+ size_t n = 0;
|
||||
+ int rv = 0;
|
||||
+
|
||||
+ f = fopen("/proc/self/mountinfo", "r");
|
||||
+
|
||||
+ if (f == NULL)
|
||||
+ return 0;
|
||||
+
|
||||
+ while(getline(&line, &n, f) != -1) {
|
||||
+ char *l;
|
||||
+ char *sptr;
|
||||
+ int i;
|
||||
+
|
||||
+ l = line;
|
||||
+ sptr = NULL;
|
||||
+ for (i = 0; i < 7; i++) {
|
||||
+ char *tok;
|
||||
+
|
||||
+ tok = strtok_r(l, " ", &sptr);
|
||||
+ l = NULL;
|
||||
+ if (tok == NULL)
|
||||
+ /* next mountinfo line */
|
||||
+ break;
|
||||
+
|
||||
+ if (i == 4 && strcmp(tok, "/") != 0)
|
||||
+ /* next mountinfo line */
|
||||
+ break;
|
||||
+
|
||||
+ if (i == 6) {
|
||||
+ if (strncmp(tok, "shared:", 7) == 0)
|
||||
+ /* there might be more / mounts, the last one counts */
|
||||
+ rv = 1;
|
||||
+ else
|
||||
+ rv = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ free(line);
|
||||
+ fclose(f);
|
||||
+
|
||||
+ return rv;
|
||||
+}
|
||||
|
||||
static int get_user_data(struct instance_data *idata)
|
||||
{
|
||||
@@ -1961,12 +2027,15 @@ PAM_EXTERN int pam_sm_open_session(pam_h
|
||||
idata.flags |= PAMNS_USE_DEFAULT_CONTEXT;
|
||||
idata.flags |= PAMNS_CTXT_BASED_INST;
|
||||
}
|
||||
+ if (strcmp(argv[i], "mount_private") == 0) {
|
||||
+ idata.flags |= PAMNS_MOUNT_PRIVATE;
|
||||
+ }
|
||||
if (strcmp(argv[i], "unmnt_remnt") == 0)
|
||||
unmnt = UNMNT_REMNT;
|
||||
if (strcmp(argv[i], "unmnt_only") == 0)
|
||||
unmnt = UNMNT_ONLY;
|
||||
if (strcmp(argv[i], "require_selinux") == 0) {
|
||||
- if (~(idata.flags & PAMNS_SELINUX_ENABLED)) {
|
||||
+ if (!(idata.flags & PAMNS_SELINUX_ENABLED)) {
|
||||
pam_syslog(idata.pamh, LOG_ERR,
|
||||
"selinux_required option given and selinux is disabled");
|
||||
return PAM_SESSION_ERR;
|
||||
@@ -1980,6 +2049,10 @@ PAM_EXTERN int pam_sm_open_session(pam_h
|
||||
if (retval != PAM_SUCCESS)
|
||||
return retval;
|
||||
|
||||
+ if (root_shared()) {
|
||||
+ idata.flags |= PAMNS_MOUNT_PRIVATE;
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* Parse namespace configuration file which lists directories to
|
||||
* polyinstantiate, directory where instance directories are to
|
||||
diff -up Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.h.private Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.h
|
||||
--- Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.h.private 2008-04-18 14:53:38.000000000 +0200
|
||||
+++ Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.h 2011-06-07 17:26:25.000000000 +0200
|
||||
@@ -74,6 +74,14 @@
|
||||
#define CLONE_NEWNS 0x00020000 /* Flag to create new namespace */
|
||||
#endif
|
||||
|
||||
+/* mount flags for mount_private */
|
||||
+#ifndef MS_REC
|
||||
+#define MS_REC (1<<14)
|
||||
+#endif
|
||||
+#ifndef MS_PRIVATE
|
||||
+#define MS_PRIVATE (1<<18)
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* Module defines
|
||||
*/
|
||||
@@ -96,6 +104,7 @@
|
||||
#define PAMNS_NO_UNMOUNT_ON_CLOSE 0x00010000 /* no unmount at session close */
|
||||
#define PAMNS_USE_CURRENT_CONTEXT 0x00020000 /* use getcon instead of getexeccon */
|
||||
#define PAMNS_USE_DEFAULT_CONTEXT 0x00040000 /* use get_default_context instead of getexeccon */
|
||||
+#define PAMNS_MOUNT_PRIVATE 0x00080000 /* Make the polydir mounts private */
|
||||
|
||||
/* polydir flags */
|
||||
#define POLYDIR_EXCLUSIVE 0x00000001 /* polyinstatiate exclusively for override uids */
|
||||
diff -up Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.8.xml.private Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.8.xml
|
||||
--- Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.8.xml.private 2009-06-01 09:03:20.000000000 +0200
|
||||
+++ Linux-PAM-1.1.3/modules/pam_namespace/pam_namespace.8.xml 2011-06-07 17:26:12.000000000 +0200
|
||||
@@ -52,6 +52,9 @@
|
||||
<arg choice="opt">
|
||||
use_default_context
|
||||
</arg>
|
||||
+ <arg choice="opt">
|
||||
+ mount_private
|
||||
+ </arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
@@ -234,6 +237,24 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
+ <varlistentry>
|
||||
+ <term>
|
||||
+ <option>mount_private</option>
|
||||
+ </term>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ This option can be used on systems where the / mount point or
|
||||
+ its submounts are made shared (for example with a
|
||||
+ <command>mount --make-rshared /</command> command).
|
||||
+ The module will make the polyinstantiated directory mount points
|
||||
+ private. Normally the pam_namespace will try to detect the
|
||||
+ shared / mount point and make the polyinstantiated directories
|
||||
+ private automatically. This option has to be used just when
|
||||
+ only a subtree is shared and / is not.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
+ </varlistentry>
|
||||
+
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
@ -1,54 +0,0 @@
|
||||
diff -up Linux-PAM-1.1.3/modules/pam_pwhistory/pam_pwhistory.c.incomplete Linux-PAM-1.1.3/modules/pam_pwhistory/pam_pwhistory.c
|
||||
--- Linux-PAM-1.1.3/modules/pam_pwhistory/pam_pwhistory.c.incomplete 2008-12-18 14:09:36.000000000 +0100
|
||||
+++ Linux-PAM-1.1.3/modules/pam_pwhistory/pam_pwhistory.c 2010-11-11 14:45:02.000000000 +0100
|
||||
@@ -187,12 +187,13 @@ pam_sm_chauthtok (pam_handle_t *pamh, in
|
||||
{
|
||||
retval = pam_get_authtok (pamh, PAM_AUTHTOK, &newpass, NULL);
|
||||
if (retval != PAM_SUCCESS && retval != PAM_TRY_AGAIN)
|
||||
- return retval;
|
||||
+ {
|
||||
+ if (retval == PAM_CONV_AGAIN)
|
||||
+ retval = PAM_INCOMPLETE;
|
||||
+ return retval;
|
||||
+ }
|
||||
tries++;
|
||||
|
||||
- if (newpass == NULL || retval == PAM_TRY_AGAIN)
|
||||
- continue;
|
||||
-
|
||||
if (options.debug)
|
||||
{
|
||||
if (newpass)
|
||||
@@ -201,12 +202,8 @@ pam_sm_chauthtok (pam_handle_t *pamh, in
|
||||
pam_syslog (pamh, LOG_DEBUG, "got no auth token");
|
||||
}
|
||||
|
||||
- if (retval != PAM_SUCCESS || newpass == NULL)
|
||||
- {
|
||||
- if (retval == PAM_CONV_AGAIN)
|
||||
- retval = PAM_INCOMPLETE;
|
||||
- return retval;
|
||||
- }
|
||||
+ if (newpass == NULL || retval == PAM_TRY_AGAIN)
|
||||
+ continue;
|
||||
|
||||
if (options.debug)
|
||||
pam_syslog (pamh, LOG_DEBUG, "check against old password file");
|
||||
@@ -219,7 +216,6 @@ pam_sm_chauthtok (pam_handle_t *pamh, in
|
||||
newpass = NULL;
|
||||
/* Remove password item, else following module will use it */
|
||||
pam_set_item (pamh, PAM_AUTHTOK, (void *) NULL);
|
||||
- continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,8 +226,7 @@ pam_sm_chauthtok (pam_handle_t *pamh, in
|
||||
return PAM_MAXTRIES;
|
||||
}
|
||||
|
||||
- /* Remember new password */
|
||||
- return pam_set_item (pamh, PAM_AUTHTOK, newpass);
|
||||
+ return PAM_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1,120 +0,0 @@
|
||||
Index: modules/pam_securetty/pam_securetty.8.xml
|
||||
===================================================================
|
||||
RCS file: /cvsroot/pam/Linux-PAM/modules/pam_securetty/pam_securetty.8.xml,v
|
||||
retrieving revision 1.4
|
||||
retrieving revision 1.6
|
||||
diff -u -p -r1.4 -r1.6
|
||||
--- modules/pam_securetty/pam_securetty.8.xml 18 Aug 2008 13:29:25 -0000 1.4
|
||||
+++ modules/pam_securetty/pam_securetty.8.xml 25 Nov 2010 16:58:59 -0000 1.6
|
||||
@@ -33,7 +33,9 @@
|
||||
user is logging in on a "secure" tty, as defined by the listing
|
||||
in <filename>/etc/securetty</filename>. pam_securetty also checks
|
||||
to make sure that <filename>/etc/securetty</filename> is a plain
|
||||
- file and not world writable.
|
||||
+ file and not world writable. It will also allow root logins on
|
||||
+ the tty specified with <option>console=</option> switch on the
|
||||
+ kernel command line.
|
||||
</para>
|
||||
<para>
|
||||
This module has no effect on non-root users and requires that the
|
||||
@@ -61,6 +63,18 @@
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
+ <varlistentry>
|
||||
+ <term>
|
||||
+ <option>noconsole</option>
|
||||
+ </term>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ Do not automatically allow root logins on the kernel console
|
||||
+ device, as specified on the kernel command line, if it is
|
||||
+ not also specified in the <filename>/etc/securetty</filename> file.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
+ </varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
Index: modules/pam_securetty/pam_securetty.c
|
||||
===================================================================
|
||||
RCS file: /cvsroot/pam/Linux-PAM/modules/pam_securetty/pam_securetty.c,v
|
||||
retrieving revision 1.14
|
||||
retrieving revision 1.15
|
||||
diff -u -p -r1.14 -r1.15
|
||||
--- modules/pam_securetty/pam_securetty.c 10 Sep 2009 10:19:58 -0000 1.14
|
||||
+++ modules/pam_securetty/pam_securetty.c 24 Nov 2010 12:28:01 -0000 1.15
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#define SECURETTY_FILE "/etc/securetty"
|
||||
#define TTY_PREFIX "/dev/"
|
||||
+#define CMDLINE_FILE "/proc/cmdline"
|
||||
|
||||
/*
|
||||
* by Elliot Lee <sopwith@redhat.com>, Red Hat Software.
|
||||
@@ -22,6 +23,7 @@
|
||||
#include <pwd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
+#include <limits.h>
|
||||
|
||||
/*
|
||||
* here, we make a definition for the externally accessible function
|
||||
@@ -38,6 +40,7 @@
|
||||
#include <security/pam_ext.h>
|
||||
|
||||
#define PAM_DEBUG_ARG 0x0001
|
||||
+#define PAM_NOCONSOLE_ARG 0x0002
|
||||
|
||||
static int
|
||||
_pam_parse (const pam_handle_t *pamh, int argc, const char **argv)
|
||||
@@ -51,6 +54,8 @@ _pam_parse (const pam_handle_t *pamh, in
|
||||
|
||||
if (!strcmp(*argv,"debug"))
|
||||
ctrl |= PAM_DEBUG_ARG;
|
||||
+ else if (!strcmp(*argv, "noconsole"))
|
||||
+ ctrl |= PAM_NOCONSOLE_ARG;
|
||||
else {
|
||||
pam_syslog(pamh, LOG_ERR, "unknown option: %s", *argv);
|
||||
}
|
||||
@@ -144,6 +149,40 @@ securetty_perform_check (pam_handle_t *p
|
||||
}
|
||||
fclose(ttyfile);
|
||||
|
||||
+ if (retval && !(ctrl & PAM_NOCONSOLE_ARG)) {
|
||||
+ FILE *cmdlinefile;
|
||||
+
|
||||
+ /* Allow access from the kernel console, if enabled */
|
||||
+ cmdlinefile = fopen(CMDLINE_FILE, "r");
|
||||
+
|
||||
+ if (cmdlinefile != NULL) {
|
||||
+ char line[LINE_MAX], *p;
|
||||
+
|
||||
+ line[0] = 0;
|
||||
+ fgets(line, sizeof(line), cmdlinefile);
|
||||
+ fclose(cmdlinefile);
|
||||
+
|
||||
+ for (p = line; p; p = strstr(p+1, "console=")) {
|
||||
+ char *e;
|
||||
+
|
||||
+ /* Test whether this is a beginning of a word? */
|
||||
+ if (p > line && p[-1] != ' ')
|
||||
+ continue;
|
||||
+
|
||||
+ /* Ist this our console? */
|
||||
+ if (strncmp(p + 8, uttyname, strlen(uttyname)))
|
||||
+ continue;
|
||||
+
|
||||
+ /* Is there any garbage after the TTY name? */
|
||||
+ e = p + 8 + strlen(uttyname);
|
||||
+ if (*e == ',' || *e == ' ' || *e == '\n' || *e == 0) {
|
||||
+ retval = 0;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (retval) {
|
||||
pam_syslog(pamh, LOG_WARNING, "access denied: tty '%s' is not secure !",
|
||||
uttyname);
|
17
pam.spec
17
pam.spec
@ -2,8 +2,8 @@
|
||||
|
||||
Summary: An extensible library which provides authentication for applications
|
||||
Name: pam
|
||||
Version: 1.1.3
|
||||
Release: 10%{?dist}
|
||||
Version: 1.1.4
|
||||
Release: 1%{?dist}
|
||||
# The library is BSD licensed with option to relicense as GPLv2+ - this option is redundant
|
||||
# as the BSD license allows that anyway. pam_timestamp and pam_console modules are GPLv2+,
|
||||
License: BSD and GPLv2+
|
||||
@ -35,11 +35,6 @@ Patch10: pam-1.1.3-nouserenv.patch
|
||||
Patch11: pam-1.1.3-console-abstract.patch
|
||||
Patch12: pam-1.1.3-faillock-screensaver.patch
|
||||
# Upstreamed patches
|
||||
Patch30: pam-1.1.3-securetty-console.patch
|
||||
Patch31: pam-1.1.3-limits-nosetreuid.patch
|
||||
Patch32: pam-1.1.3-limits-range.patch
|
||||
Patch33: pam-1.1.3-pwhistory-incomplete.patch
|
||||
Patch34: pam-1.1.3-namespace-private.patch
|
||||
|
||||
%define _sbindir /sbin
|
||||
%define _moduledir /%{_lib}/security
|
||||
@ -110,11 +105,6 @@ mv pam-redhat-%{pam_redhat_version}/* modules
|
||||
%patch10 -p1 -b .nouserenv
|
||||
%patch11 -p1 -b .abstract
|
||||
%patch12 -p1 -b .screensaver
|
||||
%patch30 -p0 -b .console
|
||||
%patch31 -p1 -b .nosetreuid
|
||||
%patch32 -p0 -b .range
|
||||
%patch33 -p1 -b .incomplete
|
||||
%patch34 -p1 -b .private
|
||||
|
||||
libtoolize -f
|
||||
autoreconf
|
||||
@ -369,6 +359,9 @@ fi
|
||||
%doc doc/adg/*.txt doc/adg/html
|
||||
|
||||
%changelog
|
||||
* Mon Jun 27 2011 Tomas Mraz <tmraz@redhat.com> 1.1.4-1
|
||||
- upgrade to new upstream release
|
||||
|
||||
* Tue Jun 7 2011 Tomas Mraz <tmraz@redhat.com> 1.1.3-10
|
||||
- detect the shared / and make the polydir mounts private based on that
|
||||
- fix memory leak and other small errors in pam_namespace
|
||||
|
Loading…
Reference in New Issue
Block a user