mirror of
https://github.com/linuxboot/heads.git
synced 2025-01-29 15:44:07 +00:00
Read and measure an EFI file into initrd during init
This commit is contained in:
parent
789c2db70d
commit
c0f3a4bb79
@ -1,6 +1,6 @@
|
|||||||
# Configuration for emulating LinuxBoot+Heads with qemu
|
# Configuration for emulating LinuxBoot+Heads with qemu
|
||||||
#
|
#
|
||||||
CONFIG_LINUXBOOT=y
|
export CONFIG_LINUXBOOT=y
|
||||||
CONFIG_LINUXBOOT_BOARD=qemu
|
CONFIG_LINUXBOOT_BOARD=qemu
|
||||||
CONFIG_LINUX_CONFIG=config/linux-linuxboot.config
|
CONFIG_LINUX_CONFIG=config/linux-linuxboot.config
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ set -e -o pipefail
|
|||||||
. /etc/functions
|
. /etc/functions
|
||||||
|
|
||||||
# Update initrd with CBFS files
|
# Update initrd with CBFS files
|
||||||
if [ -z "$CBFS_PCR" ]; then
|
if [ -z "$CONFIG_PCR" ]; then
|
||||||
CBFS_PCR=7
|
CONFIG_PCR=7
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load individual files
|
# Load individual files
|
||||||
@ -22,13 +22,10 @@ for cbfsname in `echo $cbfsfiles`; do
|
|||||||
TMPFILE=/tmp/cbfs.$$
|
TMPFILE=/tmp/cbfs.$$
|
||||||
echo "$filename" > $TMPFILE
|
echo "$filename" > $TMPFILE
|
||||||
cat $filename >> $TMPFILE
|
cat $filename >> $TMPFILE
|
||||||
tpm extend -ix "$CBFS_PCR" -if $TMPFILE \
|
tpm extend -ix "$CONFIG_PCR" -if $TMPFILE \
|
||||||
|| die "$filename: tpm extend failed"
|
|| die "$filename: tpm extend failed"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO: copy CBFS file named "initrd.tgz" to /tmp, measure and extract
|
# TODO: copy CBFS file named "heads/initrd.tgz" to /tmp, measure and extract
|
||||||
|
|
||||||
# Post processing of keys
|
|
||||||
gpg --import /.gnupg/keys/* 2>/dev/null || true
|
|
||||||
|
8
initrd/bin/key-init
Executable file
8
initrd/bin/key-init
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/ash
|
||||||
|
set -e -o pipefail
|
||||||
|
. /etc/functions
|
||||||
|
|
||||||
|
# Post processing of keys
|
||||||
|
gpg --import /.gnupg/keys/* 2>/dev/null || true
|
||||||
|
|
||||||
|
# TODO: split out gpg keys into multiple rings by function
|
28
initrd/bin/uefi-init
Executable file
28
initrd/bin/uefi-init
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/ash
|
||||||
|
set -e -o pipefail
|
||||||
|
. /etc/functions
|
||||||
|
|
||||||
|
# Update initrd with CBFS files
|
||||||
|
if [ -z "$CONFIG_PCR" ]; then
|
||||||
|
CONFIG_PCR=7
|
||||||
|
fi
|
||||||
|
|
||||||
|
CONFIG_GUID="74696e69-6472-632e-7069-6f2f75736572"
|
||||||
|
|
||||||
|
# copy EFI file named $CONFIG_GUID to /tmp, measure and extract
|
||||||
|
GUID=`uefi -l | grep "^$CONFIG_GUID"`
|
||||||
|
|
||||||
|
if [ -n "GUID" ]; then
|
||||||
|
echo "Loading $GUID from ROM"
|
||||||
|
TMPFILE=/tmp/uefi.$$
|
||||||
|
uefi -r $GUID | gunzip -c > $TMPFILE \
|
||||||
|
|| die "Failed to read config GUID from ROM"
|
||||||
|
|
||||||
|
if [ "$CONFIG_TPM" = "y" ]; then
|
||||||
|
tpm extend -ix "$CONFIG_PCR" -if $TMPFILE \
|
||||||
|
|| die "$filename: tpm extend failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
( cd / ; cpio -iud < $TMPFILE 2>/dev/null ) \
|
||||||
|
|| die "Failed to extract config GUID"
|
||||||
|
fi
|
@ -54,6 +54,10 @@ fi
|
|||||||
if [ "$CONFIG_COREBOOT" = "y" ]; then
|
if [ "$CONFIG_COREBOOT" = "y" ]; then
|
||||||
/bin/cbfs-init
|
/bin/cbfs-init
|
||||||
fi
|
fi
|
||||||
|
if [ "$CONFIG_LINUXBOOT" = "y" ]; then
|
||||||
|
/bin/uefi-init
|
||||||
|
fi
|
||||||
|
/bin/key-init
|
||||||
|
|
||||||
# Setup recovery serial shell
|
# Setup recovery serial shell
|
||||||
if [ ! -z "$CONFIG_BOOT_RECOVERY_SERIAL" ]; then
|
if [ ! -z "$CONFIG_BOOT_RECOVERY_SERIAL" ]; then
|
||||||
|
@ -21,6 +21,7 @@ flashtools_output := \
|
|||||||
peek \
|
peek \
|
||||||
poke \
|
poke \
|
||||||
cbfs \
|
cbfs \
|
||||||
|
uefi \
|
||||||
|
|
||||||
flashtools_libraries := \
|
flashtools_libraries := \
|
||||||
|
|
||||||
|
@ -24,10 +24,15 @@ linuxboot_configure := \
|
|||||||
fi ; \
|
fi ; \
|
||||||
touch .config ; \
|
touch .config ; \
|
||||||
|
|
||||||
|
ifdef CUSTOM
|
||||||
|
CUSTOMPWD=$(pwd)/$(CUSTOM)
|
||||||
|
endif
|
||||||
|
|
||||||
linuxboot_target := \
|
linuxboot_target := \
|
||||||
BOARD=$(linuxboot_board) \
|
BOARD=$(linuxboot_board) \
|
||||||
KERNEL=$(build)/$(BOARD)/bzImage \
|
KERNEL=$(build)/$(BOARD)/bzImage \
|
||||||
INITRD=$(build)/$(BOARD)/initrd.cpio.xz \
|
INITRD=$(build)/$(BOARD)/initrd.cpio.xz \
|
||||||
|
CUSTOM=$(CUSTOMPWD) \
|
||||||
$(if $(CONFIG_LINUXBOOT_ROM), ROM=$(pwd)/$(CONFIG_LINUXBOOT_ROM)) \
|
$(if $(CONFIG_LINUXBOOT_ROM), ROM=$(pwd)/$(CONFIG_LINUXBOOT_ROM)) \
|
||||||
all
|
all
|
||||||
|
|
||||||
@ -74,4 +79,5 @@ linuxboot.run: $(build)/$(BOARD)/linuxboot.rom
|
|||||||
BOARD:=$(linuxboot_board) \
|
BOARD:=$(linuxboot_board) \
|
||||||
KERNEL=$(build)/$(BOARD)/bzImage \
|
KERNEL=$(build)/$(BOARD)/bzImage \
|
||||||
INITRD=$(build)/$(BOARD)/initrd.cpio.xz \
|
INITRD=$(build)/$(BOARD)/initrd.cpio.xz \
|
||||||
|
CUSTOM=$(CUSTOMPWD) \
|
||||||
run
|
run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user