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

From: @markeryang 
Reviewed-by: @openeuler-basic 
Signed-off-by: @openeuler-basic
This commit is contained in:
openeuler-ci-bot 2024-06-13 07:37:44 +00:00 committed by Gitee
commit f054c5542e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 35 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
@@ -56,7 +56,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: 050
Release: 9
Release: 10
Summary: Initramfs generator using udev
@ -112,6 +112,7 @@ Patch0083: backport-fix-network-avoid-double-brackets-around-IPv6-address.patch
Patch0084: backport-fix-network-don-t-use-same-ifname-multiple-times.patch
Patch0085: backport-fix-dracut-init.sh-add-missing-hostonly-code-in-the-inst_multiple-function.patch
Patch0086: dracut-050-fix-base-install-chmod-binaries.patch
Patch0087: backport-fix-dracut-initramfs-restore-check-if-SELINUXTYPE-is-set.patch
Source1: https://www.gnu.org/licenses/lgpl-2.1.txt
Source2: openEuler.conf.example
@ -562,6 +563,9 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne
%endif
%changelog
* Fri Jun 07 2024 yanglongkang <yanglongkang@h-partners.com> - 050-10
- fix(dracut-initramfs-restore.sh): check if SELINUXTYPE is set
* Fri Apr 26 2024 yueyuankun <yueyuankun@kylinos.cn> - 050-9
- fix(base): install chmod binaries