On Wed, Nov 6, 2019 at 12:27 PM onitsuka.shinic@fujitsu.com onitsuka.shinic@fujitsu.com wrote:
This patch checks the update of the binary and script files in /etc/kdump/{pre.d,post.d} for initramfs of kdump. When kdumpd service is started or restarted, initramfs of kdump is recreated by new the binary and script files, if the binary and script files in /etc/kdump/{pre.d,post.d} are updated.
Signed-off-by: shin-onitsuka <onitsuka.shinic@fujitsu.com>
kdumpctl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index f75b820..136fd36 100755 --- a/kdumpctl +++ b/kdumpctl @@ -335,9 +335,19 @@ check_files_modified()
EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2`
if [ -d /etc/kdump/post.d ]; then
for file in `find /etc/kdump/post.d -type f`; do
Instead of `find /etc/kdump/post.d -type f`, will it be better to only find executable files? And also only files with *.sh name. Else if there is some permission problem, it will occur later in initramfs anyway, better to fail early.
POST_FILES="$POST_FILES $file"
done
fi
if [ -d /etc/kdump/pre.d ]; then
for file in `find /etc/kdump/pre.d -type f`; do
PRE_FILES="$PRE_FILES $file"
done
fi CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2` CORE_COLLECTOR=`type -P $CORE_COLLECTOR`
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES $POST_FILES $PRE_FILES" CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR"
It seems there is a small issue with this design, if the file in /etc/kdump/{pre.d,post.d} is copied there preserving the timestamp, then "kdumpctl restart" won't rebuild the initramfs even if the file is missing in initramfs.
And kdumpctl restart won't check if the commands called by the script is updated.
-- Best Regards, Kairui Song
-----Original Message----- From: Kairui Song [mailto:kasong@redhat.com] Sent: Tuesday, November 12, 2019 6:07 PM To: Onitsuka, Shinichi/鬼束 伸一 onitsuka.shinic@fujitsu.com Cc: kexec@lists.fedoraproject.org Subject: Re: [PATCH 2/3] kdumpctl: Check the update of the binary and script files in /etc/kdump/{pre.d,post.d}
On Wed, Nov 6, 2019 at 12:27 PM onitsuka.shinic@fujitsu.com onitsuka.shinic@fujitsu.com wrote:
This patch checks the update of the binary and script files in /etc/kdump/{pre.d,post.d} for initramfs of kdump. When kdumpd service is started or restarted, initramfs of kdump is recreated by new the binary and script files, if the binary and script files in /etc/kdump/{pre.d,post.d} are updated.
Signed-off-by: shin-onitsuka <onitsuka.shinic@fujitsu.com>
kdumpctl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index f75b820..136fd36 100755 --- a/kdumpctl +++ b/kdumpctl @@ -335,9 +335,19 @@ check_files_modified()
EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2`
if [ -d /etc/kdump/post.d ]; then
for file in `find /etc/kdump/post.d -type f`; do
Instead of `find /etc/kdump/post.d -type f`, will it be better to only find executable files? And also only files with *.sh name. Else if there is some permission problem, it will occur later in initramfs anyway, better to fail early.
I agree to add checking execution bit, but it seems to me that filtering *.sh seems overkill. I think users want put various kind of execution files other than shell scripts.
POST_FILES="$POST_FILES $file"
done
fi
if [ -d /etc/kdump/pre.d ]; then
for file in `find /etc/kdump/pre.d -type f`; do
PRE_FILES="$PRE_FILES $file"
done
fi CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut
-d\ -f2`
CORE_COLLECTOR=`type -P $CORE_COLLECTOR`
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES $POST_FILES $PRE_FILES" CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS
$CORE_COLLECTOR"
It seems there is a small issue with this design, if the file in /etc/kdump/{pre.d,post.d} is copied there preserving the timestamp, then "kdumpctl restart" won't rebuild the initramfs even if the file is missing in initramfs.
And kdumpctl restart won't check if the commands called by the script is updated.
This is good suggestion. Package installer installs files while preserving their timestamps.
The idea I come up with soon is to add information to check if any change in /etc/kdump/pre.d such as a list of file names under /etc/kdump/pre.d or checksum of them and compare the current one with the previous one.
-- Best Regards, Kairui Song _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.or g