dhclient initramfs code writes invalid net-eth0.conf

Bug #1840965 reported by Alkis Georgopoulos
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
isc-dhcp (Ubuntu)
Fix Released
High
Unassigned
Eoan
Fix Released
High
Unassigned

Bug Description

Since 18.10, Ubuntu switched to using dhclient instead of ipconfig in initramfs configure_networking(). And now a malformed /run/net-enp0s3.conf is generated, with unquoted values like the following, which are a shell syntax error:
IPV4DNS0=1.2.3.1 1.2.3.2 1.2.3.3

This file is sourced by initramfs-tools/init in various places, and produces the following message a lot of times:
/init: /run/net-enp0s3.conf: line 8: 1.2.3.2: not found

I.e. values should be quoted, and 2 DNS entries should go in IPV4DNS0/IPV4DNS1, not multiple unquoted ones in IPV4DNS0.

Here is the erroneous file that dhclient-enter-hooks.d/config produces:
DEVICE=enp0s3
PROTO=dhcp
IPV4PROTO=dhcp
IPV4ADDR=10.161.254.38
IPV4NETMASK=255.255.255.0
IPV4BROADCAST=10.161.254.255
IPV4GATEWAY=10.161.254.1
IPV4DNS0=194.63.237.4 194.63.239.164 194.63.238.4
ROOTSERVER=10.161.254.1
HOSTNAME=
DNSDOMAIN=

Here is the correct one that ipconfig produces:
DEVICE='enp0s3'
PROTO='dhcp'
IPV4ADDR='10.161.254.38'
IPV4BROADCAST='10.161.254.255'
IPV4NETMASK='255.255.255.0'
IPV4GATEWAY='10.161.254.1'
IPV4DNS0='194.63.237.4'
IPV4DNS1='194.63.239.164'
HOSTNAME=''
DNSDOMAIN=''
NISDOMAIN=''
ROOTSERVER='10.161.254.1'
ROOTPATH=''
filename=''
UPTIME='594'
DHCPLEASETIME='25200'
DOMAINSEARCH=''

I.e. please either fix dhclient-enter-hooks.d/config, or revert the ipconfig => dhclient change.

Related branches

description: updated
Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

Using Ubuntu live CDs, I verified that this did not happen in 18.04 and happens in both 18.10 and 19.04.

Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

The code that generates the invalid /run/net-enp0s3.conf belongs in the Ubuntu isc-dhcp package, and specifically in debian/initramfs-tools/lib/etc/dhcp/dhclient-enter-hooks.d/config.

It got in effect in 18.10 when initramfs-tools in Ubuntu switched to calling dhclient instead of ipconfig.

Additionally, dhclient-script calls `chmod --reference=/etc/resolv.conf $new_resolv_conf`, but busybox chmod doesn't support the --reference parameter.

I.e. dhclient has numerous issues that need to be fixed, otherwise the ipconfig => dhclient change should be reverted...

Thank you.

description: updated
summary: - netplan initramfs code writes invalid net-eth0.conf
+ dhclient initramfs code writes invalid net-eth0.conf
Steve Langasek (vorlon)
Changed in isc-dhcp (Ubuntu):
status: New → Triaged
importance: Undecided → High
Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

I'm attaching a patch for dhclient-enter-hooks.d/config.
I thought to imitate ipconfig and write all values even if they're empty.

For the debian/dhclient-script.* scripts which use chmod/chown parameters that aren't available in busybox, it might be best to just omit them, or use `cp/rm` instead of `chown/mv`.
`cp` is supposed to preserve target attributes etc, so it'll work in a real system, even if `busybox cp` doesn't do that.

no longer affects: netplan
Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

I just noticed that the original script used tabs instead of spaces;
I'm attaching a new .diff that respects that.

tags: added: patch
Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

I uploaded my patch as a merge proposal instead.

tags: added: id-5d6458d075c1a113cb9c2e57
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package isc-dhcp - 4.4.1-2ubuntu5

---------------
isc-dhcp (4.4.1-2ubuntu5) eoan; urgency=medium

  * Apply patch from Alkis Georgopoulos to generate correct
    net{,6}-${iface}.conf files when DHCP supplies multiple DNS servers.
    (LP: #1840965).

 -- Michael Hudson-Doyle <email address hidden> Tue, 03 Sep 2019 10:10:56 +1200

Changed in isc-dhcp (Ubuntu Eoan):
status: Triaged → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in initramfs-tools (Ubuntu):
status: New → Confirmed
no longer affects: initramfs-tools (Ubuntu)
no longer affects: initramfs-tools (Ubuntu Eoan)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.