Skip to contentSkip to conversation

systemd: resolved linked even if the option is disabled

PATCH In review Nicola Lunghi 2 participants 5 messages Jul 16, 2018 – Jul 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 systemd: resolved linked even if the option is disabled

From: Nicola Lunghi <[email protected]>

if resolved option is not selected the package systemd-resolved is not installed so it cannot provide an alternative for resolv.conf

In this recipe the previous check was instead reversing the check (note the !).

This patch avoid messing with resol.conf link if resolved is disabled in the package config.

This in particular if we compile systemd with musl where systemd-resolved cannot be compiled.

---
 meta/recipes-core/systemd/systemd_237.bb | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
meta/recipes-core/systemd/systemd_237.bb +3 -5
index 3efca33e73..bd6dcef637 100644
@@ -258,14 +258,11 @@ 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
+	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
-		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
 	install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_unitdir}/systemd-sysv-install
 
@@ -539,7 +536,7 @@ python __anonymous() {
 # TODO:
 # u-a for runlevel and telinit
 
-ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel resolv-conf"
+ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel"
 
 ALTERNATIVE_TARGET[init] = "${rootlibexecdir}/systemd/systemd"
 ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
@@ -565,6 +562,7 @@ ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
 ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
 ALTERNATIVE_PRIORITY[runlevel] ?= "300"
 
+ALTERNATIVE_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolv-conf', '', d)}"
 ALTERNATIVE_TARGET[resolv-conf] = "${sysconfdir}/resolv-conf.systemd"
 ALTERNATIVE_LINK_NAME[resolv-conf] = "${sysconfdir}/resolv.conf"
 ALTERNATIVE_PRIORITY[resolv-conf] ?= "50"
Signature · 1 line
2.17.1
#1 lore raw

Hi Nicola,

As I replied on poky mailing list to this patch, you need to first check the following three commits.

commit 00e4662e55f66570cae29240c22b4d74b79d3ca5

Author: Maxin B. John <[email protected]>
Date:   Mon Jun 12 18:10:21 2017 +0300

systemd: enable resolved and networkd

Enable systemd-resolved and systemd-networkd by default. Make it co-exist with connman and Fix associated problems in read-only rootfs.

Fixes [YOCTO #11331]

(From OE-Core rev: d9b6d538e3d81ab0d5e7b7b6adecef555d782217)

commit 669edd04432f8e76e32bd7f34f4d9aa63eef4038

Author: Khem Raj <[email protected]>
Date:   Fri Dec 16 14:07:31 2016 -0800

systemd: point to correct resolv.conf when resolved is enabled

latest systemd has changed the resolved defaults which points to 127.0.0.53 port 53 on local network. If someone wants to use host-local IP address then it can be pointed to copy in /lib/systemd

(From OE-Core rev: 99d1199fd0961f94732a1a533d66472ca17cf6f5)

commit b80da02ce9b683f96393fe0ea1f5f1a5f1a07c89

Author: Christopher Larson <[email protected]>
Date:   Wed Nov 4 20:19:19 2015 -0700

systemd: arrange for volatile /etc/resolv.conf

On sysvinit systems, volatiles is configured to make
/etc/resolv.conf symlink
to a file in a volatile path, which lets us write to
/etc/resolv.conf for
read-only-rootfs. For systemd, this isn't set up unless we enable systemd-resolved, which we don't by default. When it's not enabled,
create the
/etc/resolv.conf symlink and ensure the volatile path is created on
boot with
tmpfiles.d.

(From OE-Core rev: 7f087f161e8942bcd35f88999dfca418f01cd7fa)

Best Regards,
Chen Qi

Quoted 56 lines · Nicola Lunghi

From: Nicola Lunghi <[email protected]>

if resolved option is not selected the package systemd-resolved is not installed so it cannot provide an alternative for resolv.conf

In this recipe the previous check was instead reversing the check (note the !).

This patch avoid messing with resol.conf link if resolved is disabled in the package config.

This in particular if we compile systemd with musl where systemd-resolved cannot be compiled.

---
  meta/recipes-core/systemd/systemd_237.bb | 8 +++-----
  1 file changed, 3 insertions(+), 5 deletions(-)
meta/recipes-core/systemd/systemd_237.bb +3 -5
index 3efca33e73..bd6dcef637 100644
@@ -258,14 +258,11 @@ 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
+	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
-		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
  	install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_unitdir}/systemd-sysv-install
 
@@ -539,7 +536,7 @@ python __anonymous() {
  # TODO:
  # u-a for runlevel and telinit
 
-ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel resolv-conf"
+ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel"
 
  ALTERNATIVE_TARGET[init] = "${rootlibexecdir}/systemd/systemd"
  ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
@@ -565,6 +562,7 @@ ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
  ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
  ALTERNATIVE_PRIORITY[runlevel] ?= "300"
 
+ALTERNATIVE_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolv-conf', '', d)}"
  ALTERNATIVE_TARGET[resolv-conf] = "${sysconfdir}/resolv-conf.systemd"
  ALTERNATIVE_LINK_NAME[resolv-conf] = "${sysconfdir}/resolv.conf"
  ALTERNATIVE_PRIORITY[resolv-conf] ?= "50"
author
#2 lore raw

Hi Chen Qi,
Thanks I didn't see your previous response.
I will have a look and post my considerations.

Best Regards
Nicola Lunghi

Quoted 139 lines · ChenQi

Hi Nicola,

As I replied on poky mailing list to this patch, you need to first check the following three commits.

commit 00e4662e55f66570cae29240c22b4d74b79d3ca5

Author: Maxin B. John <[email protected]> <[email protected]>
Date:   Mon Jun 12 18:10:21 2017 +0300

systemd: enable resolved and networkd

Enable systemd-resolved and systemd-networkd by default. Make it co-exist with connman and Fix associated problems in read-only rootfs.

Fixes [YOCTO #11331]

(From OE-Core rev: d9b6d538e3d81ab0d5e7b7b6adecef555d782217)

<[email protected]>

<[email protected]>

commit 669edd04432f8e76e32bd7f34f4d9aa63eef4038

Author: Khem Raj <[email protected]> <[email protected]>
Date:   Fri Dec 16 14:07:31 2016 -0800

systemd: point to correct resolv.conf when resolved is enabled

latest systemd has changed the resolved defaults which points to 127.0.0.53 port 53 on local network. If someone wants to use host-local IP address then it can be pointed to copy in /lib/systemd

(From OE-Core rev: 99d1199fd0961f94732a1a533d66472ca17cf6f5)

<[email protected]>

<[email protected]>

commit b80da02ce9b683f96393fe0ea1f5f1a5f1a07c89
Author: Christopher Larson <[email protected]> <[email protected]>
Date: Wed Nov 4 20:19:19 2015 -0700

systemd: arrange for volatile /etc/resolv.conf

On sysvinit systems, volatiles is configured to make /etc/resolv.conf
symlink
to a file in a volatile path, which lets us write to /etc/resolv.conf
for
read-only-rootfs. For systemd, this isn't set up unless we enable systemd-resolved, which we don't by default. When it's not enabled,
create the
/etc/resolv.conf symlink and ensure the volatile path is created on
boot with
tmpfiles.d.

(From OE-Core rev: 7f087f161e8942bcd35f88999dfca418f01cd7fa)

<[email protected]>

<[email protected]>

<[email protected]>

Best Regards,
Chen Qi

On 07/16/2018 04:17 PM, Nicola Lunghi wrote:

From: Nicola Lunghi <[email protected]> <[email protected]>

if resolved option is not selected the package systemd-resolved is not installed so it cannot provide an alternative for resolv.conf

In this recipe the previous check was instead reversing the check (note the !).

This patch avoid messing with resol.conf link if resolved is disabled in the package config.

This in particular if we compile systemd with musl where systemd-resolved cannot be compiled.

---
 meta/recipes-core/systemd/systemd_237.bb | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
meta/recipes-core/systemd/systemd_237.bb +3 -6
index 3efca33e73..bd6dcef637 100644
@@ -258,14 +258,11 @@ 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
+	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
-		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
 	install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_unitdir}/systemd-sysv-install
 
@@ -539,7 +536,7 @@ python __anonymous() {
 # TODO:
 # u-a for runlevel and telinit
 
-ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel resolv-conf"
+ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel"
 
 ALTERNATIVE_TARGET[init] = "${rootlibexecdir}/systemd/systemd"
 ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
@@ -565,6 +562,7 @@ ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
 ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
 ALTERNATIVE_PRIORITY[runlevel] ?= "300"
 
+ALTERNATIVE_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolv-conf', '', d)}" <$%[email protected]('PACKAGECONFIG','resolved','resolv-conf','',d)%7D>
 ALTERNATIVE_TARGET[resolv-conf] = "${sysconfdir}/resolv-conf.systemd"
 ALTERNATIVE_LINK_NAME[resolv-conf] = "${sysconfdir}/resolv.conf"
 ALTERNATIVE_PRIORITY[resolv-conf] ?= "50"
 
 
--

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#3 lore raw
In reply to ChenQi

Hi

commit 00e4662e55f66570cae29240c22b4d74b79d3ca5

Quoted 10 lines
Author: Maxin B. John <[email protected]> <[email protected]>
Date:   Mon Jun 12 18:10:21 2017 +0300

systemd: enable resolved and networkd

Enable systemd-resolved and systemd-networkd by default. Make it co-exist with connman and Fix associated problems in read-only rootfs.

This part of the patch does nothing with the current version of systemd (or does the wrong thing)

        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
fi

the check here was

     if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true',

'false', d)}; then
apart from the part that the check is REVERSED ...
if the PACKAGECONFIG doesn't contain the resolved option systemd-resolved is not build and no modification is done on the /lib/tmpfiles/etc/conf

see
https://github.com/systemd/systemd/blob/46659f7deb962f55c728e70597e37c2a3ab6326d/tmpfiles.d/etc.conf.m4#L16
m4_ifdef(`ENABLE_RESOLVE',
L! /etc/resolv.conf - - - - ../run/systemd/resolve/stub-resolv.conf )m4_dnl

So the else branch can be safely removed.

Quoted 10 lines

commit 669edd04432f8e76e32bd7f34f4d9aa63eef4038

Author: Khem Raj <[email protected]> <[email protected]>
Date:   Fri Dec 16 14:07:31 2016 -0800

systemd: point to correct resolv.conf when resolved is enabled

latest systemd has changed the resolved defaults which points to 127.0.0.53 port 53 on local network. If someone wants to use host-local IP address then it can be pointed to copy in /lib/systemd

Quoted 9 lines

(From OE-Core rev: 99d1199fd0961f94732a1a533d66472ca17cf6f5)

<[email protected]>

<[email protected]>

So here the error was introduced!!!!! read this patch carefully If you read the deleted comment it was saying:
*if resolved is disabled*,
But this patch reverse it to

systemd: point to correct resolv.conf when resolved *is enabled*

        if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true',
'false', d)}; then
-               # *if resolved is disabled*, it won't handle the link of
resolv.conf, so
-               # set it up ourselves
-               ln -s ../run/resolv.conf ${D}${sysconfdir}/resolv.conf
-               echo '*L! ${sysconfdir}/resolv.conf - - - -

../run/resolv.conf'* >>${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
- echo 'f /run/resolv.conf 0644 root root'

Quoted 1 line
Quoted 1 line

${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf

+ echo* 'L! ${sysconfdir}/resolv.conf - - - -
../run/systemd/resolve/resolv.conf'*

Quoted 1 line
Quoted 1 line

${D}${exec_prefix}/lib/tmpfiles.d/etc.conf

+ echo 'd /run/systemd/resolve 0755 root root -'

Quoted 1 line
Quoted 1 line

${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf

+ echo 'f /run/systemd/resolve/resolv.conf 0644 root root'

Quoted 1 line
Quoted 1 line

${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf

+ ln -s ../run/systemd/resolve/resolv.conf
${D}${sysconfdir}/resolv.conf
+ 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

        fi
        install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON

${D}${systemd_unitdir}/systemd-sysv-install
}

Quoted 7 lines

commit b80da02ce9b683f96393fe0ea1f5f1a5f1a07c89
Author: Christopher Larson <[email protected]> <[email protected]>
Date: Wed Nov 4 20:19:19 2015 -0700

systemd: arrange for volatile /etc/resolv.conf

Quoted 12 lines

On sysvinit systems, volatiles is configured to make /etc/resolv.conf
symlink
to a file in a volatile path, which lets us write to /etc/resolv.conf
for
read-only-rootfs. For systemd, this isn't set up unless we enable systemd-resolved, which we don't by default. When it's not enabled,
create the
/etc/resolv.conf symlink and ensure the volatile path is created on
boot with
tmpfiles.d.

+ if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true',
'false', d)}; then
+ # if resolved is disabled, it won't handle the link of
resolv.conf, so

+               # set it up ourselves
+               ln -s ../run/resolv.conf ${D}${sysconfdir}/resolv.conf
+               echo 'L! ${sysconfdir}/resolv.conf - - - -

../run/resolv.conf' >>${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
+ echo 'f /run/resolv.conf 0644 root root'

Quoted 1 line
Quoted 1 line

${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf

+ fi

        install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON

${D}${systemd_unitdir}/systemd-sysv-install
}

This patch was the right one the following 669edd04432f8e76e32bd7f34f4d9aa63eef4038 reversed the sense of the switch

Regards
Nicola Lunghi

Quoted 70 lines

Best Regards,
Chen Qi

On 07/16/2018 04:17 PM, Nicola Lunghi wrote:

From: Nicola Lunghi <[email protected]> <[email protected]>

if resolved option is not selected the package systemd-resolved is not installed so it cannot provide an alternative for resolv.conf

In this recipe the previous check was instead reversing the check (note the !).

This patch avoid messing with resol.conf link if resolved is disabled in the package config.

This in particular if we compile systemd with musl where systemd-resolved cannot be compiled.

---
 meta/recipes-core/systemd/systemd_237.bb | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
meta/recipes-core/systemd/systemd_237.bb +3 -6
index 3efca33e73..bd6dcef637 100644
@@ -258,14 +258,11 @@ 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
+	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
-		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
 	install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_unitdir}/systemd-sysv-install
 
@@ -539,7 +536,7 @@ python __anonymous() {
 # TODO:
 # u-a for runlevel and telinit
 
-ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel resolv-conf"
+ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel"
 
 ALTERNATIVE_TARGET[init] = "${rootlibexecdir}/systemd/systemd"
 ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
@@ -565,6 +562,7 @@ ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
 ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
 ALTERNATIVE_PRIORITY[runlevel] ?= "300"
 
+ALTERNATIVE_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolv-conf', '', d)}" <$%[email protected]('PACKAGECONFIG','resolved','resolv-conf','',d)%7D>
 ALTERNATIVE_TARGET[resolv-conf] = "${sysconfdir}/resolv-conf.systemd"
 ALTERNATIVE_LINK_NAME[resolv-conf] = "${sysconfdir}/resolv.conf"
 ALTERNATIVE_PRIORITY[resolv-conf] ?= "50"
 
 
--

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#4 lore raw

Hi Nicola,

I'd like to detail the current handling of resolv.conf below. This is the current resolv.conf handling logic.
But if you think there's something wrong about the logic, let me know.

/etc/resolv.conf would be created/written by multiple applications. In fact, any network manager is likely to handle it. Our goal is to 1) make sure /etc/resolv.conf always exists and 2) avoid conflicts among multiple application

In systemd, if 'resolved' is enabled, both '/run/systemd/resolve' directory and '/run/systemd/resolve/resolv.conf' file will be created by systemd-resolved. What we need is just to create a symlink to /run/systemd/resolve/resolv.conf.
That's why we have: ln -s ../run/systemd/resolve/resolv.conf ${D}${sysconfdir}/resolv-conf.systemd
So why /etc/resolv-conf.systemd instead of just /etc/resolv.conf? The answer is to avoid conflicts with other network managers.
If 'resolved' is not enabled, we still need to ensure the existence of /etc/resolv.conf. As it has been handled by the 'resolv-conf' ALTERNATIVE to point to /etc/resov-conf.systemd, we just need to ensure /etc/resolv-conf.systemd is not a dead link. That why we write 'd /run/systemd/resolve 0755 root root -' and 'f /run/systemd/resolve/resolv.conf 0644 root root'. That is to satisfy goal 1. If we have dropped goal 1, then such operation is not necessary. But I doubt there would be some problem if we don't satisfy goal 1.

Back to the code block in systemd recipe.

        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 -'

Quoted 1 line
Quoted 1 line

${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
                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

As we are using 'L' instead of 'L+', you can simply ignore the two lines, they are more likely to serve as fallbacks. So expressed in pseudo codes, the above logic is:
if reoslved is not enabled:
link /etc/resolv-conf.systemd to /run/systemd/resolve/resolv.conf
make sure /etc/resolv-conf.systemd is not a dead link
else:
link /etc/resolv-conf.systemd to /run/systemd/resolve/resolv.conf
# systemd-resolved handles /run/systemd/resolve/resolv.conf, so
nothing more needs to be done here

Best Regards,
Chen Qi

Quoted 213 lines · On 07/17/2018 06:05 PM, nick83ola wrote:

Hi

commit 00e4662e55f66570cae29240c22b4d74b79d3ca5
Author: Maxin B. John <[email protected]> <mailto:[email protected]>
Date: Mon Jun 12 18:10:21 2017 +0300

systemd: enable resolved and networkd

Enable systemd-resolved and systemd-networkd by default. Make it co-exist with connman and Fix associated problems in read-only rootfs.

This part of the patch does nothing with the current version of systemd (or does the wrong thing)

        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
fi

the check here was

     if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 

'false', d)}; then
apart from the part that the check is REVERSED ...
if the PACKAGECONFIG doesn't contain the resolved option systemd-resolved is not build and no modification is done on the /lib/tmpfiles/etc/conf

see
https://github.com/systemd/systemd/blob/46659f7deb962f55c728e70597e37c2a3ab6326d/tmpfiles.d/etc.conf.m4#L16
m4_ifdef(`ENABLE_RESOLVE',

L! /etc/resolv.conf - - - - ../run/systemd/resolve/stub-resolv.conf

)m4_dnl

So the else branch can be safely removed.

commit 669edd04432f8e76e32bd7f34f4d9aa63eef4038
Author: Khem Raj <[email protected]> <mailto:[email protected]>
Date: Fri Dec 16 14:07:31 2016 -0800

systemd: point to correct resolv.conf when resolved is enabled

latest systemd has changed the resolved defaults which points to 127.0.0.53 port 53 on local network. If someone wants to use host-local IP address then it can be pointed to copy in
/lib/systemd

(From OE-Core rev: 99d1199fd0961f94732a1a533d66472ca17cf6f5)

<mailto:[email protected]>

<mailto:[email protected]>
Signed-off-by: Richard Purdie
<[email protected]>
<mailto:[email protected]>

So here the error was introduced!!!!! read this patch carefully If you read the deleted comment it was saying:
*if resolved is disabled*,
But this patch reverse it to

systemd: point to correct resolv.conf when resolved *is enabled*

        if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 

'false', d)}; then
- # *if resolved is disabled*, it won't handle the link
of resolv.conf, so

