Skip to contentSkip to conversation

dhcpcd fixes

PATCH In review Yi Zhao 2 participants 7 messages Sep 23, 2020 – Sep 24, 2020

lore
Share & tools
lore

Yi Zhao

author
#0 lore raw

v2 cover dhcpcd fixes

Yi Zhao (4):
dhcpcd: pass --dbdir to EXTRA_OECONF to set database directory
dhcpcd: set --runstatedir to /run
dhcpcd: add dhcpcd user to support priviledge separation
dhcpcd: disable service to start on boot automatically

 meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb   | 14 ++++++++++++--
 .../dhcpcd/files/[email protected]                   |  2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/4 dhcpcd: pass --dbdir to EXTRA_OECONF to set database directory

Set --dbdir to /var/lib/dhcpcd rather than /var/db/dhcpcd to satisfy FHS compliance

---
 meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb +3 -1
index 292cb5b008..3e1a83912a 100644
@@ -28,7 +28,9 @@ PACKAGECONFIG ?= "udev ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
 PACKAGECONFIG[udev] = "--with-udev,--without-udev,udev,udev"
 PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6"
 
-EXTRA_OECONF = "--enable-ipv4"
+EXTRA_OECONF = "--enable-ipv4 \
+                --dbdir=${localstatedir}/lib/${BPN} \
+               "
 
 do_install_append () {
     # install systemd unit files
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v2 2/4 dhcpcd: set --runstatedir to /run

In reply to Yi Zhao

Set --runstatedir to /run/dhcpcd rather than /var/run/dhcpcd

---
 meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb       | 1 +
 meta/recipes-connectivity/dhcpcd/files/[email protected] | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb +1 -0
index 3e1a83912a..557e15128e 100644
@@ -30,6 +30,7 @@ PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6"
 
 EXTRA_OECONF = "--enable-ipv4 \
                 --dbdir=${localstatedir}/lib/${BPN} \
+                --runstatedir=/run \
                "
 
 do_install_append () {
meta/recipes-connectivity/dhcpcd/files/[email protected] +1 -1
index c81bb05ea5..3543e6c3d2 100644
@@ -7,7 +7,7 @@ After=sys-subsystem-net-devices-%i.device
 
 [Service]
 Type=forking
-PIDFile=/run/dhcpcd-%I.pid
+PIDFile=/run/dhcpcd/%I.pid
 ExecStart=/usr/sbin/dhcpcd -q %I
 ExecStop=/usr/sbin/dhcpcd -x %I
 
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH v2 3/4 dhcpcd: add dhcpcd user to support priviledge separation

In reply to Yi Zhao

The dhcpcd enables privsep by default. It requires a user added to the system. Add dhcpcd user and group to support it.

---
 meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb +7 -1
index 557e15128e..4344841b54 100644
@@ -19,7 +19,7 @@ SRC_URI = "https://roy.marples.name/downloads/${BPN}/${BPN}-${PV}.tar.xz \
 
 SRC_URI[sha256sum] = "fcb2d19672d445bbfd38678fdee4f556ef967a3ea6bd81092d10545df2cb9666"
 
-inherit pkgconfig autotools-brokensep systemd
+inherit pkgconfig autotools-brokensep systemd useradd
 
 SYSTEMD_SERVICE_${PN} = "dhcpcd.service"
 
@@ -33,10 +33,16 @@ EXTRA_OECONF = "--enable-ipv4 \
                 --runstatedir=/run \
                "
 
+USERADD_PACKAGES = "${PN}"
+USERADD_PARAM_${PN} = "--system -d ${localstatedir}/lib/${BPN} -M -s /bin/false -U dhcpcd"
+
 do_install_append () {
     # install systemd unit files
     install -d ${D}${systemd_unitdir}/system
     install -m 0644 ${WORKDIR}/dhcpcd*.service ${D}${systemd_unitdir}/system
+
+    chmod 700 ${D}${localstatedir}/lib/${BPN}
+    chown dhcpcd:dhcpcd ${D}${localstatedir}/lib/${BPN}
 }
 
 FILES_${PN}-dbg += "${libdir}/dhcpcd/dev/.debug"
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v2 4/4 dhcpcd: disable service to start on boot automatically

In reply to Yi Zhao

As the default network manager, connman has its own internal DHCP implement. The dhcpcd may conflict with connman if the service start on boot automatically.

---
 meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb +1 -0
index 4344841b54..dd473cd815 100644
@@ -22,6 +22,7 @@ SRC_URI[sha256sum] = "fcb2d19672d445bbfd38678fdee4f556ef967a3ea6bd81092d10545df2
 inherit pkgconfig autotools-brokensep systemd useradd
 
 SYSTEMD_SERVICE_${PN} = "dhcpcd.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
 
 PACKAGECONFIG ?= "udev ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
 
Signature · 1 line
2.17.1
#5 lore raw

Re: [OE-core] [PATCH 4/4] dhcpcd: disable service to start on boot automatically

Quoted 14 lines · Yi Zhao

As the default network manager, connman has its own internal DHCP implement. The dhcpcd may conflict with connman if the service start on boot automatically.

---
 meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb +0 -0
index 4344841b54..dd473cd815 100644

meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb SRC_URI[sha256sum] = "fcb2d19672d445bbfd38678fdee4f556ef967a3ea6bd81092d10545df2 · line 28

Quoted 7 lines
meta/recipes-connectivity/dhcpcd/dhcpcd_9.2.0.bb +1 -0
@@ -22,6 +22,7 @@ SRC_URI[sha256sum] = "fcb2d19672d445bbfd38678fdee4f556ef967a3ea6bd81092d10545df2
 inherit pkgconfig autotools-brokensep systemd useradd
 
 SYSTEMD_SERVICE_${PN} = "dhcpcd.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
 
 PACKAGECONFIG ?= "udev ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
 

Rather than just disabling it, is there a way to "only enable if connman isn't present"? I'd imagine there is some kind of unit file setting for that?

(the other patches look good, thanks!)

Cheers,

Richard

author
#6 lore raw

PATCH v3 1/1 dhcpcd: set service to conflict with connman

As the default network manager, connman has its own internal DHCP implement. If run dhcpcd and connman simultaneously, they may conflict with each other.

---
 meta/recipes-connectivity/dhcpcd/files/dhcpcd.service  | 1 +
 meta/recipes-connectivity/dhcpcd/files/[email protected] | 1 +
 2 files changed, 2 insertions(+)
meta/recipes-connectivity/dhcpcd/files/dhcpcd.service +1 -0
index 86b5a43c37..bbed6d85c4 100644
@@ -2,6 +2,7 @@
 Description=A minimalistic network configuration daemon with DHCPv4, rdisc and DHCPv6 support
 Wants=network.target
 Before=network.target
+Conflicts=connman.service
 
 [Service]
 ExecStart=/usr/sbin/dhcpcd -q --nobackground
meta/recipes-connectivity/dhcpcd/files/[email protected] +1 -0
index 3543e6c3d2..389b076c38 100644
@@ -4,6 +4,7 @@ Wants=network.target
 Before=network.target
 BindsTo=sys-subsystem-net-devices-%i.device
 After=sys-subsystem-net-devices-%i.device
+Conflicts=connman.service
 
 [Service]
 Type=forking
Signature · 1 line
2.17.1