Skip to contentSkip to conversation

util-linux: backport pam_lastlog2 libpam linking fix

PATCH Superseded Siva Balasubramanian 2 participants 3 messages Jun 25 – Jul 6

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 util-linux: backport pam_lastlog2 libpam linking fix

pam_lastlog2.so uses pam_syslog() and other libpam symbols but the autotools build did not link the module against libpam. With the linker default of --as-needed, libpam was discarded and did not end up in the module's ELF NEEDED entries. The module then fails to load via dlopen() in processes that do not themselves link libpam (e.g. systemd on recent Fedora, or weston on journald-based systems without syslog):

PAM unable to dlopen(/usr/lib/security/pam_lastlog2.so): undefined symbol: pam_syslog PAM adding faulty module: /usr/lib/security/pam_lastlog2.so

Backport the upstream fix (in 2.41.5) that moves -lpam into LIBADD so it is placed after the object files and retained as a NEEDED entry. Against 2.41.3 only the LIBADD line needs changing.

[YOCTO #16320]

---
 meta/recipes-core/util-linux/util-linux.inc   |  1 +
 ...ix-libpam-linking-in-autotools-build.patch | 51 +++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 meta/recipes-core/util-linux/util-linux/0001-pam_lastlog2-fix-libpam-linking-in-autotools-build.patch
meta/recipes-core/util-linux/util-linux.inc +1 -0
index 0235862666..3cdc1e2c0f 100644
@@ -21,6 +21,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-lin
            file://0001-ts-kill-decode-use-RTMIN-from-kill-L-instead-of-hard.patch \
            file://0001-tests-script-Disable-size-option-test.patch \
            file://0001-loopdev-add-LOOPDEV_FL_NOFOLLOW-to-prevent-symlink-a.patch \
+           file://0001-pam_lastlog2-fix-libpam-linking-in-autotools-build.patch \
            "
 
 SRC_URI[sha256sum] = "3330d873f0fceb5560b89a7dc14e4f3288bbd880e96903ed9b50ec2b5799e58b"
meta/recipes-core/util-linux/util-linux/0001-pam_lastlog2-fix-libpam-linking-in-autotools-build.patch new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

Hello,

Quoted 64 lines · Siva Balasubramanian via lists.openembedded.org

pam_lastlog2.so uses pam_syslog() and other libpam symbols but the autotools build did not link the module against libpam. With the linker default of --as-needed, libpam was discarded and did not end up in the module's ELF NEEDED entries. The module then fails to load via dlopen() in processes that do not themselves link libpam (e.g. systemd on recent Fedora, or weston on journald-based systems without syslog):

PAM unable to dlopen(/usr/lib/security/pam_lastlog2.so): undefined symbol: pam_syslog PAM adding faulty module: /usr/lib/security/pam_lastlog2.so

Backport the upstream fix (in 2.41.5) that moves -lpam into LIBADD so it is placed after the object files and retained as a NEEDED entry. Against 2.41.3 only the LIBADD line needs changing.

[YOCTO #16320]

---
 meta/recipes-core/util-linux/util-linux.inc   |  1 +
 ...ix-libpam-linking-in-autotools-build.patch | 51 +++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 meta/recipes-core/util-linux/util-linux/0001-pam_lastlog2-fix-libpam-linking-in-autotools-build.patch
meta/recipes-core/util-linux/util-linux.inc +1 -0
index 0235862666..3cdc1e2c0f 100644
@@ -21,6 +21,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-lin
            file://0001-ts-kill-decode-use-RTMIN-from-kill-L-instead-of-hard.patch \
            file://0001-tests-script-Disable-size-option-test.patch \
            file://0001-loopdev-add-LOOPDEV_FL_NOFOLLOW-to-prevent-symlink-a.patch \
+           file://0001-pam_lastlog2-fix-libpam-linking-in-autotools-build.patch \
            "
 
 SRC_URI[sha256sum] = "3330d873f0fceb5560b89a7dc14e4f3288bbd880e96903ed9b50ec2b5799e58b"
meta/recipes-core/util-linux/util-linux/0001-pam_lastlog2-fix-libpam-linking-in-autotools-build.patch new file +22 -0
new file mode 100644
index 0000000000..9aaa56e7b4
@@ -0,0 +1,51 @@
+From c8d0af0421f6491ab1cb2301d2e197315289d34c Mon Sep 17 00:00:00 2001
+From: Karel Zak <[email protected]>
+Date: Tue, 19 May 2026 10:54:57 +0200
+Subject: [PATCH] pam_lastlog2: fix libpam linking in autotools build
+
+The pam_lastlog2 module uses pam_syslog() and other libpam symbols but
+the autotools build did not link the module against libpam. With the
+linker default of --as-needed (and -lpam previously only in LDFLAGS,
+before the object files), libpam was discarded and did not appear in the
+module's ELF NEEDED entries.
+
+The module then fails to load with dlopen() if the calling process does
+not itself link against libpam (e.g. systemd on recent Fedora, or weston
+on journald-based systems without syslog):
+
+  PAM unable to dlopen(/usr/lib/security/pam_lastlog2.so): undefined symbol: pam_syslog
+  PAM adding faulty module: /usr/lib/security/pam_lastlog2.so
+
+Move -lpam into pam_lastlog2_la_LIBADD so it is placed after the object
+files on the link line and is retained in the NEEDED entries. The meson
+build already links libpam correctly via cc.find_library('pam').
+

meta/recipes-core/util-linux/util-linux/0001-pam_lastlog2-fix-libpam-linking-in-autotools-build.patch line 32

Quoted 10 lines
meta/recipes-core/util-linux/util-linux/0001-pam_lastlog2-fix-libpam-linking-in-autotools-build.patch new file +10 -0
+Note for this backport: against 2.41.3 only the LIBADD line needs to
+change. The upstream commit also removes -lpam from LDFLAGS, but that
+LDFLAGS reference was added after 2.41.3 and is not present here, so the
+net change is the single LIBADD hunk below.
+
+Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2453457
+
+Upstream-Status: Backport [https://github.com/util-linux/util-linux/commit/c8d0af0421f6491ab1cb2301d2e197315289d34c]
+Signed-off-by: Karel Zak <[email protected]>
+Signed-off-by: Siva Balasubramanian <[email protected]>

Please don't rewrite patch message when backporting.

Only append backporting info at the end. We depend quite heavily on patch being similar to upstream patches and modifications like your makes it hard to check.

Please send a v2 with the commit message preserved.

Also, I can't find the corresponding commit on oe-core/master. If this is in util-linux/2.42.x branch, can you tell me what is the commit?

Thanks!

Signature · 2 lines
Yoann Congal
Smile ECS
#2 lore raw

Hello Yoann,

Thanks for the review.

Quoted 8 lines

Please don't rewrite patch message when backporting.

Only append backporting info at the end. We depend quite heavily on patch being similar to upstream patches and modifications like your makes it hard to check.

Please send a v2 with the commit message preserved.

https://patchwork.yoctoproject.org/project/oe-core/patch/[email protected]/

Understood, and sorry about that. v2 keeps Karel's upstream commit message verbatim and only appends the backport info at the end (Upstream-Status plus a short note about the dropped LDFLAGS hunk).

Quoted 3 lines

Also, I can't find the corresponding commit on oe-core/master. If this is in util-linux/2.42.x branch, can you tell me what is the commit?

This is not for the oe-core/master. It is already on util-linux 2.42.2, which contains the fix, so nothing is needed there. This backport targets the wrynose branch, which is still on util-linux 2.41.3. I've retagged v2 as [OE-core][wrynose][PATCH v2]

The upstream commit is:

util-linux master: 5683ed6320e00205146cbb3d0c76462733530eca ("pam_lastlog2: fix libpam linking in autotools build", PR #4358)

It was cherry-picked to the util-linux v2.41 stable branch as c8d0af0421f6 and released in 2.41.5, and is present in 2.42.x. v2 now points Upstream-Status at the master commit.

One note carried over into the backport: against 2.41.3 only the LIBADD line changes. The upstream commit also removes -lpam from LDFLAGS, but that LDFLAGS reference was added upstream after 2.41.3 and is not present in the wrynose tree, so only the LIBADD hunk applies (and carrying the LDFLAGS hunk would fail to apply).

Thanks,
Siva