6f7af4
From d7c2342fb26a52142ce1fb9b10b636565aba7780 Mon Sep 17 00:00:00 2001
6f7af4
From: Pavel Valena <pvalena@redhat.com>
6f7af4
Date: Mon, 2 May 2022 20:12:25 +0200
6f7af4
Subject: [PATCH] fix(fips): start iterating from 0 over BOOT_IMAGE entries
6f7af4
6f7af4
as the code contains a bug which sets default 0, but iterates from 1.
6f7af4
Correct approach is indexing from 0.
6f7af4
6f7af4
https://github.com/redhat-plumbers/dracut-rhel8/pull/9
6f7af4
---
6f7af4
 modules.d/01fips/fips.sh | 4 ++--
6f7af4
 1 file changed, 2 insertions(+), 2 deletions(-)
6f7af4
6f7af4
diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh
6f7af4
index c57fd426..e8952489 100755
6f7af4
--- a/modules.d/01fips/fips.sh
6f7af4
+++ b/modules.d/01fips/fips.sh
6f7af4
@@ -124,13 +124,13 @@ do_fips()
6f7af4
             elif [ -d /boot/loader/entries ]; then
6f7af4
                 i=0
6f7af4
                 for bls in $(ls -d /boot/loader/entries/*.conf | sort -rV); do
6f7af4
-                  ((i++))
6f7af4
-
6f7af4
                   if [ $i -eq ${BOOT_IMAGE:-0} ] && [ -r "$bls" ]; then
6f7af4
                       BOOT_IMAGE="$(grep -e '^linux' "$bls" | grep -o ' .*$')"
6f7af4
                       BOOT_IMAGE=${BOOT_IMAGE:1}
6f7af4
                       break
6f7af4
                   fi
6f7af4
+
6f7af4
+                  ((i++))
6f7af4
                 done
6f7af4
             fi
6f7af4
         fi