diff mbox series

[2/2] systemd: add option to use stub-resolv.conf

Message ID 20231019111152.23880-3-eero.aaltonen@vaisala.com
State Accepted, archived
Commit dfa541ee4ffab5c43ac4b3f23552b7f9db5cb362
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 option to use the stub-resolv.conf file, which is the systemd
upstream's recommended default mode
https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html#/etc/resolv.conf

This enables the resolution of Multicast DNS and Link-Local Multicast
Name Resolution names for programs that do not use Name Service Switch.

Signed-off-by: Eero Aaltonen <eero.aaltonen@vaisala.com>
---
 meta/recipes-core/systemd/systemd_254.bb | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd_254.bb b/meta/recipes-core/systemd/systemd_254.bb
index e0ee2da412..83cd854b87 100644
--- a/meta/recipes-core/systemd/systemd_254.bb
+++ b/meta/recipes-core/systemd/systemd_254.bb
@@ -228,6 +228,8 @@  PACKAGECONFIG[xz] = "-Dxz=true,-Dxz=false,xz"
 PACKAGECONFIG[zlib] = "-Dzlib=true,-Dzlib=false,zlib"
 PACKAGECONFIG[zstd] = "-Dzstd=true,-Dzstd=false,zstd"
 
+RESOLV_CONF ??= ""
+
 # Helper variables to clarify locations.  This mirrors the logic in systemd's
 # build system.
 rootprefix ?= "${root_prefix}"
@@ -339,8 +341,9 @@  do_install() {
 		echo 'f /run/systemd/resolve/resolv.conf 0644 root root' >>${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf
 		ln -s ../run/systemd/resolve/resolv.conf ${D}${sysconfdir}/resolv-conf.systemd
 	else
-		sed -i -e "s%^L! /etc/resolv.conf.*$%L! /etc/resolv.conf - - - - ../run/systemd/resolve/resolv.conf%g" ${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
-		ln -s ../run/systemd/resolve/resolv.conf ${D}${sysconfdir}/resolv-conf.systemd
+		resolv_conf="${@bb.utils.contains('RESOLV_CONF', 'stub-resolv', 'run/systemd/resolve/stub-resolv.conf', 'run/systemd/resolve/resolv.conf', d)}"
+		sed -i -e "s%^L! /etc/resolv.conf.*$%L! /etc/resolv.conf - - - - ../${resolv_conf}%g" ${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
+		ln -s ../${resolv_conf} ${D}${sysconfdir}/resolv-conf.systemd
 	fi
 	if ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'false', 'true', d)}; then
 		rm ${D}${exec_prefix}/lib/tmpfiles.d/x11.conf