fix: Verify TPM socket exists (#374)

This commit is contained in:
Kroese 2024-01-23 01:43:43 +01:00 committed by GitHub
parent 110e46401c
commit bf5f894c76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -61,6 +61,7 @@ if [[ "${BOOT_MODE,,}" != "legacy" ]]; then
BOOT_OPTS="$BOOT_OPTS -global kvm-pit.lost_tick_policy=discard -global ICH9-LPC.disable_s3=1"
mkdir -p /dev/shm/tpm
chmod 755 /dev/shm/tpm
swtpm socket -t -d --tpmstate dir=/dev/shm/tpm --ctrl type=unixio,path=/dev/shm/tpm/swtpm-sock --tpm2
fi

View file

@ -15,6 +15,22 @@ DEV_OPTS="$DEV_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0
ARGS="$DEF_OPTS $CPU_OPTS $RAM_OPTS $MAC_OPTS $DISPLAY_OPTS $MON_OPTS $SERIAL_OPTS $NET_OPTS $DISK_OPTS $BOOT_OPTS $DEV_OPTS $USB_OPTS $ARGUMENTS"
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')
if [[ "${BOOT_MODE,,}" == "windows" ]]; then
for (( i = 0; i < 10; i++ )); do
[ -S "/dev/shm/tpm/swtpm-sock" ] && break
echo "Waiting for TPM socket to become available..."
sleep 1
done
if [ ! -S "/dev/shm/tpm/swtpm-sock" ]; then
error "TPM socket not found?" && exit 46
fi
fi
if [[ "${DISPLAY,,}" == "web" ]]; then
rm -f /dev/shm/msg.html
rm -f /dev/shm/index.html