check for TPM program and device before loading modules (issue #181)

This commit is contained in:
Trammell Hudson 2017-04-10 17:48:52 -04:00
parent b6eaa5c295
commit c19193d7c6
Failed to extract signature

View File

@ -24,14 +24,23 @@ if [ ! -r "$MODULE" ]; then
die "$MODULE: not found?"
fi
tpm extend -ix "$MODULE_PCR" -if "$MODULE" || die "$MODULE: tpm extend failed"
if [ ! -r /sys/class/tpm/tpm0/pcrs -o ! -x /bin/tpm ]; then
tpm_missing=1
fi
if [ ! -z "$@" ]; then
if [ -z "$tpm_missing" ]; then
tpm extend -ix "$MODULE_PCR" -if "$MODULE" \
|| die "$MODULE: tpm extend failed"
fi
if [ ! -z "$@" -a -z "$tpm_missing" ]; then
TMPFILE=/tmp/insmod.$$
echo "$@" > $TMPFILE
tpm extend -ix "$MODULE_PCR" -if $TMPFILE || die "$MODULE: tpm extend on arguments failed"
tpm extend -ix "$MODULE_PCR" -if $TMPFILE \
|| die "$MODULE: tpm extend on arguments failed"
fi
# Since we have replaced the real insmod, we must invoke
# the busybox insmod via the original executable
busybox insmod "$MODULE" "$@" || die "$MODULE: insmod failed"
busybox insmod "$MODULE" "$@" \
|| die "$MODULE: insmod failed"