File tree 9 files changed +38
-21
lines changed
includes.chroot/var/lib/shim-signed/mok
package-build/linux-kernel
9 files changed +38
-21
lines changed Original file line number Diff line number Diff line change
1
+ .build /config
1
2
build /*
3
+ config /*
2
4
* .pyc
3
5
packer_build /*
4
6
packer_cache /*
5
7
key /*
6
8
packages /*
7
9
! packages /* /
8
- data /live-build-config /includes.chroot /var /lib /shim-signed /mok /*
9
10
/testinstall * .img
10
11
/testinstall * .efivars
11
12
/* .qcow2
Original file line number Diff line number Diff line change 79
79
rm -f config/binary config/bootstrap config/chroot config/common config/source
80
80
rm -f build.log
81
81
rm -f vyos-*.iso
82
- rm -f *.img
82
+ rm -f *.img *.efivars
83
83
rm -f *.xz
84
84
rm -f *.vhd
85
85
rm -f *.raw
Original file line number Diff line number Diff line change
1
+ * .key
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
+
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 18
18
19
19
# This Dockerfile is installable on both x86, x86-64, armhf and arm64 systems
20
20
ARG ARCH=
21
- FROM ${ARCH}debian:bookworm
21
+ FROM ${ARCH}debian:bookworm-slim
22
22
23
23
RUN grep "VERSION_ID" /etc/os-release || (echo 'VERSION_ID="12"' >> /etc/os-release)
24
24
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 @@ -367,6 +367,11 @@ if __name__ == "__main__":
367
367
shutil .copytree ("data/live-build-config/" , lb_config_dir )
368
368
os .makedirs (lb_config_dir , exist_ok = True )
369
369
370
+ ## Secure Boot - Copy public Keys to image
371
+ sb_certs = 'data/certificates'
372
+ if os .path .isdir (sb_certs ):
373
+ shutil .copytree (sb_certs , f'{ lb_config_dir } /includes.chroot/var/lib/shim-signed/mok' )
374
+
370
375
# Switch to the build directory, this is crucial for the live-build work
371
376
# because the efective build config files etc. are there.
372
377
#
@@ -611,6 +616,7 @@ DOCUMENTATION_URL="{build_config['documentation_url']}"
611
616
## Configure live-build
612
617
lb_config_tmpl = jinja2 .Template ("""
613
618
lb config noauto \
619
+ --no-color \
614
620
--apt-indices false \
615
621
--apt-options "--yes -oAPT::Get::allow-downgrades=true" \
616
622
--apt-recommends false \
Original file line number Diff line number Diff line change 36
36
done
37
37
38
38
# Change name of Signing Cert
39
- sed -i -e " s/CN =.*/CN=VyOS build time autogenerated kernel key/" certs/default_x509.genkey
39
+ sed -i -e " s/CN =.*/CN=VyOS Networks build time autogenerated Kernel key/" certs/default_x509.genkey
40
40
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