From 58acbffe7f2030e2ca787d652235c77cedb447af Mon Sep 17 00:00:00 2001 From: markeryang Date: Fri, 7 Jun 2024 07:48:07 +0000 Subject: [PATCH] fix(dracut-initramfs-restore.sh): check if SELINUXTYPE is set --- ...-restore-check-if-SELINUXTYPE-is-set.patch | 30 +++++++++++++++++++ dracut.spec | 9 +++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 backport-fix-dracut-initramfs-restore-check-if-SELINUXTYPE-is-set.patch diff --git a/backport-fix-dracut-initramfs-restore-check-if-SELINUXTYPE-is-set.patch b/backport-fix-dracut-initramfs-restore-check-if-SELINUXTYPE-is-set.patch new file mode 100644 index 0000000..df1f071 --- /dev/null +++ b/backport-fix-dracut-initramfs-restore-check-if-SELINUXTYPE-is-set.patch @@ -0,0 +1,30 @@ +From 72bd474b54b489afc4d06d26f5bf8e1097518946 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Fri, 11 Mar 2022 14:04:16 +0100 +Subject: [PATCH] fix(dracut-initramfs-restore.sh): check if SELINUXTYPE is set + +It can happen that SELINUXTYPE is not set, e.g., in Fedora/RHEL +installation images /etc/selinux/config is an empty file. That means +that setfiles fails, which makes dracut-initramfs-restore fail too +because it uses "set -x", which means that dracut-shutdown.service +fails. But, after commit 7ab1d00227cad6f1b86ba01fdc766769faebb031, a +failure of dracut-shutdown.service means that the final switch back into +initrd is skipped. Let's just add an additional sanity check to +workaround that. +--- + dracut-initramfs-restore.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh +index 3c70b42c3c..b19be7de3c 100644 +--- a/dracut-initramfs-restore.sh ++++ b/dracut-initramfs-restore.sh +@@ -76,7 +76,7 @@ fi + + if [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ]; then + . /etc/selinux/config +- /usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/"${SELINUXTYPE}"/contexts/files/file_contexts /run/initramfs > /dev/null ++ [ -n "${SELINUXTYPE}" ] && /usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/"${SELINUXTYPE}"/contexts/files/file_contexts /run/initramfs > /dev/null + fi + + exit 0 diff --git a/dracut.spec b/dracut.spec index 5b9f2f7..5edf161 100644 --- a/dracut.spec +++ b/dracut.spec @@ -9,7 +9,7 @@ Name: dracut Version: 055 -Release: 11 +Release: 12 Summary: Initramfs generator using udev @@ -45,6 +45,7 @@ Patch18: backport-fix-fs-lib-remove-quoting-form-the-first-argument-of.patch Patch19: backport-fix-dracut.sh-exit-if-resolving-executable-dependenc.patch Patch20: backport-fix-dracut-install-protect-against-broken-links-poin.patch Patch21: backport-fix-mdraid-allow-UUID-comparison-for-more-than-one-U.patch +Patch22: backport-fix-dracut-initramfs-restore-check-if-SELINUXTYPE-is-set.patch Patch6000: backport-fix-dracut.sh-handle-i-option-to-include-files-begin.patch Patch6001: backport-fix-dracut.sh-handle-symlinks-appropriately-while-us.patch @@ -573,6 +574,12 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne %endif %changelog +* Fri Jun 07 2024 yanglongkang - 055-12 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix(dracut-initramfs-restore.sh): check if SELINUXTYPE is set + * Wed Feb 21 2024 hongjinghao - 055-11 - backport patchs from upstream -- Gitee