From 4ab1df86719fb9d2b86936b88beb05cf0db5adf6 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Nov 21 2023 03:56:17 +0000 Subject: kdumpctl: Only returns immediately after an error occurs in check_*_modified Resolves: https://issues.redhat.com/browse/RHEL-10484 Upstream: Fedora Conflict: Missing upstream patch d4e8772("kdumpctl: make do_estimate more robust") commit 741861164e24247e995d47a8284b7493cb73b769 Author: Lichen Liu Date: Mon Oct 30 14:51:59 2023 +0800 kdumpctl: Only returns immediately after an error occurs in check_*_modified Currently is_system_modified will return immediately when check_*_modified return a non-zero value, and the remaining checks will not be executed. For example, if there is a fs-related error exists, and someone changes the kdump.conf, check_files_modified will return 1 and is_system_modified will return 1 immediately. This will cause kdumpctl to skip check_fs/drivers_modified, kdump.service will rebuild the initrd and start successfully, however, any errors should prevent kdump.service from starting. This patch will cause check_*_modifed to continue running until an error occurs or all execution ends. Signed-off-by: Lichen Liu Acked-by: Tao Liu Signed-off-by: Lichen Liu --- diff --git a/kdumpctl b/kdumpctl index fb5b35a..503e44e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -532,28 +532,22 @@ check_fs_modified() check_system_modified() { local ret + local CONF_ERROR=2 + local CONF_MODIFY=1 + local CONF_NO_MODIFY=0 + local conf_status=$CONF_NO_MODIFY [[ -f $TARGET_INITRD ]] || return 1 - check_files_modified - ret=$? - if [[ $ret -ne 0 ]]; then - return $ret - fi - - check_fs_modified - ret=$? - if [[ $ret -ne 0 ]]; then - return $ret - fi - - check_drivers_modified - ret=$? - if [[ $ret -ne 0 ]]; then - return $ret - fi + for _func in check_files_modified check_fs_modified check_drivers_modified; do + $_func + ret=$? + # return immediately if an error occurred. + [[ $ret -eq "$CONF_ERROR" ]] && return "$ret" + [[ $ret -eq "$CONF_MODIFY" ]] && { conf_status="$CONF_MODIFY"; } + done - return 0 + return $conf_status } check_rebuild()