Skip to content

Commit

Permalink
test: Fix test_tpm2_file_permissions for BSD
Browse files Browse the repository at this point in the history
BSD cp does not understand the -d option, so remove it.
It's better to use "su -u nobody -c '...'" than sudo, which makes
this test also work on the BSDs.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Sep 28, 2021
1 parent 3051082 commit 91767f3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/_test_tpm2_file_permissions
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if [ -z "$(file "${SWTPM_EXE}" | grep ELF)" ]; then
directory="$(dirname "${SWTPM_EXE}")/.libs"
if [ -d "${directory}" ]; then
cp "${directory}/swtpm" "${TPM_PATH}"
cp -d "${directory}"/libswtpm_libtpms.so* "${TPM_PATH}"
cp "${directory}"/libswtpm_libtpms.so* "${TPM_PATH}"
else
echo "Could not find .libs directory to copy swtpm from."
exit 77
Expand All @@ -67,7 +67,7 @@ chmod 0600 "${TPM_PATH}"/tpm2-00* "${PIDFILE}" "${PWDFILE}" "${LOGFILE}" "${SWTP
chown "${TESTUSER}:${TESTGROUP}" "${TPM_PATH}"/*

# Test-execute the swtpm program as $TESTUSER
tmp=$(sudo -u "${TESTUSER}" bash -c "LD_LIBRARY_PATH="${SWTPM_LD_LIBRARY_PATH}" "${MY_SWTPM_EXE}" --help 2>&1")
tmp=$(su -m "${TESTUSER}" -c "LD_LIBRARY_PATH="${SWTPM_LD_LIBRARY_PATH}" "${MY_SWTPM_EXE}" --help 2>&1")
if [ $? -ne 0 ]; then
echo "Could not run '${MY_SWTPM_EXE}' as ${TESTUSER}. Skipping swtpm_setup tests."
echo "Error: ${tmp}"
Expand Down

0 comments on commit 91767f3

Please sign in to comment.