From 84f350dacedefcb13e016e2aeb47b33667b7decc Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Thu, 9 Jan 2020 16:48:30 -0500 Subject: [PATCH] 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 --- src/swtpm_setup/swtpm_setup.sh.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/swtpm_setup/swtpm_setup.sh.in b/src/swtpm_setup/swtpm_setup.sh.in index 07a08ca..4ec54ea 100755 --- a/src/swtpm_setup/swtpm_setup.sh.in +++ b/src/swtpm_setup/swtpm_setup.sh.in @@ -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