From: Chen Qi <qi.c...@windriver.com>

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.c...@windriver.com>
Signed-off-by: Alexandre Belloni <alexandre.bell...@bootlin.com>
(cherry picked from commit ba3a78c08cb0ce08afde049610d3172b9e3b0695)
Signed-off-by: Steve Sakoman <st...@sakoman.com>
---
 meta/recipes-core/systemd/systemd_254.4.bb | 30 +++++++++++++++++-----
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd_254.4.bb 
b/meta/recipes-core/systemd/systemd_254.4.bb
index 77724eb822..285ca92e68 100644
--- a/meta/recipes-core/systemd/systemd_254.4.bb
+++ b/meta/recipes-core/systemd/systemd_254.4.bb
@@ -178,7 +178,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"
@@ -826,15 +826,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"
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#191540): 
https://lists.openembedded.org/g/openembedded-core/message/191540
Mute This Topic: https://lists.openembedded.org/mt/102902835/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to