Compare commits
10 Commits
0ba69811a7
...
2185ee1d25
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2185ee1d25 | ||
|
|
dca3fb442d | ||
|
|
b9f52c02ce | ||
|
|
49b6ffb404 | ||
|
|
ba85ca0166 | ||
|
|
80bc1d16e6 | ||
|
|
8343161da6 | ||
|
|
32277c471c | ||
|
|
c8df76bafd | ||
|
|
7d546d2861 |
@ -347,7 +347,7 @@ index 0000000..a6be19b
|
|||||||
+#!/bin/sh
|
+#!/bin/sh
|
||||||
+
|
+
|
||||||
+# testcase1 modify password, desire password encrypt with sm3
|
+# testcase1 modify password, desire password encrypt with sm3
|
||||||
+/usr/sbin/useradd -p tstpamunix
|
+/usr/sbin/useradd tstpamunix
|
||||||
+# this run must successfully change the password
|
+# this run must successfully change the password
|
||||||
+./tst-pam_unix5 pass
|
+./tst-pam_unix5 pass
|
||||||
+RET=$?
|
+RET=$?
|
||||||
|
|||||||
@ -0,0 +1,79 @@
|
|||||||
|
From b7b96362087414e52524d3d9d9b3faa21e1db620 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tobias Stoeckmann <tobias@stoeckmann.org>
|
||||||
|
Date: Wed, 24 Jan 2024 18:57:42 +0100
|
||||||
|
Subject: [PATCH] pam_unix: try to set uid to 0 for unix_chkpwd
|
||||||
|
|
||||||
|
The geteuid check does not cover all cases. If a program runs with
|
||||||
|
elevated capabilities like CAP_SETUID then we can still check
|
||||||
|
credentials of other users.
|
||||||
|
|
||||||
|
Keep logging for future analysis though.
|
||||||
|
|
||||||
|
Resolves: https://github.com/linux-pam/linux-pam/issues/747
|
||||||
|
Fixes: b3020da7da38 ("pam_unix/passverify: always run the helper to obtain shadow password file entries")
|
||||||
|
|
||||||
|
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
|
||||||
|
|
||||||
|
Conflict:NA
|
||||||
|
Reference:https://github.com/linux-pam/linux-pam/commit/b7b96362087414e52524d3d9d9b3faa21e1db620
|
||||||
|
---
|
||||||
|
modules/pam_unix/pam_unix_acct.c | 17 +++++++++--------
|
||||||
|
modules/pam_unix/support.c | 14 +++++++-------
|
||||||
|
2 files changed, 16 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/modules/pam_unix/pam_unix_acct.c b/modules/pam_unix/pam_unix_acct.c
|
||||||
|
index 8f5ed3e..7ffcb9e 100644
|
||||||
|
--- a/modules/pam_unix/pam_unix_acct.c
|
||||||
|
+++ b/modules/pam_unix/pam_unix_acct.c
|
||||||
|
@@ -110,14 +110,15 @@ int _unix_run_verify_binary(pam_handle_t *pamh, unsigned long long ctrl,
|
||||||
|
_exit(PAM_AUTHINFO_UNAVAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (geteuid() == 0) {
|
||||||
|
- /* must set the real uid to 0 so the helper will not error
|
||||||
|
- out if pam is called from setuid binary (su, sudo...) */
|
||||||
|
- if (setuid(0) == -1) {
|
||||||
|
- pam_syslog(pamh, LOG_ERR, "setuid failed: %m");
|
||||||
|
- printf("-1\n");
|
||||||
|
- fflush(stdout);
|
||||||
|
- _exit(PAM_AUTHINFO_UNAVAIL);
|
||||||
|
+ /* must set the real uid to 0 so the helper will not error
|
||||||
|
+ out if pam is called from setuid binary (su, sudo...) */
|
||||||
|
+ if (setuid(0) == -1) {
|
||||||
|
+ uid_t euid = geteuid();
|
||||||
|
+ pam_syslog(pamh, euid == 0 ? LOG_ERR : LOG_DEBUG, "setuid failed: %m");
|
||||||
|
+ if (euid == 0) {
|
||||||
|
+ printf("-1\n");
|
||||||
|
+ fflush(stdout);
|
||||||
|
+ _exit(PAM_AUTHINFO_UNAVAIL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c
|
||||||
|
index 4052868..ff46155 100644
|
||||||
|
--- a/modules/pam_unix/support.c
|
||||||
|
+++ b/modules/pam_unix/support.c
|
||||||
|
@@ -513,13 +513,13 @@ static int _unix_run_helper_binary(pam_handle_t *pamh, const char *passwd,
|
||||||
|
_exit(PAM_AUTHINFO_UNAVAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (geteuid() == 0) {
|
||||||
|
- /* must set the real uid to 0 so the helper will not error
|
||||||
|
- out if pam is called from setuid binary (su, sudo...) */
|
||||||
|
- if (setuid(0) == -1) {
|
||||||
|
- D(("setuid failed"));
|
||||||
|
- _exit(PAM_AUTHINFO_UNAVAIL);
|
||||||
|
- }
|
||||||
|
+ /* must set the real uid to 0 so the helper will not error
|
||||||
|
+ out if pam is called from setuid binary (su, sudo...) */
|
||||||
|
+ if (setuid(0) == -1) {
|
||||||
|
+ D(("setuid failed"));
|
||||||
|
+ if (geteuid() == 0) {
|
||||||
|
+ _exit(PAM_AUTHINFO_UNAVAIL);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* exec binary helper */
|
||||||
|
--
|
||||||
|
2.46.0
|
||||||
|
|
||||||
95
backport-CVE-2024-10041.patch
Normal file
95
backport-CVE-2024-10041.patch
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
From b3020da7da384d769f27a8713257fbe1001878be Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Dmitry V. Levin" <ldv@strace.io>
|
||||||
|
Date: Mon, 1 Jan 2024 12:00:00 +0000
|
||||||
|
Subject: [PATCH] pam_unix/passverify: always run the helper to obtain shadow
|
||||||
|
password file entries
|
||||||
|
|
||||||
|
Initially, when pam_unix.so verified the password, it used to try to
|
||||||
|
obtain the shadow password file entry for the given user by invoking
|
||||||
|
getspnam(3), and only when that didn't work and the effective uid
|
||||||
|
was nonzero, pam_unix.so used to invoke the helper as a fallback.
|
||||||
|
|
||||||
|
When SELinux support was introduced by commit
|
||||||
|
67aab1ff5515054341a438cf9804e9c9b3a88033, the fallback was extended
|
||||||
|
also for the case when SELinux was enabled.
|
||||||
|
|
||||||
|
Later, commit f220cace205332a3dc34e7b37a85e7627e097e7d extended the
|
||||||
|
fallback conditions for the case when pam_modutil_getspnam() failed
|
||||||
|
with EACCES.
|
||||||
|
|
||||||
|
Since commit 470823c4aacef5cb3b1180be6ed70846b61a3752, the helper is
|
||||||
|
invoked as a fallback when pam_modutil_getspnam() fails for any reason.
|
||||||
|
|
||||||
|
The ultimate solution for the case when pam_unix.so does not have
|
||||||
|
permissions to obtain the shadow password file entry is to stop trying
|
||||||
|
to use pam_modutil_getspnam() and to invoke the helper instead.
|
||||||
|
Here are two recent examples.
|
||||||
|
|
||||||
|
https://github.com/linux-pam/linux-pam/pull/484 describes a system
|
||||||
|
configuration where libnss_systemd is enabled along with libnss_files
|
||||||
|
in the shadow entry of nsswitch.conf, so when libnss_files is unable
|
||||||
|
to obtain the shadow password file entry for the root user, e.g. when
|
||||||
|
SELinux is enabled, NSS falls back to libnss_systemd which returns
|
||||||
|
a synthesized shadow password file entry for the root user, which
|
||||||
|
in turn locks the root user out.
|
||||||
|
|
||||||
|
https://bugzilla.redhat.com/show_bug.cgi?id=2150155 describes
|
||||||
|
essentially the same problem in a similar system configuration.
|
||||||
|
|
||||||
|
This commit is the final step in the direction of addressing the issue:
|
||||||
|
for password verification pam_unix.so now invokes the helper instead of
|
||||||
|
making the pam_modutil_getspnam() call.
|
||||||
|
|
||||||
|
* modules/pam_unix/passverify.c (get_account_info) [!HELPER_COMPILE]:
|
||||||
|
Always return PAM_UNIX_RUN_HELPER instead of trying to obtain
|
||||||
|
the shadow password file entry.
|
||||||
|
|
||||||
|
Complements: https://github.com/linux-pam/linux-pam/pull/386
|
||||||
|
Resolves: https://github.com/linux-pam/linux-pam/pull/484
|
||||||
|
Link: https://github.com/authselect/authselect/commit/1e78f7e048747024a846fd22d68afc6993734e92
|
||||||
|
|
||||||
|
Conflict:NA
|
||||||
|
Reference:https://github.com/linux-pam/linux-pam/commit/b3020da7da384d769f27a8713257fbe1001878be
|
||||||
|
---
|
||||||
|
modules/pam_unix/passverify.c | 21 +++++++++++----------
|
||||||
|
1 file changed, 11 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/modules/pam_unix/passverify.c b/modules/pam_unix/passverify.c
|
||||||
|
index 1aee153..9f349e5 100644
|
||||||
|
--- a/modules/pam_unix/passverify.c
|
||||||
|
+++ b/modules/pam_unix/passverify.c
|
||||||
|
@@ -237,20 +237,21 @@ PAMH_ARG_DECL(int get_account_info,
|
||||||
|
return PAM_UNIX_RUN_HELPER;
|
||||||
|
#endif
|
||||||
|
} else if (is_pwd_shadowed(*pwd)) {
|
||||||
|
+#ifdef HELPER_COMPILE
|
||||||
|
/*
|
||||||
|
- * ...and shadow password file entry for this user,
|
||||||
|
+ * shadow password file entry for this user,
|
||||||
|
* if shadowing is enabled
|
||||||
|
*/
|
||||||
|
- *spwdent = pam_modutil_getspnam(pamh, name);
|
||||||
|
- if (*spwdent == NULL) {
|
||||||
|
-#ifndef HELPER_COMPILE
|
||||||
|
- /* still a chance the user can authenticate */
|
||||||
|
- return PAM_UNIX_RUN_HELPER;
|
||||||
|
-#endif
|
||||||
|
- return PAM_AUTHINFO_UNAVAIL;
|
||||||
|
- }
|
||||||
|
- if ((*spwdent)->sp_pwdp == NULL)
|
||||||
|
+ *spwdent = getspnam(name);
|
||||||
|
+ if (*spwdent == NULL || (*spwdent)->sp_pwdp == NULL)
|
||||||
|
return PAM_AUTHINFO_UNAVAIL;
|
||||||
|
+#else
|
||||||
|
+ /*
|
||||||
|
+ * The helper has to be invoked to deal with
|
||||||
|
+ * the shadow password file entry.
|
||||||
|
+ */
|
||||||
|
+ return PAM_UNIX_RUN_HELPER;
|
||||||
|
+#endif
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return PAM_USER_UNKNOWN;
|
||||||
|
--
|
||||||
|
2.46.0
|
||||||
|
|
||||||
228
backport-CVE-2024-10963.patch
Normal file
228
backport-CVE-2024-10963.patch
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
From 940747f88c16e029b69a74e80a2e94f65cb3e628 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Thorsten Kukuk <kukuk@suse.com>
|
||||||
|
Date: Thu, 14 Nov 2024 10:27:28 +0100
|
||||||
|
Subject: [PATCH] pam_access: rework resolving of tokens as hostname
|
||||||
|
|
||||||
|
Conflict:Context adaptation
|
||||||
|
Reference:https://github.com/linux-pam/linux-pam/commit/940747f88c16e029b69a74e80a2e94f65cb3e628
|
||||||
|
|
||||||
|
* modules/pam_access/pam_access.c: separate resolving of IP addresses
|
||||||
|
from hostnames. Don't resolve TTYs or display variables as hostname
|
||||||
|
(#834).
|
||||||
|
Add "nodns" option to disallow resolving of tokens as hostname.
|
||||||
|
* modules/pam_access/pam_access.8.xml: document nodns option
|
||||||
|
* modules/pam_access/access.conf.5.xml: document that hostnames should
|
||||||
|
be written as FQHN.
|
||||||
|
---
|
||||||
|
modules/pam_access/access.conf.5.xml | 4 ++
|
||||||
|
modules/pam_access/pam_access.8.xml | 46 ++++++++++++------
|
||||||
|
modules/pam_access/pam_access.c | 72 +++++++++++++++++++++++++++-
|
||||||
|
3 files changed, 105 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/modules/pam_access/access.conf.5.xml b/modules/pam_access/access.conf.5.xml
|
||||||
|
index 0b93db00..10b8ba92 100644
|
||||||
|
--- a/modules/pam_access/access.conf.5.xml
|
||||||
|
+++ b/modules/pam_access/access.conf.5.xml
|
||||||
|
@@ -226,6 +226,10 @@
|
||||||
|
item and the line will be most probably ignored. For this reason, it is not
|
||||||
|
recommended to put spaces around the ':' characters.
|
||||||
|
</para>
|
||||||
|
+ <para>
|
||||||
|
+ Hostnames should be written as Fully-Qualified Host Name (FQHN) to avoid
|
||||||
|
+ confusion with device names or PAM service names.
|
||||||
|
+ </para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 xml:id="access.conf-see_also">
|
||||||
|
diff --git a/modules/pam_access/pam_access.8.xml b/modules/pam_access/pam_access.8.xml
|
||||||
|
index c991d7a0..71a4f7ee 100644
|
||||||
|
--- a/modules/pam_access/pam_access.8.xml
|
||||||
|
+++ b/modules/pam_access/pam_access.8.xml
|
||||||
|
@@ -25,11 +25,14 @@
|
||||||
|
<arg choice="opt" rep="norepeat">
|
||||||
|
debug
|
||||||
|
</arg>
|
||||||
|
+ <arg choice="opt" rep="norepeat">
|
||||||
|
+ noaudit
|
||||||
|
+ </arg>
|
||||||
|
<arg choice="opt" rep="norepeat">
|
||||||
|
nodefgroup
|
||||||
|
</arg>
|
||||||
|
<arg choice="opt" rep="norepeat">
|
||||||
|
- noaudit
|
||||||
|
+ nodns
|
||||||
|
</arg>
|
||||||
|
<arg choice="opt" rep="norepeat">
|
||||||
|
accessfile=<replaceable>file</replaceable>
|
||||||
|
@@ -112,6 +115,33 @@
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
+ <varlistentry>
|
||||||
|
+ <term>
|
||||||
|
+ nodefgroup
|
||||||
|
+ </term>
|
||||||
|
+ <listitem>
|
||||||
|
+ <para>
|
||||||
|
+ User tokens which are not enclosed in parentheses will not be
|
||||||
|
+ matched against the group database. The backwards compatible default is
|
||||||
|
+ to try the group database match even for tokens not enclosed
|
||||||
|
+ in parentheses.
|
||||||
|
+ </para>
|
||||||
|
+ </listitem>
|
||||||
|
+ </varlistentry>
|
||||||
|
+
|
||||||
|
+ <varlistentry>
|
||||||
|
+ <term>
|
||||||
|
+ nodns
|
||||||
|
+ </term>
|
||||||
|
+ <listitem>
|
||||||
|
+ <para>
|
||||||
|
+ Do not try to resolve tokens as hostnames, only IPv4 and IPv6
|
||||||
|
+ addresses will be resolved. Which means to allow login from a
|
||||||
|
+ remote host, the IP addresses need to be specified in <filename>access.conf</filename>.
|
||||||
|
+ </para>
|
||||||
|
+ </listitem>
|
||||||
|
+ </varlistentry>
|
||||||
|
+
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
fieldsep=separators
|
||||||
|
@@ -153,20 +183,6 @@
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
- <varlistentry>
|
||||||
|
- <term>
|
||||||
|
- nodefgroup
|
||||||
|
- </term>
|
||||||
|
- <listitem>
|
||||||
|
- <para>
|
||||||
|
- User tokens which are not enclosed in parentheses will not be
|
||||||
|
- matched against the group database. The backwards compatible default is
|
||||||
|
- to try the group database match even for tokens not enclosed
|
||||||
|
- in parentheses.
|
||||||
|
- </para>
|
||||||
|
- </listitem>
|
||||||
|
- </varlistentry>
|
||||||
|
-
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
diff --git a/modules/pam_access/pam_access.c b/modules/pam_access/pam_access.c
|
||||||
|
index 48e7c7e9..109115e9 100644
|
||||||
|
--- a/modules/pam_access/pam_access.c
|
||||||
|
+++ b/modules/pam_access/pam_access.c
|
||||||
|
@@ -92,6 +92,7 @@ struct login_info {
|
||||||
|
int debug; /* Print debugging messages. */
|
||||||
|
int only_new_group_syntax; /* Only allow group entries of the form "(xyz)" */
|
||||||
|
int noaudit; /* Do not audit denials */
|
||||||
|
+ int nodns; /* Do not try to resolve tokens as hostnames */
|
||||||
|
const char *fs; /* field separator */
|
||||||
|
const char *sep; /* list-element separator */
|
||||||
|
int from_remote_host; /* If PAM_RHOST was used for from */
|
||||||
|
@@ -143,6 +144,8 @@ parse_args(pam_handle_t *pamh, struct login_info *loginfo,
|
||||||
|
loginfo->only_new_group_syntax = YES;
|
||||||
|
} else if (strcmp (argv[i], "noaudit") == 0) {
|
||||||
|
loginfo->noaudit = YES;
|
||||||
|
+ } else if (strcmp (argv[i], "nodns") == 0) {
|
||||||
|
+ loginfo->nodns = YES;
|
||||||
|
} else {
|
||||||
|
pam_syslog(pamh, LOG_ERR, "unrecognized option [%s]", argv[i]);
|
||||||
|
}
|
||||||
|
@@ -637,7 +640,7 @@ remote_match (pam_handle_t *pamh, char *tok, struct login_info *item)
|
||||||
|
if ((str_len = strlen(string)) > tok_len
|
||||||
|
&& strcasecmp(tok, string + str_len - tok_len) == 0)
|
||||||
|
return YES;
|
||||||
|
- } else if (tok[tok_len - 1] == '.') { /* internet network numbers (end with ".") */
|
||||||
|
+ } else if (tok[tok_len - 1] == '.') { /* internet network numbers/subnet (end with ".") */
|
||||||
|
struct addrinfo hint;
|
||||||
|
|
||||||
|
memset (&hint, '\0', sizeof (hint));
|
||||||
|
@@ -712,6 +715,39 @@ string_match (pam_handle_t *pamh, const char *tok, const char *string,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+static int
|
||||||
|
+is_device (pam_handle_t *pamh, const char *tok)
|
||||||
|
+{
|
||||||
|
+ struct stat st;
|
||||||
|
+ const char *dev = "/dev/";
|
||||||
|
+ char *devname;
|
||||||
|
+
|
||||||
|
+ devname = malloc (strlen(dev) + strlen (tok) + 1);
|
||||||
|
+ if (devname == NULL) {
|
||||||
|
+ pam_syslog(pamh, LOG_ERR, "Cannot allocate memory for device name: %m");
|
||||||
|
+ /*
|
||||||
|
+ * We should return an error and abort, but pam_access has no good
|
||||||
|
+ * error handling.
|
||||||
|
+ */
|
||||||
|
+ return NO;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ char *cp = stpcpy (devname, dev);
|
||||||
|
+ strcpy (cp, tok);
|
||||||
|
+
|
||||||
|
+ if (lstat(devname, &st) != 0)
|
||||||
|
+ {
|
||||||
|
+ free (devname);
|
||||||
|
+ return NO;
|
||||||
|
+ }
|
||||||
|
+ free (devname);
|
||||||
|
+
|
||||||
|
+ if (S_ISCHR(st.st_mode))
|
||||||
|
+ return YES;
|
||||||
|
+
|
||||||
|
+ return NO;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* network_netmask_match - match a string against one token
|
||||||
|
* where string is a hostname or ip (v4,v6) address and tok
|
||||||
|
* represents either a hostname, a single ip (v4,v6) address
|
||||||
|
@@ -773,10 +809,42 @@ network_netmask_match (pam_handle_t *pamh,
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ else if (isipaddr(tok, NULL, NULL) == YES)
|
||||||
|
+ {
|
||||||
|
+ if (getaddrinfo (tok, NULL, NULL, &ai) != 0)
|
||||||
|
+ {
|
||||||
|
+ if (item->debug)
|
||||||
|
+ pam_syslog(pamh, LOG_DEBUG, "cannot resolve IP address \"%s\"", tok);
|
||||||
|
+
|
||||||
|
+ return NO;
|
||||||
|
+ }
|
||||||
|
+ netmask_ptr = NULL;
|
||||||
|
+ }
|
||||||
|
+ else if (item->nodns)
|
||||||
|
+ {
|
||||||
|
+ /* Only hostnames are left, which we would need to resolve via DNS */
|
||||||
|
+ return NO;
|
||||||
|
+ }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
+ /* Bail out on X11 Display entries and ttys. */
|
||||||
|
+ if (tok[0] == ':')
|
||||||
|
+ {
|
||||||
|
+ if (item->debug)
|
||||||
|
+ pam_syslog (pamh, LOG_DEBUG,
|
||||||
|
+ "network_netmask_match: tok=%s is X11 display", tok);
|
||||||
|
+ return NO;
|
||||||
|
+ }
|
||||||
|
+ if (is_device (pamh, tok))
|
||||||
|
+ {
|
||||||
|
+ if (item->debug)
|
||||||
|
+ pam_syslog (pamh, LOG_DEBUG,
|
||||||
|
+ "network_netmask_match: tok=%s is a TTY", tok);
|
||||||
|
+ return NO;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
- * It is either an IP address or a hostname.
|
||||||
|
+ * It is most likely a hostname.
|
||||||
|
* Let getaddrinfo sort everything out
|
||||||
|
*/
|
||||||
|
if (getaddrinfo (tok, NULL, NULL, &ai) != 0)
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
From d6103b30050554d7b6ca6d55cb5b4ed3c9516663 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Iker Pedrosa <ipedrosa@redhat.com>
|
||||||
|
Date: Wed, 25 Oct 2023 09:46:15 +0200
|
||||||
|
Subject: [PATCH] libpam: use close_range() to close file descriptors
|
||||||
|
|
||||||
|
* configure.ac: check whether close_range() is available in the system.
|
||||||
|
* libpam/pam_modutil_sanitize.c: use close_range() to close all file
|
||||||
|
descriptors. If the interface isn't available use the previous
|
||||||
|
approach.
|
||||||
|
|
||||||
|
Link: https://github.com/linux-pam/linux-pam/pull/276
|
||||||
|
Resolves: https://issues.redhat.com/browse/RHEL-5099
|
||||||
|
|
||||||
|
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
|
||||||
|
|
||||||
|
Conflict:NA
|
||||||
|
Reference:https://github.com/linux-pam/linux-pam/commit/d6103b30050554d7b6ca6d55cb5b4ed3c9516663
|
||||||
|
|
||||||
|
---
|
||||||
|
configure.ac | 1 +
|
||||||
|
libpam/pam_modutil_sanitize.c | 19 +++++++++++++++++--
|
||||||
|
2 files changed, 18 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/configure.ac b/configure.ac
|
||||||
|
index 39124d87..b6a8d6fb 100644
|
||||||
|
--- a/configure.ac
|
||||||
|
+++ b/configure.ac
|
||||||
|
@@ -638,6 +638,7 @@ AC_CHECK_FUNCS(quotactl)
|
||||||
|
AC_CHECK_FUNCS(unshare)
|
||||||
|
AC_CHECK_FUNCS(explicit_bzero memset_explicit)
|
||||||
|
AC_CHECK_FUNCS([ruserok_af ruserok], [break])
|
||||||
|
+AC_CHECK_FUNCS(close_range)
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([regenerate-docu],
|
||||||
|
AS_HELP_STRING([--disable-regenerate-docu],[Don't re-build documentation from XML sources]),
|
||||||
|
diff --git a/libpam/pam_modutil_sanitize.c b/libpam/pam_modutil_sanitize.c
|
||||||
|
index f26e8ec0..1b8af743 100644
|
||||||
|
--- a/libpam/pam_modutil_sanitize.c
|
||||||
|
+++ b/libpam/pam_modutil_sanitize.c
|
||||||
|
@@ -11,6 +11,10 @@
|
||||||
|
#include <syslog.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
|
+#ifndef CLOSE_RANGE_UNSHARE
|
||||||
|
+#define CLOSE_RANGE_UNSHARE (1U << 1)
|
||||||
|
+#endif /* CLOSE_RANGE_UNSHARE */
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Creates a pipe, closes its write end, redirects fd to its read end.
|
||||||
|
* Returns fd on success, -1 otherwise.
|
||||||
|
@@ -84,9 +88,8 @@ redirect_out(pam_handle_t *pamh, enum pam_modutil_redirect_fd mode,
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
-/* Closes all descriptors after stderr. */
|
||||||
|
static void
|
||||||
|
-close_fds(void)
|
||||||
|
+close_fds_iteratively(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* An arbitrary upper limit for the maximum file descriptor number
|
||||||
|
@@ -111,6 +114,18 @@ close_fds(void)
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Closes all descriptors after stderr. */
|
||||||
|
+static void
|
||||||
|
+close_fds(void)
|
||||||
|
+{
|
||||||
|
+#ifdef HAVE_CLOSE_RANGE
|
||||||
|
+ if (close_range(STDERR_FILENO+1, -1U, CLOSE_RANGE_UNSHARE) == 0)
|
||||||
|
+ return;
|
||||||
|
+#endif /* HAVE_CLOSE_RANGE */
|
||||||
|
+
|
||||||
|
+ close_fds_iteratively();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int
|
||||||
|
pam_modutil_sanitize_helper_fds(pam_handle_t *pamh,
|
||||||
|
enum pam_modutil_redirect_fd stdin_mode,
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
From 741acf4ff707d53b94947736a01eeeda5e2c7e98 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Thorsten Kukuk <kukuk@suse.com>
|
||||||
|
Date: Fri, 4 Aug 2023 15:46:16 +0200
|
||||||
|
Subject: [PATCH] pam_access: make non-resolveable hostname a debug output
|
||||||
|
(#590)
|
||||||
|
|
||||||
|
Conflict:NA
|
||||||
|
Reference:https://github.com/linux-pam/linux-pam/commit/741acf4ff707d53b94947736a01eeeda5e2c7e98
|
||||||
|
|
||||||
|
* modules/pam_access/pam_access.c (network_netmask_match): Don't print
|
||||||
|
an error if a string is not resolveable, only a debug message in debug
|
||||||
|
mode. We even don't know if that entry is for remote logins or not.
|
||||||
|
---
|
||||||
|
modules/pam_access/pam_access.c | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/modules/pam_access/pam_access.c b/modules/pam_access/pam_access.c
|
||||||
|
index f70b7e49..985dc7de 100644
|
||||||
|
--- a/modules/pam_access/pam_access.c
|
||||||
|
+++ b/modules/pam_access/pam_access.c
|
||||||
|
@@ -876,7 +876,8 @@ network_netmask_match (pam_handle_t *pamh,
|
||||||
|
*/
|
||||||
|
if (getaddrinfo (tok, NULL, NULL, &ai) != 0)
|
||||||
|
{
|
||||||
|
- pam_syslog(pamh, LOG_ERR, "cannot resolve hostname \"%s\"", tok);
|
||||||
|
+ if (item->debug)
|
||||||
|
+ pam_syslog(pamh, LOG_DEBUG, "cannot resolve hostname \"%s\"", tok);
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
27
pam.spec
27
pam.spec
@ -4,7 +4,7 @@
|
|||||||
%define _pamconfdir %{_sysconfdir}/pam.d
|
%define _pamconfdir %{_sysconfdir}/pam.d
|
||||||
Name: pam
|
Name: pam
|
||||||
Version: 1.5.3
|
Version: 1.5.3
|
||||||
Release: 3
|
Release: 8
|
||||||
Summary: Pluggable Authentication Modules for Linux
|
Summary: Pluggable Authentication Modules for Linux
|
||||||
License: BSD and GPLv2+
|
License: BSD and GPLv2+
|
||||||
URL: http://www.linux-pam.org/
|
URL: http://www.linux-pam.org/
|
||||||
@ -23,6 +23,11 @@ Provides: %{name}-sm3 = %{version}-%{release}
|
|||||||
Patch1: bugfix-pam-1.1.8-faillock-systemtime.patch
|
Patch1: bugfix-pam-1.1.8-faillock-systemtime.patch
|
||||||
Patch2: backport-CVE-2024-22365-pam_namespace-protect_dir-use-O_DIRECTORY-to-prevent.patch
|
Patch2: backport-CVE-2024-22365-pam_namespace-protect_dir-use-O_DIRECTORY-to-prevent.patch
|
||||||
Patch3: backport-pam_pwhistory-fix-passing-NULL-filename-argument-to-pwhistory-helper.patch
|
Patch3: backport-pam_pwhistory-fix-passing-NULL-filename-argument-to-pwhistory-helper.patch
|
||||||
|
Patch4: backport-pam_access-make-non-resolveable-hostname-a-debug-out.patch
|
||||||
|
Patch5: backport-CVE-2024-10963.patch
|
||||||
|
Patch6: backport-CVE-2024-10041.patch
|
||||||
|
Patch7: backport-CVE-2024-10041-pam_unix-try-to-set-uid-to-0-for-unix_chkpwd.patch
|
||||||
|
Patch8: backport-libpam-use-close_range-to-close-file-descriptors.patch
|
||||||
|
|
||||||
Patch9000:change-ndbm-to-gdbm.patch
|
Patch9000:change-ndbm-to-gdbm.patch
|
||||||
Patch9001:add-sm3-crypt-support.patch
|
Patch9001:add-sm3-crypt-support.patch
|
||||||
@ -94,7 +99,6 @@ install -m 644 %{SOURCE10} $RPM_BUILD_ROOT%{_pamconfdir}/config-util
|
|||||||
install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_pamconfdir}/postlogin
|
install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_pamconfdir}/postlogin
|
||||||
install -m 600 /dev/null $RPM_BUILD_ROOT%{_secconfdir}/opasswd
|
install -m 600 /dev/null $RPM_BUILD_ROOT%{_secconfdir}/opasswd
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/var/log
|
install -d -m 755 $RPM_BUILD_ROOT/var/log
|
||||||
install -m 600 /dev/null $RPM_BUILD_ROOT/var/log/tallylog
|
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/var/run/faillock
|
install -d -m 755 $RPM_BUILD_ROOT/var/run/faillock
|
||||||
|
|
||||||
for phase in auth acct passwd session ; do
|
for phase in auth acct passwd session ; do
|
||||||
@ -113,9 +117,6 @@ make check
|
|||||||
|
|
||||||
%post
|
%post
|
||||||
/sbin/ldconfig
|
/sbin/ldconfig
|
||||||
if [ ! -e /var/log/tallylog ] ; then
|
|
||||||
/usr/bin/install -m 600 /dev/null /var/log/tallylog || :
|
|
||||||
fi
|
|
||||||
|
|
||||||
%postun -p /sbin/ldconfig
|
%postun -p /sbin/ldconfig
|
||||||
|
|
||||||
@ -160,7 +161,6 @@ fi
|
|||||||
%config(noreplace) %{_secconfdir}/faillock.conf
|
%config(noreplace) %{_secconfdir}/faillock.conf
|
||||||
%config(noreplace) %{_secconfdir}/pwhistory.conf
|
%config(noreplace) %{_secconfdir}/pwhistory.conf
|
||||||
%dir /var/run/sepermit
|
%dir /var/run/sepermit
|
||||||
%ghost %verify(not md5 size mtime) /var/log/tallylog
|
|
||||||
%dir /var/run/faillock
|
%dir /var/run/faillock
|
||||||
%{_prefix}/lib/tmpfiles.d/pam.conf
|
%{_prefix}/lib/tmpfiles.d/pam.conf
|
||||||
|
|
||||||
@ -182,6 +182,21 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Mar 24 2025 hugel <gengqihu2@h-partners.com> - 1.5.3-8
|
||||||
|
- backport patch libpam use close_range() to close file descriptors
|
||||||
|
|
||||||
|
* Fri Dec 27 2024 dongyuzhen <dongyuzhen@h-partners.com> - 1.5.3-7
|
||||||
|
- fix tst-pam_unix5 test case failure
|
||||||
|
|
||||||
|
* Tue Dec 17 2024 dongyuzhen <dongyuzhen@h-partners.com> - 1.5.3-6
|
||||||
|
- fix CVE-2024-10041
|
||||||
|
|
||||||
|
* Fri Nov 29 2024 hugel <gengqihu2@h-partners.com> - 1.5.3-5
|
||||||
|
- fix CVE-2024-10963
|
||||||
|
|
||||||
|
* Thu May 9 2024 dongyuzhen <dongyuzhen@h-partners.com> - 1.5.3-4
|
||||||
|
- remove redundant /var/log/tallylog file
|
||||||
|
|
||||||
* Mon Apr 29 2024 zhengxiaoxiao <zhengxiaoxiao2@huawei.com> - 1.5.3-3
|
* Mon Apr 29 2024 zhengxiaoxiao <zhengxiaoxiao2@huawei.com> - 1.5.3-3
|
||||||
- add backport-pam_pwhistory-fix-passing-NULL-filename-argument-to-pwhistory-helper.patch
|
- add backport-pam_pwhistory-fix-passing-NULL-filename-argument-to-pwhistory-helper.patch
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user