2
2
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3
3
# ex: ts=8 sw=4 sts=4 et filetype=sh
4
4
5
- do_fipskernel ()
5
+ mount_boot ()
6
6
{
7
7
boot=$( getarg boot=)
8
- KERNEL=$( uname -r)
9
- case " $boot " in
8
+
9
+ if [ -n " $boot " ]; then
10
+ case " $boot " in
10
11
LABEL=* )
11
12
boot=" $( echo $boot | sed ' s,/,\\x2f,g' ) "
12
13
boot=" /dev/disk/by-label/${boot# LABEL=} "
@@ -18,45 +19,52 @@ do_fipskernel()
18
19
;;
19
20
* )
20
21
die " You have to specify boot=<boot device> as a boot option for fips=1" ;;
21
- esac
22
-
23
- if ! [ -e " $boot " ]; then
24
- udevadm trigger --action=add > /dev/null 2>&1
25
- [ -z " $UDEVVERSION " ] && UDEVVERSION=$( udevadm --version)
22
+ esac
26
23
27
- if [ $UDEVVERSION -ge 143 ]; then
28
- udevadm settle --exit-if-exists=$boot
29
- else
30
- udevadm settle --timeout=30
24
+ if ! [ -e " $boot " ]; then
25
+ udevadm trigger --action=add > /dev/null 2>&1
26
+ [ -z " $UDEVVERSION " ] && UDEVVERSION=$( udevadm --version)
27
+ i=0
28
+ while ! [ -e $boot ]; do
29
+ if [ $UDEVVERSION -ge 143 ]; then
30
+ udevadm settle --exit-if-exists=$boot
31
+ else
32
+ udevadm settle --timeout=30
33
+ fi
34
+ [ -e $boot ] && break
35
+ modprobe scsi_wait_scan && rmmod scsi_wait_scan
36
+ [ -e $boot ] && break
37
+ sleep 0.5
38
+ i=$(( $i + 1 ))
39
+ [ $i -gt 40 ] && break
40
+ done
31
41
fi
32
- fi
33
42
34
- [ -e " $boot " ]
43
+ [ -e " $boot " ] || return 1
35
44
36
- mkdir -m 0755 /boot
37
- info " Mounting $boot as /boot"
38
- mount -oro " $boot " /boot
45
+ mkdir /boot
46
+ info " Mounting $boot as /boot"
47
+ mount -oro " $boot " /boot || return 1
48
+ fi
49
+ }
39
50
51
+ do_fips ()
52
+ {
40
53
info " Checking integrity of kernel"
54
+ newroot=$NEWROOT
55
+ KERNEL=$( uname -r)
41
56
42
- if ! [ -e " /boot/.vmlinuz-${KERNEL} .hmac" ]; then
43
- warn " /boot/.vmlinuz-${KERNEL} .hmac does not exist"
57
+ [ -e " $newroot /boot/.vmlinuz-${KERNEL} .hmac" ] || unset newroot
58
+
59
+ if ! [ -e " $newroot /boot/.vmlinuz-${KERNEL} .hmac" ]; then
60
+ warn " $newroot /boot/.vmlinuz-${KERNEL} .hmac does not exist"
44
61
return 1
45
62
fi
46
63
47
- sha512hmac -c " /boot/.vmlinuz-${KERNEL} .hmac" || return 1
48
-
49
- info " Umounting /boot"
50
- umount /boot
51
- }
64
+ sha512hmac -c " $newroot /boot/.vmlinuz-${KERNEL} .hmac" || return 1
52
65
53
- do_fips ()
54
- {
55
66
FIPSMODULES=$( cat /etc/fipsmodules)
56
67
57
- if ! getarg rd.fips.skipkernel > /dev/null; then
58
- do_fipskernel
59
- fi
60
68
info " Loading and integrity checking all crypto modules"
61
69
for module in $FIPSMODULES ; do
62
70
if [ " $module " != " tcrypt" ]; then
@@ -66,15 +74,11 @@ do_fips()
66
74
info " Self testing crypto algorithms"
67
75
modprobe tcrypt || return 1
68
76
rmmod tcrypt
69
- info " All initrd crypto checks done"
77
+ info " All initrd crypto checks done"
78
+
79
+ > /tmp/fipsdone
80
+
81
+ umount /boot > /dev/null 2>&1
70
82
71
83
return 0
72
84
}
73
-
74
- if ! fipsmode=$( getarg fips) || [ $fipsmode = " 0" ]; then
75
- rm -f /etc/modprobe.d/fips.conf > /dev/null 2>&1
76
- else
77
- set -e
78
- do_fips || die " FIPS integrity test failed"
79
- set +e
80
- fi
0 commit comments