fix(dracut-initramfs-restore.sh): check if SELINUXTYPE is set

(cherry picked from commit 58acbffe7f2030e2ca787d652235c77cedb447af)
This commit is contained in:
markeryang 2024-06-07 07:48:07 +00:00 committed by openeuler-sync-bot
parent 19ad7e8cf9
commit ebc85942f8
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From 72bd474b54b489afc4d06d26f5bf8e1097518946 Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
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

View File

@ -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 <yanglongkang@h-partners.com> - 055-12
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix(dracut-initramfs-restore.sh): check if SELINUXTYPE is set
* Wed Feb 21 2024 hongjinghao <hongjinghao@huawei.com> - 055-11
- backport patchs from upstream