From 02202aa70fb5230660348882f0466a6f3b9809c2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 19 Jan 2021 20:10:28 +0800 Subject: [PATCH] logger: source the logger file individually Sourcing logger file in kdump-lib.sh will leak kdump helper to dracut, because module-setup.sh will source kdump-lib.sh. This will make kdump's function override dracut's ones, and lead to unexpected behaviours. So include kdump-logger.sh individually and only source it where it really needed. for module-setup.sh, simply use dracut's logger helper is good enough so just source kdump-logger.sh in kdump only scripts. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-early-kdump.sh | 1 + kdump-dep-generator.sh | 1 + kdump-lib-initramfs.sh | 1 + kdump-lib.sh | 6 ------ kdumpctl | 1 + mkdumprd | 1 + 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index a4e14a4..129841e 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -12,6 +12,7 @@ EARLY_KEXEC_ARGS="" . /etc/sysconfig/kdump . /lib/dracut-lib.sh . /lib/kdump-lib.sh +. /lib/kdump-logger.sh #initiate the kdump logger dlog_init diff --git a/kdump-dep-generator.sh b/kdump-dep-generator.sh index b6fab2d..f48c8f6 100644 --- a/kdump-dep-generator.sh +++ b/kdump-dep-generator.sh @@ -4,6 +4,7 @@ # http://www.freedesktop.org/wiki/Software/systemd/Generators/ . /usr/lib/kdump/kdump-lib.sh +. /usr/lib/kdump/kdump-logger.sh # If invokded with no arguments for testing purpose, output to /tmp to # avoid overriding the existing. diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index cd9d512..059ff20 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,6 +1,7 @@ # These variables and functions are useful in 2nd kernel . /lib/kdump-lib.sh +. /lib/kdump-logger.sh KDUMP_PATH="/var/crash" KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log" diff --git a/kdump-lib.sh b/kdump-lib.sh index 0e38580..d2801da 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -8,12 +8,6 @@ FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" -if [ -f /lib/kdump/kdump-logger.sh ]; then - . /lib/kdump/kdump-logger.sh -elif [ -f /lib/kdump-logger.sh ]; then - . /lib/kdump-logger.sh -fi - is_fadump_capable() { # Check if firmware-assisted dump is enabled diff --git a/kdumpctl b/kdumpctl index 2e7f842..24f5cf7 100755 --- a/kdumpctl +++ b/kdumpctl @@ -34,6 +34,7 @@ fi [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut . $dracutbasedir/dracut-functions.sh . /lib/kdump/kdump-lib.sh +. /lib/kdump/kdump-logger.sh #initiate the kdump logger dlog_init diff --git a/mkdumprd b/mkdumprd index 8ba8e2a..c34b79c 100644 --- a/mkdumprd +++ b/mkdumprd @@ -13,6 +13,7 @@ fi [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut . $dracutbasedir/dracut-functions.sh . /lib/kdump/kdump-lib.sh +. /lib/kdump/kdump-logger.sh export IN_KDUMP=1 #initiate the kdump logger