travis: misc software TPM changes
Mimi Zohar
maintainercover travis: misc software TPM changes
Here are a few more software TPM related changes.
Mimi
Mimi Zohar (3):
travis: retry sending tssstartup
travis: rename the software tpm variables
travis: properly kill the software TPM
tests/boot_aggregate.test | 56 +++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 23 deletions(-)
Signature · 1 line
2.18.4
Mimi Zohar
maintainerPATCH 1/3 travis: retry sending tssstartup
The software TPM might not be listening for commands yet. Try re-sending the tssstartup.
Reported-by Ken Goldman <[email protected]>
Signed-off-by Mimi Zohar <[email protected]>
--- tests/boot_aggregate.test | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tests/boot_aggregate.test +13 -1
@@ -97,8 +97,20 @@ swtpm_init() { return "$SKIP" fi - echo "INFO: Walking ${BINARY_BIOS_MEASUREMENTS} initializing the software TPM" + echo "INFO: Sending software TPM startup" "${TSSDIR}/tssstartup" + if [ $? -ne 0 ]; then + echo "INFO: Retry sending software TPM startup" + sleep 1 + "${TSSDIR}/tssstartup" + fi + + if [ $? -ne 0 ]; then + echo "INFO: Software TPM startup failed" + return "$SKIP" + fi + + echo "INFO: Walking ${BINARY_BIOS_MEASUREMENTS} initializing the software TPM" # $(${TSSDIR}/tsseventextend -tpm -if "${BINARY_BIOS_MEASUREMENTS}" -v) 2>&1 > /dev/null "${TSSDIR}/tsseventextend" -tpm -if "${BINARY_BIOS_MEASUREMENTS}" -v > /dev/null 2>&1 }
Signature · 1 line
2.18.4
Mimi Zohar
maintainerPATCH 2/3 travis: rename the software tpm variables
In reply to Mimi ZoharThe existing variable names swtpm and swtpm1 is confusing. Rename "swtpm" to "tpm_server" and "swtpm1" as "swtpm".
Reported-by Ken Goldman <[email protected]>
Signed-off-by Mimi Zohar <[email protected]>
--- tests/boot_aggregate.test | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
tests/boot_aggregate.test +13 -13
@@ -54,36 +54,36 @@ cleanup() { # Try to start a software TPM if needed. swtpm_start() { - local swtpm swtpm1 + local tpm_server swtpm - swtpm="$(which tpm_server)" - swtpm1="$(which swtpm)" - if [ -z "${swtpm}" ] && [ -z "${swtpm1}" ]; then + tpm_server="$(which tpm_server)" + swtpm="$(which swtpm)" + if [ -z "${tpm_server}" ] && [ -z "${swtpm}" ]; then echo "${CYAN}SKIP: Software TPM (tpm_server and swtpm) not found${NORM}" return "$SKIP" fi - if [ -n "${swtpm1}" ]; then - pgrep swtpm1 + if [ -n "${swtpm}" ]; then + pgrep swtpm if [ $? -eq 0 ]; then echo "INFO: Software TPM (swtpm) already running" return 114 else - echo "INFO: Starting software TPM: ${swtpm1}" - mkdir ./myvtpm - ${swtpm1} socket --tpmstate dir=./myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init > /dev/null 2>&1 & + echo -n "INFO: Starting software TPM: ${swtpm}" + mkdir -p ./myvtpm + ${swtpm} socket --tpmstate dir=./myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init > /dev/null 2>&1 & SWTPM_PPID=$! fi - elif [ -n "${swtpm}" ]; then + elif [ -n "${tpm_server}" ]; then # tpm_server uses the Microsoft simulator encapsulated packet format export TPM_SERVER_TYPE="mssim" - pgrep swtpm + pgrep tpm_server if [ $? -eq 0 ]; then echo "INFO: Software TPM (tpm_server) already running" return 114 else - echo "INFO: Starting software TPM: ${swtpm}" - ${swtpm} > /dev/null 2>&1 & + echo "INFO: Starting software TPM: ${tpm_server}" + ${tpm_server} > /dev/null 2>&1 & SWTPM_PPID=$! fi fi
Signature · 1 line
2.18.4
Mimi Zohar
maintainerPATCH 3/3 travis: properly kill the software TPM
In reply to Mimi ZoharSend "tsstpmcmd -stop" to properly stop the tpm_server. Send SIGTERM to stop the swtpm process.
Signed-off-by Mimi Zohar <[email protected]>
--- tests/boot_aggregate.test | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
tests/boot_aggregate.test +7 -9
@@ -41,14 +41,12 @@ else fi -# Only stop this test's software TPM. Preferred method: "tsstpmcmd -stop" +# Only stop this test's software TPM cleanup() { - if [ -n "${SWTPM_PPID}" ]; then - if [ -f "${TSSDIR}/tsstpmcmd" ]; then - "${TSSDIR}/tsstpmcmd" -stop - else - pkill -P "${SWTPM_PPID}" - fi + if [ -n "${SWTPM_PID}" ]; then + kill -SIGTERM "${SWTPM_PID}" + elif [ -n "${TPMSERVER_PID}" ]; then + "${TSSDIR}/tsstpmcmd" -stop fi }
@@ -72,7 +70,7 @@ swtpm_start() { echo -n "INFO: Starting software TPM: ${swtpm}" mkdir -p ./myvtpm ${swtpm} socket --tpmstate dir=./myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init > /dev/null 2>&1 & - SWTPM_PPID=$! + SWTPM_PID=$! fi elif [ -n "${tpm_server}" ]; then # tpm_server uses the Microsoft simulator encapsulated packet format
@@ -84,7 +82,7 @@ swtpm_start() { else echo "INFO: Starting software TPM: ${tpm_server}" ${tpm_server} > /dev/null 2>&1 & - SWTPM_PPID=$! + TPMSERVER_PID=$! fi fi return 0
Signature · 1 line
2.18.4