(quoted diff) +0 -3
-               # set it up ourselves
-               ln -s ../run/resolv.conf ${D}${sysconfdir}/resolv.conf
-               echo '*L! ${sysconfdir}/resolv.conf - - - - 

../run/resolv.conf'* >>${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
- echo 'f /run/resolv.conf 0644 root root'

Quoted 1 line
Quoted 1 line

${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf

+ echo*'L! ${sysconfdir}/resolv.conf - - - -
../run/systemd/resolve/resolv.conf'*

Quoted 1 line
Quoted 1 line

${D}${exec_prefix}/lib/tmpfiles.d/etc.conf

+ echo 'd /run/systemd/resolve 0755 root root -'

Quoted 1 line
Quoted 1 line

${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

(quoted diff) +2 -0
+       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

        fi
        install -Dm 0755 

${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_unitdir}/systemd-sysv-install
}

commit b80da02ce9b683f96393fe0ea1f5f1a5f1a07c89
Author: Christopher Larson <[email protected]> <mailto:[email protected]>
Date: Wed Nov 4 20:19:19 2015 -0700

systemd: arrange for volatile /etc/resolv.conf

On sysvinit systems, volatiles is configured to make
/etc/resolv.conf symlink
to a file in a volatile path, which lets us write to
/etc/resolv.conf for
read-only-rootfs. For systemd, this isn't set up unless we enable systemd-resolved, which we don't by default. When it's not
enabled, create the
/etc/resolv.conf symlink and ensure the volatile path is
created on boot with
tmpfiles.d.

+ if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true',
'false', d)}; then
+ # if resolved is disabled, it won't handle the link of
resolv.conf, so

