Skip to contentSkip to conversation

libpam: set pam module path to ${base_libdir}/security

PATCH New Yi Zhao 1 participant 3 messages Jan 3, 2025

lore
Share & tools
lore

Yi Zhao

author
#0 lore raw

PATCH 1/3 libpam: set pam module path to ${base_libdir}/security

After upgrading to 1.7.0, the pam module path is set to ${libdir}/security[1]. But from the pam.conf(5) man page, the default location seems to be "Module location: /lib/security/ or /lib64/security/, depending on the architecture"[2].

Many third-party pam modules still use {base_libdir}/security as the default module path, such as pam_lastlog2 (from util-linux), pam_cgroup (from libcgroup), pam_cap (from libcap), etc.
So currently if you don't use the absolute path to these modules in the files in /etc/pam.d/, they will not be found:

PAM unable to dlopen(/usr/lib/security/pam_lastlog2.so):
/usr/lib/security/pam_lastlog2.so: cannot open shared object file: No such file or directory

This change only affects sysvinit without usrmerge feature enabled, and has no effect on systems using systemd.

[1] https://git.openembedded.org/openembedded-core/commit/?id=00eb730291f9630eb70480d37ed48fbadecc547a
[2] https://www.man7.org/linux/man-pages/man5/pam.conf.5.html

---
 meta/recipes-extended/pam/libpam_1.7.0.bb | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
meta/recipes-extended/pam/libpam_1.7.0.bb +4 -4
index 53839e8cd3..1be3c9e2bb 100644
@@ -29,7 +29,7 @@ SRC_URI[sha256sum] = "57dcd7a6b966ecd5bbd95e1d11173734691e16b68692fa59661cdae9b1
 
 DEPENDS = "bison-native flex-native libxml2-native virtual/crypt"
 
-EXTRA_OEMESON = "-Ddocs=disabled"
+EXTRA_OEMESON = "-Ddocs=disabled -Dsecuredir=${base_libdir}/security"
 
 S = "${WORKDIR}/Linux-PAM-${PV}"
 
@@ -45,7 +45,7 @@ FILES:${PN} = " \
     ${libdir}/lib*${SOLIBS} \
     ${nonarch_libdir}/tmpfiles.d/*.conf \
 "
-FILES:${PN}-dev += "${libdir}/security/*.la ${libdir}/*.la ${libdir}/lib*${SOLIBSDEV}"
+FILES:${PN}-dev += "${base_libdir}/security/*.la ${libdir}/*.la ${libdir}/lib*${SOLIBSDEV}"
 FILES:${PN}-runtime = "${sysconfdir} ${sbindir} ${nonarch_libdir}/systemd/system"
 FILES:${PN}-xtests = "${datadir}/Linux-PAM/xtests"
 
@@ -105,9 +105,9 @@ python populate_packages:prepend () {
 
     mlprefix = d.getVar('MLPREFIX') or ''
     dvar = d.expand('${WORKDIR}/package')
-    pam_libdir = d.expand('${libdir}/security')
+    pam_libdir = d.expand('${base_libdir}/security')
     pam_sbindir = d.expand('${sbindir}')
-    pam_filterdir = d.expand('${libdir}/security/pam_filter')
+    pam_filterdir = d.expand('${base_libdir}/security/pam_filter')
     pam_pkgname = mlprefix + 'pam-plugin%s'
 
     do_split_packages(d, pam_libdir, r'^pam(.*)\.so$', pam_pkgname,
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/3 util-linux: replace local patch with upstream patch

There is a better solution upstream to fix the pam_lastlog2 installation issue[1]. Backport this patch to replace the local patch.

[1] https://github.com/util-linux/util-linux/pull/3173

---
 meta/recipes-core/util-linux/util-linux.inc   |  2 +-
 ...s-make-pam-install-path-configurable.patch | 65 ---------------
 ...x-securedir-and-pam_lastlog2-install.patch | 82 +++++++++++++++++++
 3 files changed, 83 insertions(+), 66 deletions(-)
 delete mode 100644 meta/recipes-core/util-linux/util-linux/0001-Revert-autotools-make-pam-install-path-configurable.patch
 create mode 100644 meta/recipes-core/util-linux/util-linux/0001-autotools-fix-securedir-and-pam_lastlog2-install.patch
meta/recipes-core/util-linux/util-linux.inc +1 -1
index 1c066631f3..1dc30c0535 100644
@@ -38,7 +38,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-lin
            file://display_testname_for_subtest.patch \
            file://avoid_parallel_tests.patch \
            file://fcntl-lock.c \
-           file://0001-Revert-autotools-make-pam-install-path-configurable.patch \
+           file://0001-autotools-fix-securedir-and-pam_lastlog2-install.patch \
            file://libfdisk-cfdisk-and-sfdisk-sector-size-improvements.patch \
            "
 
meta/recipes-core/util-linux/util-linux/0001-Revert-autotools-make-pam-install-path-configurable.patch deleted +0 -65

65 lines not on this page · raw message

meta/recipes-core/util-linux/util-linux/0001-autotools-fix-securedir-and-pam_lastlog2-install.patch new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 3/3 util-linux: add volatile file for lastlog2

In reply to Yi Zhao

Add volatile file for lastlog2 to fix runtime error with sysvinit:

$ lastlog2
lastlog2: Couldn't read entries for all users
lastlog2: Cannot open database (/var/lib/lastlog/lastlog2.db): unable to open database file
---
 meta/recipes-core/util-linux/util-linux_2.40.2.bb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
meta/recipes-core/util-linux/util-linux_2.40.2.bb +8 -1
index 646bc05564..2c7dd154e1 100644
@@ -129,7 +129,8 @@ FILES:${PN}-runuser = "${sysconfdir}/pam.d/runuser*"
 FILES:${PN}-su = "${sysconfdir}/pam.d/su-l"
 CONFFILES:${PN}-su = "${sysconfdir}/pam.d/su-l"
 FILES:${PN}-lastlog2 += "${base_libdir}/security/pam_lastlog2.so \
-                         ${nonarch_libdir}/tmpfiles.d/lastlog2.conf"
+                         ${nonarch_libdir}/tmpfiles.d/lastlog2.conf \
+                         ${sysconfdir}/default/volatiles/99_lastlog2"
 FILES:${PN}-pylibmount = "${PYTHON_SITEPACKAGES_DIR}/libmount/pylibmount.so \
                           ${PYTHON_SITEPACKAGES_DIR}/libmount/__init__.* \
                           ${PYTHON_SITEPACKAGES_DIR}/libmount/__pycache__/*"
@@ -222,6 +223,12 @@ do_install:append:class-target () {
 			install -m 0644 ${S}/misc-utils/lastlog2-tmpfiles.conf.in \
 				${D}${nonarch_libdir}/tmpfiles.d/lastlog2.conf
 		fi
+
+		if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
+			install -d ${D}${sysconfdir}/default/volatiles
+			echo "d root root 0755 /var/lib/lastlog none" \
+				> ${D}${sysconfdir}/default/volatiles/99_lastlog2
+		fi
 	fi
 }
 # nologin causes a conflict with shadow-native
Signature · 1 line
2.25.1