diff mbox series

[v2] base-files: add nsswitch-resolved.conf and remove nsswitch patch

Message ID 20250522201417.53623-1-hiagofranco@gmail.com
State Accepted, archived
Commit f3f68874f0edd16c4a85df76e34cc905c41d47f0
Headers show
Series [v2] base-files: add nsswitch-resolved.conf and remove nsswitch patch | expand

Commit Message

Hiago De Franco May 22, 2025, 8:14 p.m. UTC
From: Hiago De Franco <hiago.franco@toradex.com>

Due to changes to nsswitch.conf file on commit 0cb122f17cf2
("base-files: add gshadow entry in nsswitch.conf"), the current patch
does not apply anymore due to patch fuzz.

This fuzz wasn't detected before because this is a conditional patch,
and will be hard to detect if nsswitch.conf changes again.

Instead, add a new version of nsswitch.conf, called
nsswitch-resolved.conf, which will later be renamed accordingly based on
the DISTRO_FEATURES variable. This file contains the necessary changes
which were applied by the patch before.

Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
Suggested-by: Alexander Kanavin <alex.kanavin@gmail.com>

---
v2: Patch deleted and nsswitch-resolved.conf was introduced instead.
v1: https://lore.kernel.org/all/20250521202337.113556-1-hiagofranco@gmail.com/
---
---
 .../0001-add-nss-resolve-to-nsswitch.patch    | 31 -------------------
 .../base-files/nsswitch-resolved.conf         | 20 ++++++++++++
 .../base-files/base-files_3.0.14.bb           |  4 +--
 3 files changed, 22 insertions(+), 33 deletions(-)
 delete mode 100644 meta/recipes-core/base-files/base-files/0001-add-nss-resolve-to-nsswitch.patch
 create mode 100644 meta/recipes-core/base-files/base-files/nsswitch-resolved.conf
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
deleted file mode 100644
index a6e39e095688..000000000000
--- a/meta/recipes-core/base-files/base-files/0001-add-nss-resolve-to-nsswitch.patch
+++ /dev/null
@@ -1,31 +0,0 @@ 
-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/nsswitch-resolved.conf b/meta/recipes-core/base-files/base-files/nsswitch-resolved.conf
new file mode 100644
index 000000000000..ec6ce156b590
--- /dev/null
+++ b/meta/recipes-core/base-files/base-files/nsswitch-resolved.conf
@@ -0,0 +1,20 @@ 
+# /etc/nsswitch.conf
+#
+# Example configuration of GNU Name Service Switch functionality.
+# If you have the `glibc-doc' and `info' packages installed, try:
+# `info libc "Name Service Switch"' for information about this file.
+
+passwd:         compat
+group:          compat
+shadow:         compat
+gshadow:        files
+
+hosts:          resolve [!UNAVAIL=return] files dns
+networks:       files
+
+protocols:      db files
+services:       db files
+ethers:         db files
+rpc:            db files
+
+netgroup:       nis
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 60253fcd4213..59b084d14147 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
@@ -11,6 +11,7 @@  LIC_FILES_CHKSUM = "file://licenses/GPL-2;md5=94d55d512a9ba36caa9b7df079bae19f"
 
 SRC_URI = "file://rotation \
            file://nsswitch.conf \
+           file://nsswitch-resolved.conf \
            file://motd \
            file://hosts \
            file://host.conf \
@@ -23,7 +24,6 @@  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}/sources"
 UNPACKDIR = "${S}"
@@ -124,7 +124,7 @@  do_install () {
 }
 
 do_install:append:libc-glibc () {
-	install -m 0644 ${S}/nsswitch.conf ${D}${sysconfdir}/nsswitch.conf
+	install -m 0644 ${S}/${@bb.utils.contains('DISTRO_FEATURES', 'systemd systemd-resolved', 'nsswitch-resolved.conf', 'nsswitch.conf', d)} ${D}${sysconfdir}/nsswitch.conf
 }
 
 DISTRO_VERSION[vardepsexclude] += "DATE"