From 5f3855f6f53b976dc220fcabc3bd3692c62d00f2 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 14 Dec 2015 18:12:09 +1100 Subject: [PATCH] yum-minimal: leave behind dummy /etc/resolv.conf As described in the comment, systemd will create a broken /etc/resolv.conf link if there is no file in the base-image (as you can read in the bug, it is debated if this is a bug or a feature). The solution is to leave a dummy /etc/resolv.conf file in the image. Whatever network manager you choose (NetworkManager, glean, cloud-config, etc) will overwrite this anyway. It's just that some tools, such as dhclient, get confused with the broken symlink. This affects you if you're using glean to configure the network in a DHCP situation, for example -- dhclient won't configure nameservers and everything goes to heck. Change-Id: I734834d03e7fdb13f9ab2e86f877b07bf4a84ff9 --- elements/yum-minimal/root.d/08-yum-chroot | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/elements/yum-minimal/root.d/08-yum-chroot b/elements/yum-minimal/root.d/08-yum-chroot index ec22e0bf..10f76c31 100755 --- a/elements/yum-minimal/root.d/08-yum-chroot +++ b/elements/yum-minimal/root.d/08-yum-chroot @@ -169,10 +169,18 @@ else --setopt=cachedir=/tmp/yum/$ARCH/$DIB_RELEASE \ install passwd findutils sudo util-linux-ng + # Put in a dummy /etc/resolv.conf over the temporary one we used + # to bootstrap. systemd has a bug/feature [1] that it will assume + # you want systemd-networkd as the network manager and create a + # broken symlink to /run/... if the base image doesn't have one. + # This broken link confuses things like dhclient. + # [1] https://bugzilla.redhat.com/show_bug.cgi?id=1197204 + echo -e "# This file intentionally left blank\n" | \ + sudo tee $TARGET_ROOT/etc/resolv.conf + # cleanup # TODO : move this into a exit trap; and reconsider how # this integrates with the global exit cleanup path. - sudo rm $TARGET_ROOT/etc/resolv.conf sudo umount $TMP_MOUNT_PATH/tmp/yum sudo umount $TARGET_ROOT/proc sudo umount $TARGET_ROOT/dev/pts