From bf5f894c760f412c7e0c802981a15ae9cc39a1a9 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 23 Jan 2024 01:43:43 +0100 Subject: [PATCH] fix: Verify TPM socket exists (#374) --- src/boot.sh | 1 + src/config.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/boot.sh b/src/boot.sh index 750f51f..be1911c 100644 --- a/src/boot.sh +++ b/src/boot.sh @@ -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 diff --git a/src/config.sh b/src/config.sh index fee92d1..7d3b971 100644 --- a/src/config.sh +++ b/src/config.sh @@ -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