From ee18dd2b88d6767902d442baa92c95f7be69c265 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Fri, 17 Aug 2018 12:50:29 +0200
Subject: [PATCH] ifcfg/write-ifcfg.sh: aggregate resolv.conf
The old code used /tmp/net.$netif.resolv.conf with $netif being randomly
chosen.
As it is not known which nameserver have which priority, just sort them
and deduplicate.
---
modules.d/45ifcfg/module-setup.sh | 1 +
modules.d/45ifcfg/write-ifcfg.sh | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/modules.d/45ifcfg/module-setup.sh b/modules.d/45ifcfg/module-setup.sh
index 6791985a..c89def3e 100755
--- a/modules.d/45ifcfg/module-setup.sh
+++ b/modules.d/45ifcfg/module-setup.sh
@@ -14,6 +14,7 @@ depends() {
# called by dracut
install() {
+ inst_binary sort
inst_hook pre-pivot 85 "$moddir/write-ifcfg.sh"
}
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
index 25c81be3..3bf847a5 100755
--- a/modules.d/45ifcfg/write-ifcfg.sh
+++ b/modules.d/45ifcfg/write-ifcfg.sh
@@ -286,7 +286,10 @@ echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
{
cp /tmp/net.* /run/initramfs/
- cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
+ for i in /tmp/net.*.resolv.conf; do
+ [ -f "$i" ] && cat "$i"
+ done | sort -u > /run/initramfs/state/etc/resolv.conf
+ [ -s /run/initramfs/state/etc/resolv.conf ] || rm -f /run/initramfs/state/etc/resolv.conf
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
} > /dev/null 2>&1