File tree 3 files changed +26
-6
lines changed
data/live-build-config/hooks/live
package-build/linux-kernel
3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
SIGN_FILE=$( find /usr/lib -name sign-file)
3
- MOK_KEY =" /var/lib/shim-signed/mok/MOK .key"
4
- MOK_CERT =" /var/lib/shim-signed/mok/MOK .pem"
3
+ KERNEL_KEY =" /var/lib/shim-signed/mok/vyos-dev-2025-linux .key"
4
+ KERNEL_CERT =" /var/lib/shim-signed/mok/vyos-dev-2025-linux .pem"
5
5
VMLINUZ=$( readlink /boot/vmlinuz)
6
6
7
7
# All Linux Kernel modules need to be cryptographically signed
@@ -13,10 +13,19 @@ find /lib/modules -type f -name \*.ko | while read MODULE; do
13
13
fi
14
14
done
15
15
16
- if [ ! -f ${MOK_KEY } ]; then
16
+ if [ ! -f ${KERNEL_KEY} ] && [ ! -f ${KERNEL_CERT } ]; then
17
17
echo " I: Signing key for Linux Kernel not found - Secure Boot not possible"
18
18
else
19
19
echo " I: Signing Linux Kernel for Secure Boot"
20
- sbsign --key ${MOK_KEY } --cert ${MOK_CERT } /boot/${VMLINUZ} --output /boot/${VMLINUZ}
20
+ sbsign --key ${KERNEL_KEY } --cert ${KERNEL_CERT } /boot/${VMLINUZ} --output /boot/${VMLINUZ}
21
21
sbverify --list /boot/${VMLINUZ}
22
+ rm -f ${KERNEL_KEY}
22
23
fi
24
+
25
+ for cert in $( ls /var/lib/shim-signed/mok/) ; do
26
+ if grep -rq " BEGIN PRIVATE KEY" /var/lib/shim-signed/mok/${cert} ; then
27
+ echo " Found private key - bailing out"
28
+ exit 1
29
+ fi
30
+ done
31
+
Original file line number Diff line number Diff line change @@ -398,6 +398,16 @@ try:
398
398
399
399
loginVM (c , log )
400
400
401
+ #################################################
402
+ # Check for no private key contents within the image
403
+ #################################################
404
+ msg = 'Found private key - bailing out'
405
+ c .sendline (f'if sudo grep -rq "BEGIN PRIVATE KEY" /var/lib/shim-signed/mok; then echo { msg } ; exit 1; fi' )
406
+ tmp = c .expect ([f'\n { msg } ' , op_mode_prompt ])
407
+ if tmp == 0 :
408
+ log .error (msg )
409
+ exit (1 )
410
+
401
411
#################################################
402
412
# Installing into VyOS system
403
413
#################################################
@@ -879,7 +889,7 @@ except pexpect.exceptions.ExceptionPexpect:
879
889
EXCEPTION = 1
880
890
881
891
except Exception :
882
- log .error ('Unknown error occured while VyOS !' )
892
+ log .error ('Unknown error occured!' )
883
893
traceback .print_exc ()
884
894
EXCEPTION = 1
885
895
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ sed -i -e "s/CN =.*/CN=VyOS build time autogenerated kernel key/" certs/default_
41
41
TRUSTED_KEYS_FILE=trusted_keys.pem
42
42
# start with empty key file
43
43
echo -n " " > $TRUSTED_KEYS_FILE
44
- CERTS=$( find ../../../data/live-build-config/includes.chroot/var/lib/shim-signed/mok -name " *.pem" -type f || true)
44
+ GIT_ROOT=$( git rev-parse --show-toplevel)
45
+ CERTS=$( find ${GIT_ROOT} /data/certificates -name " *.pem" -type f || true)
45
46
if [ ! -z " ${CERTS} " ]; then
46
47
# add known public keys to Kernel certificate chain
47
48
for file in $CERTS ; do
You can’t perform that action at this time.
0 commit comments