Skip to content

Commit 5789abc

Browse files
bsloane1650haraldh
authored andcommitted
fix(fips.sh): repsect rd.fips.skipkernel
Support for this flag was broken in 4257798
1 parent 0b97790 commit 5789abc

File tree

1 file changed

+46
-43
lines changed

1 file changed

+46
-43
lines changed

modules.d/01fips/fips.sh

+46-43
Original file line numberDiff line numberDiff line change
@@ -113,58 +113,61 @@ do_fips() {
113113

114114
KERNEL=$(uname -r)
115115

116-
fips_info "Checking integrity of kernel"
117-
if [ -e "/run/initramfs/live/vmlinuz0" ]; then
118-
do_rhevh_check /run/initramfs/live/vmlinuz0 || return 1
119-
elif [ -e "/run/initramfs/live/isolinux/vmlinuz0" ]; then
120-
do_rhevh_check /run/initramfs/live/isolinux/vmlinuz0 || return 1
121-
elif [ -e "/run/install/repo/images/pxeboot/vmlinuz" ]; then
122-
# This is a boot.iso with the .hmac inside the install.img
123-
do_rhevh_check /run/install/repo/images/pxeboot/vmlinuz || return 1
124-
else
125-
BOOT_IMAGE="$(getarg BOOT_IMAGE)"
126-
127-
# On s390x, BOOT_IMAGE isn't a path but an integer representing the
128-
# entry number selected. Let's try the root of /boot first, and
129-
# otherwise fallback to trying to parse the BLS entries if it's a
130-
# BLS-based system.
131-
if [ "$(uname -m)" = s390x ]; then
132-
if [ -e "/boot/vmlinuz-${KERNEL}" ]; then
133-
BOOT_IMAGE="vmlinuz-${KERNEL}"
134-
elif [ -d /boot/loader/entries ]; then
135-
bls=$(find /boot/loader/entries -name '*.conf' | sort -rV | sed -n "$((BOOT_IMAGE + 1))p")
136-
if [ -e "${bls}" ]; then
137-
BOOT_IMAGE=$(grep ^linux "${bls}" | cut -d' ' -f2)
116+
if ! getarg rd.fips.skipkernel > /dev/null; then
117+
118+
fips_info "Checking integrity of kernel"
119+
if [ -e "/run/initramfs/live/vmlinuz0" ]; then
120+
do_rhevh_check /run/initramfs/live/vmlinuz0 || return 1
121+
elif [ -e "/run/initramfs/live/isolinux/vmlinuz0" ]; then
122+
do_rhevh_check /run/initramfs/live/isolinux/vmlinuz0 || return 1
123+
elif [ -e "/run/install/repo/images/pxeboot/vmlinuz" ]; then
124+
# This is a boot.iso with the .hmac inside the install.img
125+
do_rhevh_check /run/install/repo/images/pxeboot/vmlinuz || return 1
126+
else
127+
BOOT_IMAGE="$(getarg BOOT_IMAGE)"
128+
129+
# On s390x, BOOT_IMAGE isn't a path but an integer representing the
130+
# entry number selected. Let's try the root of /boot first, and
131+
# otherwise fallback to trying to parse the BLS entries if it's a
132+
# BLS-based system.
133+
if [ "$(uname -m)" = s390x ]; then
134+
if [ -e "/boot/vmlinuz-${KERNEL}" ]; then
135+
BOOT_IMAGE="vmlinuz-${KERNEL}"
136+
elif [ -d /boot/loader/entries ]; then
137+
bls=$(find /boot/loader/entries -name '*.conf' | sort -rV | sed -n "$((BOOT_IMAGE + 1))p")
138+
if [ -e "${bls}" ]; then
139+
BOOT_IMAGE=$(grep ^linux "${bls}" | cut -d' ' -f2)
140+
fi
138141
fi
139142
fi
140-
fi
141143

142-
# Trim off any leading GRUB boot device (e.g. ($root) )
143-
BOOT_IMAGE="$(echo "${BOOT_IMAGE}" | sed 's/^(.*)//')"
144+
# Trim off any leading GRUB boot device (e.g. ($root) )
145+
BOOT_IMAGE="$(echo "${BOOT_IMAGE}" | sed 's/^(.*)//')"
144146

145-
BOOT_IMAGE_NAME="${BOOT_IMAGE##*/}"
146-
BOOT_IMAGE_PATH="${BOOT_IMAGE%${BOOT_IMAGE_NAME}}"
147+
BOOT_IMAGE_NAME="${BOOT_IMAGE##*/}"
148+
BOOT_IMAGE_PATH="${BOOT_IMAGE%${BOOT_IMAGE_NAME}}"
147149

148-
if [ -z "$BOOT_IMAGE_NAME" ]; then
149-
BOOT_IMAGE_NAME="vmlinuz-${KERNEL}"
150-
elif ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE_NAME}" ]; then
151-
#if /boot is not a separate partition BOOT_IMAGE might start with /boot
152-
BOOT_IMAGE_PATH=${BOOT_IMAGE_PATH#"/boot"}
153-
#on some achitectures BOOT_IMAGE does not contain path to kernel
154-
#so if we can't find anything, let's treat it in the same way as if it was empty
155-
if ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE_NAME}" ]; then
150+
if [ -z "$BOOT_IMAGE_NAME" ]; then
156151
BOOT_IMAGE_NAME="vmlinuz-${KERNEL}"
157-
BOOT_IMAGE_PATH=""
152+
elif ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE_NAME}" ]; then
153+
#if /boot is not a separate partition BOOT_IMAGE might start with /boot
154+
BOOT_IMAGE_PATH=${BOOT_IMAGE_PATH#"/boot"}
155+
#on some achitectures BOOT_IMAGE does not contain path to kernel
156+
#so if we can't find anything, let's treat it in the same way as if it was empty
157+
if ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE_NAME}" ]; then
158+
BOOT_IMAGE_NAME="vmlinuz-${KERNEL}"
159+
BOOT_IMAGE_PATH=""
160+
fi
158161
fi
159-
fi
160162

161-
BOOT_IMAGE_HMAC="/boot/${BOOT_IMAGE_PATH}/.${BOOT_IMAGE_NAME}.hmac"
162-
if ! [ -e "${BOOT_IMAGE_HMAC}" ]; then
163-
warn "${BOOT_IMAGE_HMAC} does not exist"
164-
return 1
165-
fi
163+
BOOT_IMAGE_HMAC="/boot/${BOOT_IMAGE_PATH}/.${BOOT_IMAGE_NAME}.hmac"
164+
if ! [ -e "${BOOT_IMAGE_HMAC}" ]; then
165+
warn "${BOOT_IMAGE_HMAC} does not exist"
166+
return 1
167+
fi
166168

167-
(cd "${BOOT_IMAGE_HMAC%/*}" && sha512hmac -c "${BOOT_IMAGE_HMAC}") || return 1
169+
(cd "${BOOT_IMAGE_HMAC%/*}" && sha512hmac -c "${BOOT_IMAGE_HMAC}") || return 1
170+
fi
168171
fi
169172

170173
fips_info "All initrd crypto checks done"

0 commit comments

Comments
 (0)