Skip to contentSkip to conversation

systemd: don't symlink /etc/resolv.conf if resolved is disabled

PATCH In review Carlos Alberto Lopez Perez 1 participant 3 messages Aug 21, 2017 – Aug 24, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 systemd: don't symlink /etc/resolv.conf if resolved is disabled

* symlinking /etc/resolv.conf to /run/systemd/resolve/resolv.conf when resolved is not enabled is wrong, as this prevents network manager from handling the resolv.conf file itself and breaking DNS resolution.

See: NetworkManager.conf manpage or https://git.io/v5UJQ

---
 meta/recipes-core/systemd/systemd_234.bb | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
meta/recipes-core/systemd/systemd_234.bb +1 -6
index 4560cf4175..dddad62941 100644
@@ -235,12 +235,7 @@ do_install() {
 	if [ -s ${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf ]; then
 		${@bb.utils.contains('PACKAGECONFIG', 'networkd', ':', 'sed -i -e "\$ad /run/systemd/netif/links 0755 root root -" ${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf', d)}
 	fi
-	if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 'false', d)}; then
-		echo 'L! ${sysconfdir}/resolv.conf - - - - ../run/systemd/resolve/resolv.conf' >>${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
-		echo 'd /run/systemd/resolve 0755 root root -' >>${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf
-		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
+	if ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 'false', d)}; then
 		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
 	fi
Signature · 1 line
2.11.0
#1 lore raw
Quoted 21 lines · Carlos Alberto Lopez Perez

* symlinking /etc/resolv.conf to /run/systemd/resolve/resolv.conf when resolved is not enabled is wrong, as this prevents network manager from handling the resolv.conf file itself and breaking DNS resolution.

See: NetworkManager.conf manpage or https://git.io/v5UJQ

---
 meta/recipes-core/systemd/systemd_234.bb | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
meta/recipes-core/systemd/systemd_234.bb +0 -0
index 4560cf4175..dddad62941 100644
@@ -235,12 +235,7 @@ do_install() {
 	if [ -s ${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf ]; then
 		${@bb.utils.contains('PACKAGECONFIG', 'networkd', ':', 'sed -i -e "\$ad /run/systemd/netif/links 0755 root root -" ${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf', d)}
 	fi

meta/recipes-core/systemd/systemd_234.bb do_install() { · line 241

Quoted 10 lines
meta/recipes-core/systemd/systemd_234.bb +1 -6
-	if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 'false', d)}; then
-		echo 'L! ${sysconfdir}/resolv.conf - - - - ../run/systemd/resolve/resolv.conf' >>${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
-		echo 'd /run/systemd/resolve 0755 root root -' >>${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf
-		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
+	if ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 'false', d)}; then
 		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
 	fi

Looking at the previous history it seems symlinking /etc/resolv.conf when not enabling resolved was done originally to allow updating resolv.conf on read-only-rootfs filesystems ( commit 7f087f161e ).

So the above patch is not right, as it will break that.

An idea is to symlink /etc/resolv.conf to a different filename in /run when resolved is not enabled.

#2 lore raw
Quoted 37 lines · Carlos Alberto Lopez Perez
Quoted 21 lines · Carlos Alberto Lopez Perez

* symlinking /etc/resolv.conf to /run/systemd/resolve/resolv.conf when resolved is not enabled is wrong, as this prevents network manager from handling the resolv.conf file itself and breaking DNS resolution.

See: NetworkManager.conf manpage or https://git.io/v5UJQ

---
 meta/recipes-core/systemd/systemd_234.bb | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
meta/recipes-core/systemd/systemd_234.bb +0 -0
index 4560cf4175..dddad62941 100644
@@ -235,12 +235,7 @@ do_install() {
 	if [ -s ${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf ]; then
 		${@bb.utils.contains('PACKAGECONFIG', 'networkd', ':', 'sed -i -e "\$ad /run/systemd/netif/links 0755 root root -" ${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf', d)}
 	fi

meta/recipes-core/systemd/systemd_234.bb do_install() { · line 241

Quoted 10 lines
meta/recipes-core/systemd/systemd_234.bb +1 -6
-	if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 'false', d)}; then
-		echo 'L! ${sysconfdir}/resolv.conf - - - - ../run/systemd/resolve/resolv.conf' >>${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
-		echo 'd /run/systemd/resolve 0755 root root -' >>${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf
-		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
+	if ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 'false', d)}; then
 		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
 	fi

Looking at the previous history it seems symlinking /etc/resolv.conf when not enabling resolved was done originally to allow updating resolv.conf on read-only-rootfs filesystems ( commit 7f087f161e ).

Quoted 7 lines

So the above patch is not right, as it will break that.

An idea is to symlink /etc/resolv.conf to a different filename in /run when resolved is not enabled.

FTR; I reported this issue at:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=11969