2018-03-12 01:27:19 +00:00
|
|
|
#!/bin/ash
|
|
|
|
set -e -o pipefail
|
|
|
|
. /etc/functions
|
|
|
|
|
2023-02-20 16:01:17 +00:00
|
|
|
TRACE "Under /bin/cbfs-init"
|
2023-02-18 17:58:43 +00:00
|
|
|
|
2018-03-12 01:27:19 +00:00
|
|
|
# Update initrd with CBFS files
|
2018-04-30 02:58:44 +00:00
|
|
|
if [ -z "$CONFIG_PCR" ]; then
|
|
|
|
CONFIG_PCR=7
|
2018-03-12 01:27:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Load individual files
|
2018-04-22 00:21:37 +00:00
|
|
|
cbfsfiles=`cbfs -t 50 -l 2>/dev/null | grep "^heads/initrd/"`
|
2018-03-12 01:27:19 +00:00
|
|
|
|
|
|
|
for cbfsname in `echo $cbfsfiles`; do
|
2018-04-20 22:11:12 +00:00
|
|
|
filename=${cbfsname:12}
|
2018-03-12 01:27:19 +00:00
|
|
|
if [ ! -z "$filename" ]; then
|
|
|
|
echo "Loading $filename from CBFS"
|
|
|
|
mkdir -p `dirname $filename` \
|
|
|
|
|| die "$filename: mkdir failed"
|
2018-03-23 16:29:47 +00:00
|
|
|
cbfs -t 50 -r $cbfsname > "$filename" \
|
2018-03-12 01:27:19 +00:00
|
|
|
|| die "$filename: cbfs file read failed"
|
2022-08-25 18:43:31 +00:00
|
|
|
if [ "$CONFIG_TPM" = "y" -o "$CONFIG_TPM2_TOOLS" = "y" ]; then
|
2018-03-12 01:27:19 +00:00
|
|
|
TMPFILE=/tmp/cbfs.$$
|
|
|
|
echo "$filename" > $TMPFILE
|
|
|
|
cat $filename >> $TMPFILE
|
2022-08-25 18:43:31 +00:00
|
|
|
tpmr extend -ix "$CONFIG_PCR" -if $TMPFILE \
|
2018-03-12 01:27:19 +00:00
|
|
|
|| die "$filename: tpm extend failed"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-04-30 02:58:44 +00:00
|
|
|
# TODO: copy CBFS file named "heads/initrd.tgz" to /tmp, measure and extract
|