kdumpctl: detect modification of scripts by its directory's timestamp
Checking modification against a file can not detect a removing file in "/etc/kdump/post.d/ /etc/kdump/pre.d/". Hence it also needs the modified time of directory to detect such changes. Signed-off-by: Pingfan Liu <piliu@redhat.com> Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
parent
bdbddbff73
commit
25824d64cd
7
kdumpctl
7
kdumpctl
@ -338,6 +338,7 @@ check_files_modified()
|
|||||||
|
|
||||||
EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
||||||
CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
||||||
|
HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/"
|
||||||
if [ -d /etc/kdump/post.d ]; then
|
if [ -d /etc/kdump/post.d ]; then
|
||||||
for file in /etc/kdump/post.d/*; do
|
for file in /etc/kdump/post.d/*; do
|
||||||
if [ -x "$file" ]; then
|
if [ -x "$file" ]; then
|
||||||
@ -352,9 +353,11 @@ check_files_modified()
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
HOOKS="$HOOKS $POST_FILES $PRE_FILES"
|
||||||
CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
||||||
CORE_COLLECTOR=`type -P $CORE_COLLECTOR`
|
CORE_COLLECTOR=`type -P $CORE_COLLECTOR`
|
||||||
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES $POST_FILES $PRE_FILES"
|
# POST_FILES and PRE_FILES are already checked against executable, need not to check again.
|
||||||
|
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
|
||||||
CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-`
|
CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-`
|
||||||
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
|
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
|
||||||
files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR"
|
files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR"
|
||||||
@ -385,6 +388,8 @@ check_files_modified()
|
|||||||
check_exist "$files" && check_executable "$EXTRA_BINS"
|
check_exist "$files" && check_executable "$EXTRA_BINS"
|
||||||
[ $? -ne 0 ] && return 2
|
[ $? -ne 0 ] && return 2
|
||||||
|
|
||||||
|
# HOOKS only need to check the modification here
|
||||||
|
files="$files $HOOKS"
|
||||||
for file in $files; do
|
for file in $files; do
|
||||||
if [ -e "$file" ]; then
|
if [ -e "$file" ]; then
|
||||||
time_stamp=`stat -c "%Y" $file`
|
time_stamp=`stat -c "%Y" $file`
|
||||||
|
Loading…
Reference in New Issue
Block a user