swtpm_setup: Use 1st part of SWTPM_EXE/SWTPM_IOCTL to determine executable

Search for the SWTPM_EXE / SWTPM_IOCTL executable using 'type -P' to
determine whether it is an executable rather than assuming a full path
is given on which we can check -x.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2020-01-09 16:48:30 -05:00 committed by Stefan Berger
parent 996ad55fbc
commit 84f350dace

View File

@ -2102,7 +2102,7 @@ main()
local flags=0
local tpm_state_path=""
local config_file="$DEFAULT_CONFIG_FILE"
local vmid=""
local vmid="" tmp
local ret
local keyfile pwdfile cipher="aes-128-cbc"
local keyfile_fd pwdfile_fd
@ -2251,7 +2251,8 @@ main()
exit 1
fi
if [ ! -x "$(echo $SWTPM | cut -d " " -f1)" ]; then
tmp="$(echo $SWTPM | cut -d" " -f1)"
if [ ! -x "$(type -P $tmp)" ]; then
logerr "TPM at $SWTPM is not an executable."
exit 1
fi
@ -2273,7 +2274,8 @@ main()
exit 1
fi
if [ ! -x "$(echo $SWTPM_IOCTL | cut -d " " -f1)" ]; then
tmp="$(echo $SWTPM_IOCTL | cut -d" " -f1)"
if [ ! -x "$(type -P $tmp)" ]; then
logerr "swtpm_ioctl at $SWTPM_IOCTL is not an executable."
exit 1
fi