v2 -> v3: re-arrange the patch sequence. Fix bug in 'kdumpctl: detect modification of scripts by its directory's timestamp'
v1 -> v2: 1. [1/4]: using rpm spec to install pre.d and post.d mandatory 2. [4/4]: improve commit log
Pingfan Liu (3): kexec-tools.spec: make the existence of pre.d and post.d mandatory module-setup.sh: suppress false alarm kdumpctl: detect modification of scripts by its directory's timestamp
dracut-module-setup.sh | 4 ++-- kdumpctl | 7 ++++++- kexec-tools.spec | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-)
If the directory /etc/kdump/pre.d is optional, then it is hard to tell between the following cases: -1. no directory "/etc/kdump/pre.d" -2. "rm -rf /etc/kdump/pre.d", which removes all scripts under pre.d For the second case, kdump.img should be rebuilt.
To bail out from this corner case, always creating pre.d and post.d during rpm installation.
Signed-off-by: Pingfan Liu piliu@redhat.com --- kexec-tools.spec | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/kexec-tools.spec b/kexec-tools.spec index 4cd64c8..0fd4853 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -157,6 +157,9 @@ make -C makedumpfile-%{mkdf_ver} LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libep %install mkdir -p -m755 $RPM_BUILD_ROOT/usr/sbin mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig +mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump +mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump/pre.d +mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump/post.d mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man5/ @@ -327,6 +330,9 @@ done %endif %{dracutlibdir}/modules.d/* %dir %{_localstatedir}/crash +%dir %{_sysconfdir}/kdump +%dir %{_sysconfdir}/kdump/pre.d +%dir %{_sysconfdir}/kdump/post.d %{_mandir}/man8/kdumpctl.8.gz %{_mandir}/man8/kexec.8.gz %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
Even if the directory "/etc/kdump/pre.d/" is empty, the following false alarm can be observed during building kdump.initrd: "/etc/kdump/pre.d/* is not executable"
Suppress it.
Signed-off-by: Pingfan Liu piliu@redhat.com --- dracut-module-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 2454463..fbbd21a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -419,7 +419,7 @@ kdump_install_pre_post_conf() { for file in /etc/kdump/pre.d/*; do if [ -x "$file" ]; then dracut_install $file - else + elif [ $file != "/etc/kdump/pre.d/*" ]; then echo "$file is not executable" fi done @@ -429,7 +429,7 @@ kdump_install_pre_post_conf() { for file in /etc/kdump/post.d/*; do if [ -x "$file" ]; then dracut_install $file - else + elif [ $file != "/etc/kdump/post.d/*" ]; then echo "$file is not executable" fi done
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 --- kdumpctl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index d3ec4d7..42c11d3 100755 --- a/kdumpctl +++ b/kdumpctl @@ -338,6 +338,7 @@ 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` + HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/" if [ -d /etc/kdump/post.d ]; then for file in /etc/kdump/post.d/*; do if [ -x "$file" ]; then @@ -352,9 +353,11 @@ check_files_modified() fi done fi + HOOKS="$HOOKS $POST_FILES $PRE_FILES" CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2` 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-` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR" @@ -385,6 +388,8 @@ check_files_modified() check_exist "$files" && check_executable "$EXTRA_BINS" [ $? -ne 0 ] && return 2
+ # HOOKS only need to check the modification here + files="$files $HOOKS" for file in $files; do if [ -e "$file" ]; then time_stamp=`stat -c "%Y" $file`
Dear Liu,
I'm sorry for my very late response. Thank you very much for detecting and correcting the problem of the "pre.d/post.d" interface. I confirmed that your additional function works well.
Best Regards, Shinichi Onitsuka
-----Original Message----- From: Pingfan Liu piliu@redhat.com Sent: Thursday, July 16, 2020 5:50 PM To: kexec@lists.fedoraproject.org Cc: Kairui Song kasong@redhat.com Subject: [PATCHv3 0/3] trival fixes and improvement of pre.d/post.d hooks
v2 -> v3: re-arrange the patch sequence. Fix bug in 'kdumpctl: detect modification of scripts by its directory's timestamp'
v1 -> v2:
- [1/4]: using rpm spec to install pre.d and post.d mandatory
- [4/4]: improve commit log
Pingfan Liu (3): kexec-tools.spec: make the existence of pre.d and post.d mandatory module-setup.sh: suppress false alarm kdumpctl: detect modification of scripts by its directory's timestamp
dracut-module-setup.sh | 4 ++-- kdumpctl | 7 ++++++- kexec-tools.spec | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-)
-- 2.25.4 _______________________________________________ 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.org
On Thu, Jul 16, 2020 at 4:50 PM Pingfan Liu piliu@redhat.com wrote:
v2 -> v3: re-arrange the patch sequence. Fix bug in 'kdumpctl: detect modification of scripts by its directory's timestamp'
v1 -> v2:
- [1/4]: using rpm spec to install pre.d and post.d mandatory
- [4/4]: improve commit log
Pingfan Liu (3): kexec-tools.spec: make the existence of pre.d and post.d mandatory module-setup.sh: suppress false alarm kdumpctl: detect modification of scripts by its directory's timestamp
dracut-module-setup.sh | 4 ++-- kdumpctl | 7 ++++++- kexec-tools.spec | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-)
-- 2.25.4
Hi Pingfan, the patches looks good, and previous issues are fixed, thanks.
Acked-by: Kairui Song kasong@redhat.com