File 0628-ifup.sh-fix-did-setup-logic-and-dhcp-return-value.patch of Package dracut.18204

From 12131e2c360e7d40cd4a3370d91ac6f329123d57 Mon Sep 17 00:00:00 2001
From: Thomas Blume <Thomas.Blume@suse.com>
Date: Tue, 15 Sep 2020 08:04:34 +0200
Subject: [PATCH] ifup.sh: fix did-setup logic and dhcp return value

don't create $netif.did-setup files, this is done by net-lib

fix return value parsing for dhcp
---
 modules.d/40network/ifup.sh | 39 +++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
index 33f07ebb..06c28743 100755
--- a/modules.d/40network/ifup.sh
+++ b/modules.d/40network/ifup.sh
@@ -575,13 +575,14 @@ for p in $(getargs ip=); do
         esac
     done
 
-    if [ $? -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}*)" ]; then
+
+    if [ $? -eq 0 ]; then
+        bring_online
+
         > /tmp/net.$netif.did-setup
        [ -z "$DO_VLAN" ] && \
        [ -e /sys/class/net/$netif/address ] && \
        > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
-
-        bring_online
     fi
 done
 
@@ -593,30 +594,44 @@ if [ -n "$DO_BOND_SETUP" -o -n "$DO_TEAM_SETUP" -o -n "$DO_VLAN_SETUP" ]; then
 fi
 
 # no ip option directed at our interface?
-if [ ! -e /tmp/net.${netif}.up ]; then
+if [ -z "$NO_AUTO_DHCP" ] && [ ! -e /tmp/net.${netif}.up ]; then
+    ret=1
     if [ -e /tmp/net.bootdev ]; then
         BOOTDEV=$(cat /tmp/net.bootdev)
         if [ "$netif" = "$BOOTDEV" ] || [ "$BOOTDEV" = "$(cat /sys/class/net/${netif}/address)" ]; then
-            load_ipv6
             do_dhcp
+            ret=$?
         fi
     else
-        if getargs 'ip=dhcp6'; then
+        # No ip lines, no bootdev -> default to dhcp
+        ip=$(getarg ip)
+
+        if getargs 'ip=dhcp6' || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then
             load_ipv6
             do_dhcp -6
+            ret=$?
         fi
-        if getargs 'ip=dhcp' && [ "$autoconf" != "dhcp" ]; then
+        if getargs 'ip=dhcp' || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then
             do_dhcp -4
+            ret=$?
         fi
     fi
-    if [ $? -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}*)" ]; then
-        bring_online
+
+    for s in $(getargs nameserver); do
+        [ -n "$s" ] || continue
+        echo nameserver $s >> /tmp/net.$netif.resolv.conf
+    done
+
+    if [ "$ret" -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}*)" ]; then
+         bring_online
+
+         if [ -e /sys/class/net/${netif}/address ]; then
+             > /tmp/net.$(cat /sys/class/net/${netif}/address).did-setup
+         fi
     fi
 fi
 
-if [ -e /tmp/net.${netif}.up ]; then
-    > /tmp/net.$netif.did-setup
-    [ -e /sys/class/net/$netif/address ] && \
+if [ -e /tmp/net.${netif}.up ] && [ -e /sys/class/net/$netif/address ]; then
         > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
 fi
 exit 0
-- 
2.26.2

openSUSE Build Service is sponsored by