]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(network-legacy): check if dhclient has --timeout option
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Mon, 11 Jul 2022 14:14:42 +0000 (16:14 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Fri, 21 Oct 2022 22:25:39 +0000 (22:25 +0000)
dhclient's --timeout option is not upstream, so a pre-check is needed before
using it.

modules.d/35network-legacy/dhcp-multi.sh
modules.d/35network-legacy/ifup.sh

index df091a521fb5849820a05a156b505c0ca85f9131..1c1415a3d27b4280663f3fc88ae9b366002d26ae 100755 (executable)
@@ -21,6 +21,13 @@ do_dhclient() {
     _timeout=$(getarg rd.net.timeout.dhcp=)
     _DHCPRETRY=$(getargnum 1 1 1000000000 rd.net.dhcp.retry=)
 
+    if [ -n "$_timeout" ]; then
+        if ! (dhclient --help 2>&1 | grep -q -F -- '--timeout' 2> /dev/null); then
+            warn "rd.net.timeout.dhcp has no effect because dhclient does not implement the --timeout option"
+            unset _timeout
+        fi
+    fi
+
     while [ $_COUNT -lt "$_DHCPRETRY" ]; do
         info "Starting dhcp for interface $netif"
         dhclient "$arg" \
index 0dc9541c8b26a4c53900ef667be135edbab90d02..df4059615927b68e40b60157e84294095d8c4d38 100755 (executable)
@@ -73,6 +73,13 @@ do_dhcp() {
         return 1
     fi
 
+    if [ -n "$_timeout" ]; then
+        if ! (dhclient --help 2>&1 | grep -q -F -- '--timeout' 2> /dev/null); then
+            warn "rd.net.timeout.dhcp has no effect because dhclient does not implement the --timeout option"
+            unset _timeout
+        fi
+    fi
+
     if [ ! -e /run/NetworkManager/conf.d/10-dracut-dhclient.conf ]; then
         mkdir -p /run/NetworkManager/conf.d
         echo '[main]' > /run/NetworkManager/conf.d/10-dracut-dhclient.conf