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 <lichliu@redhat.com>
Acked-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
Lichen Liu 2023-10-30 14:51:59 +08:00 committed by Coiby Xu
parent cb761c7224
commit 741861164e

View File

@ -605,6 +605,10 @@ check_fs_modified()
is_system_modified() is_system_modified()
{ {
local ret 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 [[ -f $TARGET_INITRD ]] || return 1
@ -617,9 +621,15 @@ is_system_modified()
fi fi
fi fi
check_files_modified || return for _func in check_files_modified check_fs_modified check_drivers_modified; do
check_fs_modified || return $_func
check_drivers_modified ret=$?
# return immediately if an error occurred.
[[ $ret -eq "$CONF_ERROR" ]] && return "$ret"
[[ $ret -eq "$CONF_MODIFY" ]] && { conf_status="$CONF_MODIFY"; }
done
return $conf_status
} }
# need_initrd_rebuild - check whether the initrd needs to be rebuild # need_initrd_rebuild - check whether the initrd needs to be rebuild