Skip to content

Commit

Permalink
fix(network-legacy): check if dhclient has --timeout option
Browse files Browse the repository at this point in the history
dhclient's --timeout option is not upstream, so a pre-check is needed before
using it.
  • Loading branch information
aafeijoo-suse authored and johannbg committed Oct 21, 2022
1 parent 699e394 commit 23654c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules.d/35network-legacy/dhcp-multi.sh
Expand Up @@ -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" \
Expand Down
7 changes: 7 additions & 0 deletions modules.d/35network-legacy/ifup.sh
Expand Up @@ -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
Expand Down

0 comments on commit 23654c5

Please sign in to comment.