d1a34d
From 1cd3626354131eecbaea0ce16f04be34ad4dfbf9 Mon Sep 17 00:00:00 2001
d1a34d
From: David Tardon <dtardon@redhat.com>
d1a34d
Date: Fri, 11 Mar 2022 14:04:16 +0100
d1a34d
Subject: [PATCH] fix(dracut-initramfs-restore.sh): check if SELINUXTYPE is set
d1a34d
d1a34d
It can happen that SELINUXTYPE is not set, e.g., in Fedora/RHEL
d1a34d
installation images /etc/selinux/config is an empty file. That means
d1a34d
that setfiles fails, which makes dracut-initramfs-restore fail too
d1a34d
because it uses "set -x", which means that dracut-shutdown.service
d1a34d
fails. But, after commit 7ab1d00227cad6f1b86ba01fdc766769faebb031, a
d1a34d
failure of dracut-shutdown.service means that the final switch back into
d1a34d
initrd is skipped. Let's just add an additional sanity check to
d1a34d
workaround that.
d1a34d
d1a34d
Resolves: #2059552
d1a34d
---
d1a34d
 dracut-initramfs-restore.sh | 2 +-
d1a34d
 1 file changed, 1 insertion(+), 1 deletion(-)
d1a34d
d1a34d
diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh
d1a34d
index d97030a3..25cc881d 100644
d1a34d
--- a/dracut-initramfs-restore.sh
d1a34d
+++ b/dracut-initramfs-restore.sh
d1a34d
@@ -65,7 +65,7 @@ fi
d1a34d
 
d1a34d
 if [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ]; then
d1a34d
     . /etc/selinux/config
d1a34d
-    /usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/"${SELINUXTYPE}"/contexts/files/file_contexts /run/initramfs > /dev/null
d1a34d
+    [ -n "${SELINUXTYPE}" ] && /usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/"${SELINUXTYPE}"/contexts/files/file_contexts /run/initramfs > /dev/null
d1a34d
 fi
d1a34d
 
d1a34d
 exit 0