diff mbox series

[1/2] base-files, systemd: add nss-resolve plugin

Message ID 20231019111152.23880-2-eero.aaltonen@vaisala.com
State Accepted, archived
Commit 81da1d6eecee9fd036121298abba6fdcffc3969d
Headers show
Series DNS resolution using systemd-resolved | expand

Commit Message

Aaltonen Eero Oct. 19, 2023, 11:11 a.m. UTC
From: Eero Aaltonen <eero.aaltonen@vaisala.com>

Add nss-resolve plugin to the glibc Name Service Switch (NSS) with
systemd-resolved DISTRO_FEATURE so that systemd-resolved is used in DNS
name resolution.

This enables the resolution of Multicast DNS and Link-Local Multicast
Name Resolution names, depending on the selected options.

Signed-off-by: Eero Aaltonen <eero.aaltonen@vaisala.com>
---
 .../0001-add-nss-resolve-to-nsswitch.patch    | 31 +++++++++++++++++++
 .../base-files/base-files_3.0.14.bb           |  2 ++
 meta/recipes-core/systemd/systemd_254.bb      |  3 ++
 3 files changed, 36 insertions(+)
 create mode 100644 meta/recipes-core/base-files/base-files/0001-add-nss-resolve-to-nsswitch.patch
diff mbox series

Patch

diff --git a/meta/recipes-core/base-files/base-files/0001-add-nss-resolve-to-nsswitch.patch b/meta/recipes-core/base-files/base-files/0001-add-nss-resolve-to-nsswitch.patch
new file mode 100644
index 0000000000..a6e39e0956
--- /dev/null
+++ b/meta/recipes-core/base-files/base-files/0001-add-nss-resolve-to-nsswitch.patch
@@ -0,0 +1,31 @@ 
+From 830abe652428d9d31780c3ace121635ad7b64274 Mon Sep 17 00:00:00 2001
+From: Eero Aaltonen <eero.aaltonen@vaisala.com>
+Date: Wed Sep 27 15:50:48 2023 +0300
+Subject: [PATCH] Add nss-resolve to the Name Service Switch (NSS)
+
+Add `nss-resolve` so that `systemd-resolved` is used for name
+resolution with glibc `gethostbyname` calls.
+
+Upstream-Status: Inappropriate [no upstream, configuration].
+
+Signed-off-by: Eero Aaltonen <eero.aaltonen@vaisala.com>
+---
+ nsswitch.conf | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nsswitch.conf b/nsswitch.conf
+index 06f03d2..34b165c 100644
+--- a/nsswitch.conf
++++ b/nsswitch.conf
+@@ -8,7 +8,7 @@ passwd:         compat
+ group:          compat
+ shadow:         compat
+ 
+-hosts:          files dns
++hosts:          resolve [!UNAVAIL=return] files dns
+ networks:       files
+ 
+ protocols:      db files
+-- 
+2.25.1
+
diff --git a/meta/recipes-core/base-files/base-files_3.0.14.bb b/meta/recipes-core/base-files/base-files_3.0.14.bb
index 6ba3971e32..6890fe114d 100644
--- a/meta/recipes-core/base-files/base-files_3.0.14.bb
+++ b/meta/recipes-core/base-files/base-files_3.0.14.bb
@@ -23,6 +23,8 @@  SRC_URI = "file://rotation \
            file://share/dot.profile \
            file://licenses/GPL-2 \
            "
+SRC_URI:append:libc-glibc = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd systemd-resolved', ' file://0001-add-nss-resolve-to-nsswitch.patch', '', d)}"
+
 S = "${WORKDIR}"
 
 INHIBIT_DEFAULT_DEPS = "1"
diff --git a/meta/recipes-core/systemd/systemd_254.bb b/meta/recipes-core/systemd/systemd_254.bb
index 8d5cf13095..e0ee2da412 100644
--- a/meta/recipes-core/systemd/systemd_254.bb
+++ b/meta/recipes-core/systemd/systemd_254.bb
@@ -789,6 +789,9 @@  python __anonymous() {
     if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
         d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
 
+    if bb.utils.contains('DISTRO_FEATURES', 'systemd-resolved', True, False, d) and not bb.utils.contains('PACKAGECONFIG', 'nss-resolve resolved', True, False, d):
+        bb.error("DISTRO_FEATURES[systemd-resolved] requires PACKAGECONFIG[nss-resolve, resolved]")
+
     if bb.utils.contains('PACKAGECONFIG', 'repart', True, False, d) and not bb.utils.contains('PACKAGECONFIG', 'openssl', True, False, d):
         bb.error("PACKAGECONFIG[repart] requires PACKAGECONFIG[openssl]")