From 37ee740cdef57371cc114c2a2a3828b0c62c1a16 Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 27 Aug 2024 11:35:40 +0200 Subject: [PATCH 1/4] netconsole: remove trailing whitespaces (cherry picked from commit 78c0af5bb90c76546878ed3ffcfe183b7dcae8a2) Resolves: RHEL-40660 --- usr/libexec/netconsole | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/usr/libexec/netconsole b/usr/libexec/netconsole index 3f2872dd2..26c9baabc 100755 --- a/usr/libexec/netconsole +++ b/usr/libexec/netconsole @@ -1,5 +1,5 @@ #!/bin/bash -# +# # netconsole This loads the netconsole module with the configured parameters. # # chkconfig: - 50 50 @@ -50,7 +50,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|")" @@ -63,9 +63,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 @@ -101,7 +101,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 @@ -140,7 +140,6 @@ status () fi } - restart () { stop @@ -152,7 +151,6 @@ condrestart () [ -e /var/lock/subsys/netconsole ] && restart } - case "$1" in stop) stop ;; status) status ;; From c1401ee4eb38e7daa0471bf5c31c842b851745b8 Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 27 Aug 2024 11:36:14 +0200 Subject: [PATCH 2/4] netconsole: remove unused variables (cherry picked from commit 293dbf2f00d0687a837662b27a52f4278274ef60) Resolves: RHEL-40660 --- usr/libexec/netconsole | 3 --- 1 file changed, 3 deletions(-) diff --git a/usr/libexec/netconsole b/usr/libexec/netconsole index 26c9baabc..20bee9d43 100755 --- a/usr/libexec/netconsole +++ b/usr/libexec/netconsole @@ -20,7 +20,6 @@ PATH=/sbin:/usr/sbin:$PATH RETVAL=0 -SERVER_ADDRESS_RESOLUTION= # Check that networking is up. . /etc/sysconfig/network @@ -36,8 +35,6 @@ SYSLOGADDR= SYSLOGPORT=514 SYSLOGMACADDR= -kernel=$(uname -r | cut -d. -f1-2) - usage () { echo $"Usage: $0 {start|stop|status|restart|condrestart}" 1>&2 From e57baf6399f0b45d82d0a3b2d3d9de3c8f2c2da4 Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 27 Aug 2024 11:36:49 +0200 Subject: [PATCH 3/4] netconsole: source sysconfig/network only if it exists 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 backwards compatibility). (cherry picked from commit ad2a578e27863930918ab5c3d88aab74b7ebc997) Resolves: RHEL-40660 --- usr/libexec/netconsole | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr/libexec/netconsole b/usr/libexec/netconsole index 20bee9d43..31ed526a3 100755 --- a/usr/libexec/netconsole +++ b/usr/libexec/netconsole @@ -21,8 +21,7 @@ PATH=/sbin:/usr/sbin:$PATH RETVAL=0 -# Check that networking is up. -. /etc/sysconfig/network +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network # Source function library. . /etc/rc.d/init.d/functions From 0739704bffda719e8202489a9d4034c26c65355d Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 27 Aug 2024 12:29:42 +0200 Subject: [PATCH 4/4] netconsole: var/lock -> run/lock /var/lock is a symlink to /run/lock, so let's use proper location (cherry picked from commit 91df03ef7a003767593f537c54c5399bee914195) Resolves: RHEL-40660 --- usr/libexec/netconsole | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/libexec/netconsole b/usr/libexec/netconsole index 31ed526a3..92c79c62d 100755 --- a/usr/libexec/netconsole +++ b/usr/libexec/netconsole @@ -112,7 +112,7 @@ start () $SYSLOGOPTS [ "$?" != "0" ] && RETVAL=1 fi - touch /var/lock/subsys/netconsole + touch /run/lock/subsys/netconsole } stop () @@ -122,7 +122,7 @@ stop () [ "$?" != "0" ] && RETVAL=1 fi - rm -f /var/lock/subsys/netconsole + rm -f /run/lock/subsys/netconsole } status () @@ -144,7 +144,7 @@ restart () condrestart () { - [ -e /var/lock/subsys/netconsole ] && restart + [ -e /run/lock/subsys/netconsole ] && restart } case "$1" in