]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
systemd: fix DynamicUser issue
authorChen Qi <Qi.Chen@windriver.com>
Thu, 2 Nov 2023 01:42:20 +0000 (18:42 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 5 Nov 2023 11:21:01 +0000 (11:21 +0000)
The DynamicUser needs libnss-systemd to be installed to function
well. The tweaks to nsswitch.conf should be conditional on PACKAGECONFIG
values.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
meta/recipes-core/systemd/systemd_254.4.bb

index ddc8a0219a5cfce50d005df8bed8816ce4aaa398..8a8ff545995a0624321f6dc810f4d52ab99899b4 100644 (file)
@@ -179,7 +179,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"
@@ -840,15 +840,31 @@ ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
 ALTERNATIVE_PRIORITY[runlevel] ?= "300"
 
 pkg_postinst:${PN}:libc-glibc () {
-       sed -e '/^hosts:/s/\s*\<myhostname\>//' \
-               -e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2 myhostname \3\4\5/' \
-               -i $D${sysconfdir}/nsswitch.conf
+       if ${@bb.utils.contains('PACKAGECONFIG', 'myhostname', 'true', 'false', d)}; then
+               sed -e '/^hosts:/s/\s*\<myhostname\>//' \
+                       -e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\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 () {
-       sed -e '/^hosts:/s/\s*\<myhostname\>//' \
-               -e '/^hosts:/s/\s*myhostname//' \
-               -i $D${sysconfdir}/nsswitch.conf
+       if ${@bb.utils.contains('PACKAGECONFIG', 'myhostname', 'true', 'false', d)}; then
+               sed -e '/^hosts:/s/\s*\<myhostname\>//' \
+                       -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"