From 6e40d0025254b312a097a182c9920502edea3235 Mon Sep 17 00:00:00 2001 From: Chris Wiggins Date: Tue, 4 Feb 2025 14:18:53 +1300 Subject: [PATCH] systemd: backport DynamicUser support via nss The DynamicUser needs libnss-systemd to be installed to function well. The tweaks to nsswitch.conf should be conditional on PACKAGECONFIG values. Upstream commit: ba3a78c08cb0ce08afde049610d3172b9e3b0695 Signed-off-by: Chris Wiggins --- meta/recipes-core/systemd/systemd_250.5.bb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/meta/recipes-core/systemd/systemd_250.5.bb b/meta/recipes-core/systemd/systemd_250.5.bb index 4d520c85f3d..8146610dbfa 100644 --- a/meta/recipes-core/systemd/systemd_250.5.bb +++ b/meta/recipes-core/systemd/systemd_250.5.bb @@ -175,7 +175,7 @@ PACKAGECONFIG[microhttpd] = "-Dmicrohttpd=true,-Dmicrohttpd=false,libmicrohttpd" PACKAGECONFIG[myhostname] = "-Dnss-myhostname=true,-Dnss-myhostname=false,,libnss-myhostname" PACKAGECONFIG[networkd] = "-Dnetworkd=true,-Dnetworkd=false" PACKAGECONFIG[no-dns-fallback] = "-Ddns-servers=" -PACKAGECONFIG[nss] = "-Dnss-systemd=true,-Dnss-systemd=false" +PACKAGECONFIG[nss] = "-Dnss-systemd=true,-Dnss-systemd=false,,libnss-systemd" PACKAGECONFIG[nss-mymachines] = "-Dnss-mymachines=true,-Dnss-mymachines=false" PACKAGECONFIG[nss-resolve] = "-Dnss-resolve=true,-Dnss-resolve=false" PACKAGECONFIG[oomd] = "-Doomd=true,-Doomd=false" @@ -782,6 +782,12 @@ pkg_postinst:${PN}:libc-glibc () { -e 's/\(^hosts:.*\)\(\\)\(.*\)\(\\)\(.*\)/\1\2 myhostname \3\4\5/' \ -i $D${sysconfdir}/nsswitch.conf fi + if ${@bb.utils.contains('PACKAGECONFIG', 'nss', 'true', 'false', d)}; then + sed -e 's#\(^passwd:.*\)#\1 systemd#' \ + -e 's#\(^group:.*\)#\1 systemd#' \ + -e 's#\(^shadow:.*\)#\1 systemd#' \ + -i $D${sysconfdir}/nsswitch.conf + fi } pkg_prerm:${PN}:libc-glibc () { @@ -790,6 +796,13 @@ pkg_prerm:${PN}:libc-glibc () { -e '/^hosts:/s/\s*myhostname//' \ -i $D${sysconfdir}/nsswitch.conf fi + + if ${@bb.utils.contains('PACKAGECONFIG', 'nss', 'true', 'false', d)}; then + sed -e '/^passwd:/s#\s*systemd##' \ + -e '/^group:/s#\s*systemd##' \ + -e '/^shadow:/s#\s*systemd##' \ + -i $D${sysconfdir}/nsswitch.conf + fi } PACKAGE_WRITE_DEPS += "qemu-native"