(quoted diff) +3 -0
+               # set it up ourselves
+               ln -s ../run/resolv.conf ${D}${sysconfdir}/resolv.conf
+               echo 'L! ${sysconfdir}/resolv.conf - - - - 

../run/resolv.conf' >>${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
+ echo 'f /run/resolv.conf 0644 root root'

Quoted 1 line
Quoted 1 line

${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf

+ fi

        install -Dm 0755 

${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_unitdir}/systemd-sysv-install
}

This patch was the right one the following 669edd04432f8e76e32bd7f34f4d9aa63eef4038 reversed the sense of the switch

Regards
Nicola Lunghi

    Best Regards,
    Chen Qi


    On 07/16/2018 04:17 PM, Nicola Lunghi wrote:
Quoted 50 lines
    From: Nicola Lunghi<[email protected]> <mailto:[email protected]>

    if resolved option is not selected the package systemd-resolved
    is not installed so it cannot provide an alternative for
    resolv.conf

    In this recipe the previous check was instead reversing the check (note the !).

    This patch avoid messing with resol.conf link if resolved is disabled in
    the package config.

    This in particular if we compile systemd with musl where systemd-resolved
    cannot be compiled.

    Signed-off-by: Nicola Lunghi<[email protected]> <mailto:[email protected]>
    ---
      meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb>  | 8 +++-----
      1 file changed, 3 insertions(+), 5 deletions(-)

    diff --git a/meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb>  b/meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb>
    index 3efca33e73..bd6dcef637 100644
    --- a/meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb>
    +++ b/meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb>
    @@ -258,14 +258,11 @@ 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
    +	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
    -		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
      	install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_unitdir}/systemd-sysv-install
      
    @@ -539,7 +536,7 @@ python __anonymous() {
      # TODO:
      # u-a for runlevel and telinit
      
    -ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel resolv-conf"
    +ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel"
      
      ALTERNATIVE_TARGET[init] = "${rootlibexecdir}/systemd/systemd"
      ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
    @@ -565,6 +562,7 @@ ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
      ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
Quoted 8 lines
      ALTERNATIVE_PRIORITY[runlevel] ?= "300"
      
    +ALTERNATIVE_${PN} +="${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolv-conf',
    '', d)}"
    <mailto:$%[email protected]%28%27PACKAGECONFIG%27,%27resolved%27,%27resolv-conf%27,%27%27,d%29%7D>
      ALTERNATIVE_TARGET[resolv-conf] = "${sysconfdir}/resolv-conf.systemd"
      ALTERNATIVE_LINK_NAME[resolv-conf] = "${sysconfdir}/resolv.conf"
      ALTERNATIVE_PRIORITY[resolv-conf] ?= "50"
    -- 
    _______________________________________________
    Openembedded-core mailing list
    [email protected]
    <mailto:[email protected]>
    http://lists.openembedded.org/mailman/listinfo/openembedded-core