Skip to content

Commit

Permalink
netconsole: source sysconfig/network only if it exists
Browse files Browse the repository at this point in the history
Although the comment said "check if network is up",
the code only sourced the configuration file, but did not fail
if it did not exist and happily continued.

Also on current versions of Fedora, the sysconfig/network
does not exist by default, so you see a warning message
when you start the service.

So let's just check if the file exists and only source it
if it does (for backward compatibility).
  • Loading branch information
lnykryn committed Aug 27, 2024
1 parent 67743ca commit 9819251
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions usr/libexec/netconsole
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
#
#
# netconsole This loads the netconsole module with the configured parameters.
#
# chkconfig: - 50 50
Expand All @@ -22,8 +22,7 @@ PATH=/sbin:/usr/sbin:$PATH
RETVAL=0
SERVER_ADDRESS_RESOLUTION=

# Check that networking is up.
. /etc/sysconfig/network
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network

# Source function library.
. /etc/rc.d/init.d/functions
Expand All @@ -50,7 +49,7 @@ print_address_info ()
local route via target

route=$(LANG=C ip -o route get to $host/32)

[ -z "$DEV" ] && DEV=$(echo $route | sed "s|.* dev \([^ ]*\).*|\1|")
echo "DEV=$DEV"
echo "LOCALADDR=$(echo $route | sed "s|.* src \([^ ]*\).*|\1|")"
Expand All @@ -63,9 +62,9 @@ print_address_info ()
if [ -z "$SYSLOGMACADDR" ]; then
arp=$(LANG=C /sbin/arping -f -c 1 -I $DEV $target 2>/dev/null | awk '/ reply from .*[.*]/ { print gensub(".* reply from .* \\[(.*)\\].*","\\1","G"); exit }')
[ -n "$arp" ] && echo "SYSLOGMACADDR=$arp"
fi
}
fi
}

start ()
{
[ -f /etc/sysconfig/netconsole ] || exit 6
Expand Down Expand Up @@ -101,7 +100,7 @@ start ()
exit 6
fi
eval $(print_address_info $SYSLOGADDR)

if [ -z "$SYSLOGMACADDR" ]; then
echo $"netconsole: can't resolve MAC address of $SYSLOGADDR" 1>&2
exit 1
Expand Down

0 comments on commit 9819251

Please sign in to comment.