[Buildroot] [PATCH 02/10] package/systemd: add libnss-systemd to name resolution

Norbert Lange nolange79 at gmail.com
Thu Feb 6 09:36:25 UTC 2020


The feature DynamicUser creates users/groups without
touching the /etc/{passwd,group} files on disk.
Adding the dynamic resolver to /etc/nsswitch.conf
ensures the Names are resolved consistently.

Signed-off-by: Norbert Lange <nolange79 at gmail.com>
---
 package/systemd/systemd.mk | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index 05b07cfd1b..a390cdd1a9 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -409,7 +409,15 @@ define SYSTEMD_INSTALL_MACHINEID_HOOK
 	touch $(TARGET_DIR)/etc/machine-id
 endef
 
+define SYSTEMD_ADD_NSSCONFIG_HOOK
+	grep >/dev/null '^passwd:.*systemd' $(TARGET_DIR)/etc/nsswitch.conf || \
+		sed '/^passwd:/ s/$$/ systemd/' $(TARGET_DIR)/etc/nsswitch.conf
+	grep >/dev/null '^group:.*systemd' $(TARGET_DIR)/etc/nsswitch.conf || \
+		sed '/^group:/ s/$$/ systemd/' $(TARGET_DIR)/etc/nsswitch.conf
+endef
+
 SYSTEMD_POST_INSTALL_TARGET_HOOKS += \
+	SYSTEMD_ADD_NSSCONFIG_HOOK \
 	SYSTEMD_INSTALL_INIT_HOOK \
 	SYSTEMD_INSTALL_MACHINEID_HOOK \
 	SYSTEMD_INSTALL_RESOLVCONF_HOOK
-- 
2.24.1



More information about the buildroot mailing list