Unverified Commit 7c726f12 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Validate BIOS serial (#730)

parent b4a9bd85
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -114,6 +114,14 @@ else
  esac
fi

SM_BIOS=""
BIOS_SERIAL=$(</sys/class/dmi/id/product_serial)
BIOS_SERIAL="${BIOS_SERIAL//[![:alnum:]]/}"

if [ -n "$BIOS_SERIAL" ]; then
  SM_BIOS="-smbios type=1,serial=$BIOS_SERIAL"
fi

if [[ "$TPM" == [Yy1]* ]]; then

  rm -f /var/run/tpm.pid
+2 −8
Original line number Diff line number Diff line
@@ -16,15 +16,9 @@ CPU_OPTS="-cpu $CPU_FLAGS -smp $SMP"
RAM_OPTS=$(echo "-m ${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
MON_OPTS="-monitor $MONITOR -name $PROCESS,process=$PROCESS,debug-threads=on"
MAC_OPTS="-machine type=${MACHINE},smm=${SECURE},graphics=off,vmport=${VMPORT},dump-guest-core=off,hpet=${HPET}${KVM_OPTS}"
[ -n "$UUID" ] && MAC_OPTS+=" -uuid $UUID"

if [ -s "/sys/class/dmi/id/product_serial" ]; then
  BIOS_SERIAL=$(</sys/class/dmi/id/product_serial)
  BIOS_SERIAL="${BIOS_SERIAL//[![:alnum:]]/}"
  if [ -n "$BIOS_SERIAL" ]; then
    MAC_OPTS+=" -smbios type=1,serial=$BIOS_SERIAL"
  fi
fi
[ -n "$UUID" ] && MAC_OPTS+=" -uuid $UUID"
[ -n "$SM_BIOS" ] && MAC_OPTS+=" $SM_BIOS"

if [[ "${MACHINE,,}" != "pc-i440fx-2"* ]]; then
  DEV_OPTS="-object rng-random,id=objrng0,filename=/dev/urandom"