commit:     6c8f42e4b5218feb58c545dec9117386fcce195a
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 18 02:57:30 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 18 02:57:30 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6c8f42e4

sys-libs/pam: pull in 32-bit fixes for 1.7.1

Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-libs/pam/files/pam-1.7.1-32-bit-lastlog.patch  | 37 ++++++++++++++++++++++
 .../pam/files/pam-1.7.1-32-bit-timestamp.patch     | 37 ++++++++++++++++++++++
 sys-libs/pam/pam-1.7.1.ebuild                      |  5 +++
 3 files changed, 79 insertions(+)

diff --git a/sys-libs/pam/files/pam-1.7.1-32-bit-lastlog.patch 
b/sys-libs/pam/files/pam-1.7.1-32-bit-lastlog.patch
new file mode 100644
index 000000000000..c27f9a6459a1
--- /dev/null
+++ b/sys-libs/pam/files/pam-1.7.1-32-bit-lastlog.patch
@@ -0,0 +1,37 @@
+https://github.com/linux-pam/linux-pam/commit/4176cf25a3ae8b5fd2956b41b068221b39932c3a
+
+From 4176cf25a3ae8b5fd2956b41b068221b39932c3a Mon Sep 17 00:00:00 2001
+From: "Dmitry V. Levin" <[email protected]>
+Date: Tue, 17 Jun 2025 13:00:00 +0000
+Subject: [PATCH] pam_lastlog: fix compilation warning on some of 32-bit
+ architectures
+
+On those of 32-bit architectures where glibc defines
+__WORDSIZE_TIME64_COMPAT32, struct utmp.ut_tv.tv_sec is unsigned,
+while time_t is signed, causing the following compiler diagnostics:
+
+  pam_lastlog.c: In function 'last_login_failed':
+  pam_lastlog.c:572:29: warning: comparison of integer expressions of 
different signedness: '__uint32_t' {aka 'unsigned int'} and 'time_t' {aka 'long 
int'} [-Wsign-compare]
+  572 |         if (ut.ut_tv.tv_sec >= lltime && strncmp(ut.ut_user, user, 
UT_NAMESIZE) == 0) {
+
+Given that by its nature these values are treated as unsigned, fix this
+by zero-extending both values to unsigned long long before the comparison.
+---
+ modules/pam_lastlog/pam_lastlog.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/modules/pam_lastlog/pam_lastlog.c 
b/modules/pam_lastlog/pam_lastlog.c
+index 01545a696..c68b5fb04 100644
+--- a/modules/pam_lastlog/pam_lastlog.c
++++ b/modules/pam_lastlog/pam_lastlog.c
+@@ -569,7 +569,8 @@ last_login_failed(pam_handle_t *pamh, int announce, const 
char *user, time_t llt
+ 
+     while ((retval=pam_modutil_read(fd, (void *)&ut,
+                        sizeof(ut))) == sizeof(ut)) {
+-      if (ut.ut_tv.tv_sec >= lltime && strncmp(ut.ut_user, user, UT_NAMESIZE) 
== 0) {
++      if (zero_extend_signed_to_ull(ut.ut_tv.tv_sec) >= 
zero_extend_signed_to_ull(lltime)
++          && strncmp(ut.ut_user, user, UT_NAMESIZE) == 0) {
+           memcpy(&utuser, &ut, sizeof(utuser));
+           failed++;
+       }
+

diff --git a/sys-libs/pam/files/pam-1.7.1-32-bit-timestamp.patch 
b/sys-libs/pam/files/pam-1.7.1-32-bit-timestamp.patch
new file mode 100644
index 000000000000..e0e12cc313db
--- /dev/null
+++ b/sys-libs/pam/files/pam-1.7.1-32-bit-timestamp.patch
@@ -0,0 +1,37 @@
+https://github.com/linux-pam/linux-pam/commit/e3b66a60e4209e019cf6a45f521858cec2dbefa1
+
+From e3b66a60e4209e019cf6a45f521858cec2dbefa1 Mon Sep 17 00:00:00 2001
+From: "Dmitry V. Levin" <[email protected]>
+Date: Tue, 17 Jun 2025 13:00:00 +0000
+Subject: [PATCH] pam_timestamp: fix compilation warning on some of 32-bit
+ architectures
+
+On those of 32-bit architectures where glibc defines
+__WORDSIZE_TIME64_COMPAT32, struct utmp.ut_tv.tv_sec is unsigned,
+while time_t is signed, causing the following compiler diagnostics:
+
+  pam_timestamp.c: In function 'check_login_time':
+  pam_timestamp.c:247:55: warning: comparison of integer expressions of 
different signedness: 'time_t' {aka 'long int'} and '__uint32_t' {aka 'unsigned 
int'} [-Wsign-compare]
+  247 |                 if (oldest_login == 0 || oldest_login > 
ut->ut_tv.tv_sec) {
+
+Given that by its nature these values are treated as unsigned, fix this
+by zero-extending both values to unsigned long long before the comparison.
+---
+ modules/pam_timestamp/pam_timestamp.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/modules/pam_timestamp/pam_timestamp.c 
b/modules/pam_timestamp/pam_timestamp.c
+index 0172d1ef9..030fa2b8f 100644
+--- a/modules/pam_timestamp/pam_timestamp.c
++++ b/modules/pam_timestamp/pam_timestamp.c
+@@ -244,7 +244,9 @@ check_login_time(
+               if (strncmp(ruser, ut->ut_user, sizeof(ut->ut_user)) != 0) {
+                       continue;
+               }
+-              if (oldest_login == 0 || oldest_login > ut->ut_tv.tv_sec) {
++              if (oldest_login == 0 ||
++                  zero_extend_signed_to_ull(oldest_login)
++                  > zero_extend_signed_to_ull(ut->ut_tv.tv_sec)) {
+                       oldest_login = ut->ut_tv.tv_sec;
+               }
+       }

diff --git a/sys-libs/pam/pam-1.7.1.ebuild b/sys-libs/pam/pam-1.7.1.ebuild
index eb03ad42934d..13ee4cbbf1de 100644
--- a/sys-libs/pam/pam-1.7.1.ebuild
+++ b/sys-libs/pam/pam-1.7.1.ebuild
@@ -66,6 +66,11 @@ DEPEND="
 RDEPEND="${DEPEND}"
 PDEPEND=">=sys-auth/pambase-20200616"
 
+PATCHES=(
+       "${FILESDIR}"/${P}-32-bit-lastlog.patch
+       "${FILESDIR}"/${P}-32-bit-timestamp.patch
+)
+
 src_configure() {
        # meson.build sets -Wl,--fatal-warnings and with e.g. mold, we get:
        #  cannot assign version `global` to symbol `pam_sm_open_session`: 
symbol not found

Reply via email to