e83cdd
From a1435c3d535707f1d21aaf85e62175ff2bb1ad2b Mon Sep 17 00:00:00 2001
e83cdd
From: Kairui Song <kasong@redhat.com>
e83cdd
Date: Thu, 14 Mar 2019 18:54:10 +0800
e83cdd
Subject: [PATCH] fips: ensure fs module for /boot is installed
e83cdd
e83cdd
When using dracut with  --hostonly and --no-hostonly-default-device,
e83cdd
/boot will be inaccessible as dracut will most fs modules unless
e83cdd
specified. But FIPS require /boot to be accessible, and it will try
e83cdd
to mount it on boot. It will fail if corresponding fs module is missing.
e83cdd
e83cdd
For most case /boot will be a simple partition, include the fs module
e83cdd
will be enough for FIPS to mount it. For other cases users have to pass
e83cdd
extra parameters by themselves.
e83cdd
e83cdd
Suggested-by: Kenneth Dsouza <kdsouza@redhat.com>
e83cdd
Signed-off-by: Kairui Song <kasong@redhat.com>
e83cdd
---
e83cdd
 modules.d/01fips/module-setup.sh | 12 +++++++++++-
e83cdd
 1 file changed, 11 insertions(+), 1 deletion(-)
e83cdd
e83cdd
diff --git a/modules.d/01fips/module-setup.sh b/modules.d/01fips/module-setup.sh
e83cdd
index 18186d62..89734a09 100755
e83cdd
--- a/modules.d/01fips/module-setup.sh
e83cdd
+++ b/modules.d/01fips/module-setup.sh
e83cdd
@@ -12,7 +12,7 @@ depends() {
e83cdd
 
e83cdd
 # called by dracut
e83cdd
 installkernel() {
e83cdd
-    local _fipsmodules _mod
e83cdd
+    local _fipsmodules _mod _bootfstype
e83cdd
     if [[ -f "${srcmods}/modules.fips" ]]; then
e83cdd
         _fipsmodules="$(cat "${srcmods}/modules.fips")"
e83cdd
     else
e83cdd
@@ -47,6 +47,16 @@ installkernel() {
e83cdd
             echo "blacklist $_mod" >> "${initdir}/etc/modprobe.d/fips.conf"
e83cdd
         fi
e83cdd
     done
e83cdd
+
e83cdd
+    # with hostonly_default_device fs module for /boot is not installed by default
e83cdd
+    if [[ $hostonly ]] && [[ "$hostonly_default_device" == "no" ]]; then
e83cdd
+        _bootfstype=$(find_mp_fstype /boot)
e83cdd
+        if [[ -n "$_bootfstype" ]]; then
e83cdd
+            hostonly='' instmods $_bootfstype
e83cdd
+        else
e83cdd
+            dwarning "Can't determine fs type for /boot, FIPS check may fail."
e83cdd
+        fi
e83cdd
+    fi
e83cdd
 }
e83cdd
 
e83cdd
 # called by dracut
e83cdd