From 84d1cd07073f828fd52cb2759817e2245619ea67 Mon Sep 17 00:00:00 2001 From: Thomas Wouters Date: Wed, 13 Nov 2024 14:09:59 +0100 Subject: [PATCH] Fix dhcpcd failing on systemd-resolved stub dhcpcd fails to update /etc/resolv.conf if is a dangling symlink, so remove it if it is. This happens on Arch Linux when systemd-resolved is enabled by symlinking /etc/resolv.conf to /run/systemd/resolve/stub-resolv.conf. The symlink is copied into the supermin appliance, but the target file is not and this causes dhcpcd to fail when it tries to update /etc/resolv.conf. The handling of /etc/resolv.conf could be improved in dhcpcd but it's not their job to decide when to remove the symlink. We do have the authority to decide whether or not to use systemd-resolved or resolvconf in the appliance, so we can remove it. --- appliance/init | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appliance/init b/appliance/init index dae06dbbe..6189f311b 100755 --- a/appliance/init +++ b/appliance/init @@ -115,6 +115,10 @@ if test "$guestfs_network" = 1; then # Two workarounds for Ubuntu: touch /etc/fstab rm -f /etc/dhcp/dhclient-enter-hooks.d/resolved + # Prevent dhcpcd from failing when /etc/resolv.conf is a dangling symlink. + if [ -L "/etc/resolv.conf" ] && [ ! -e "/etc/resolv.conf" ]; then + rm -f /etc/resolv.conf + fi if dhclient --version >/dev/null 2>&1; then dhclient $iface elif dhcpcd $iface; then