Harald Hoyer 3610a1
From 43634c2469a33c80c235f9bfe254002c6bea5448 Mon Sep 17 00:00:00 2001
Harald Hoyer 3610a1
From: Harald Hoyer <harald@hoyer.xyz>
Harald Hoyer 3610a1
Date: Mon, 18 Dec 2017 15:26:31 +0100
Harald Hoyer 3610a1
Subject: [PATCH] Merge pull request #335 from lnykryn/BOOT_IMAGE-to-HMAC
Harald Hoyer 3610a1
Harald Hoyer 3610a1
01fips: Fix creating path to .hmac of kernel based on BOOT_IMAGE
Harald Hoyer 3610a1
---
Harald Hoyer 3610a1
 modules.d/01fips/fips.sh | 14 ++++++++++----
Harald Hoyer 3610a1
 1 file changed, 10 insertions(+), 4 deletions(-)
Harald Hoyer 3610a1
Harald Hoyer 3610a1
diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh
Harald Hoyer 3610a1
index 1e5707c0..11de1793 100755
Harald Hoyer 3610a1
--- a/modules.d/01fips/fips.sh
Harald Hoyer 3610a1
+++ b/modules.d/01fips/fips.sh
Harald Hoyer 3610a1
@@ -110,13 +110,19 @@ do_fips()
Harald Hoyer 3610a1
         do_rhevh_check /run/initramfs/live/isolinux/vmlinuz0 || return 1
Harald Hoyer 3610a1
     else
Harald Hoyer 3610a1
         BOOT_IMAGE="$(getarg BOOT_IMAGE)"
Harald Hoyer 3610a1
-        [ -e "/boot/.${BOOT_IMAGE}.hmac" ] || BOOT_IMAGE="vmlinuz-${KERNEL}"
Harald Hoyer 3610a1
+        if ! [ -e "/boot/${BOOT_IMAGE}" ]; then
Harald Hoyer 3610a1
+            #if /boot is not a separate partition BOOT_IMAGE might start with /boot
Harald Hoyer 3610a1
+            BOOT_IMAGE=${BOOT_IMAGE#"/boot"}
Harald Hoyer 3610a1
+            [ -e "/boot/${BOOT_IMAGE}" ] || BOOT_IMAGE="vmlinuz-${KERNEL}"
Harald Hoyer 3610a1
+        fi
Harald Hoyer 3610a1
+        
Harald Hoyer 3610a1
+        BOOT_IMAGE_HMAC="/boot/${BOOT_IMAGE%/*}/.${BOOT_IMAGE##*/}.hmac"
Harald Hoyer 3610a1
 
Harald Hoyer 3610a1
-        if ! [ -e "/boot/.${BOOT_IMAGE}.hmac" ]; then
Harald Hoyer 3610a1
-            warn "/boot/.${BOOT_IMAGE}.hmac does not exist"
Harald Hoyer 3610a1
+        if ! [ -e "${BOOT_IMAGE_HMAC}" ]; then
Harald Hoyer 3610a1
+            warn "${BOOT_IMAGE_HMAC} does not exist"
Harald Hoyer 3610a1
             return 1
Harald Hoyer 3610a1
         fi
Harald Hoyer 3610a1
-        sha512hmac -c "/boot/.${BOOT_IMAGE}.hmac" || return 1
Harald Hoyer 3610a1
+        sha512hmac -c "${BOOT_IMAGE_HMAC}" || return 1
Harald Hoyer 3610a1
     fi
Harald Hoyer 3610a1
 
Harald Hoyer 3610a1
     info "All initrd crypto checks done"
Harald Hoyer 3610a1