diff mbox series

[3/3] util-linux: add volatile file for lastlog2

Message ID 20250103092445.566172-3-yi.zhao@windriver.com
State Accepted, archived
Commit 440f4830d1f1bac9d55584fc4e48627920493cb9
Headers show
Series [1/3] libpam: set pam module path to ${base_libdir}/security | expand

Commit Message

Yi Zhao Jan. 3, 2025, 9:24 a.m. UTC
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

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 meta/recipes-core/util-linux/util-linux_2.40.2.bb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/util-linux/util-linux_2.40.2.bb b/meta/recipes-core/util-linux/util-linux_2.40.2.bb
index 646bc05564..2c7dd154e1 100644
--- a/meta/recipes-core/util-linux/util-linux_2.40.2.bb
+++ b/meta/recipes-core/util-linux/util-linux_2.40.2.bb
@@ -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