Skip to content

Commit 23654c5

Browse files
aafeijoo-susejohannbg
authored andcommitted
fix(network-legacy): check if dhclient has --timeout option
dhclient's --timeout option is not upstream, so a pre-check is needed before using it.
1 parent 699e394 commit 23654c5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ do_dhclient() {
2121
_timeout=$(getarg rd.net.timeout.dhcp=)
2222
_DHCPRETRY=$(getargnum 1 1 1000000000 rd.net.dhcp.retry=)
2323

24+
if [ -n "$_timeout" ]; then
25+
if ! (dhclient --help 2>&1 | grep -q -F -- '--timeout' 2> /dev/null); then
26+
warn "rd.net.timeout.dhcp has no effect because dhclient does not implement the --timeout option"
27+
unset _timeout
28+
fi
29+
fi
30+
2431
while [ $_COUNT -lt "$_DHCPRETRY" ]; do
2532
info "Starting dhcp for interface $netif"
2633
dhclient "$arg" \

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ do_dhcp() {
7373
return 1
7474
fi
7575

76+
if [ -n "$_timeout" ]; then
77+
if ! (dhclient --help 2>&1 | grep -q -F -- '--timeout' 2> /dev/null); then
78+
warn "rd.net.timeout.dhcp has no effect because dhclient does not implement the --timeout option"
79+
unset _timeout
80+
fi
81+
fi
82+
7683
if [ ! -e /run/NetworkManager/conf.d/10-dracut-dhclient.conf ]; then
7784
mkdir -p /run/NetworkManager/conf.d
7885
echo '[main]' > /run/NetworkManager/conf.d/10-dracut-dhclient.conf

0 commit comments

Comments
 (0)