]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut-initramfs-restore.sh): check if SELINUXTYPE is set
authorDavid Tardon <dtardon@redhat.com>
Fri, 11 Mar 2022 13:04:16 +0000 (14:04 +0100)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Fri, 18 Mar 2022 06:37:23 +0000 (06:37 +0000)
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

index 3c70b42c3c9aa822d9c71aae1c946e058d3ed7df..b19be7de3cfff636fd8149ca4e04686606e32eb2 100644 (file)
@@ -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