From 3f161ba9bc43e68e5ac3dd9ef18309e6e88bee89 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 19 Apr 2021 13:01:59 +0200 Subject: test: make the test entrypoint scripts shellcheck-compliant --- test/TEST-06-SELINUX/test.sh | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'test/TEST-06-SELINUX') diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh index f05cd35593..984caf4b4f 100755 --- a/test/TEST-06-SELINUX/test.sh +++ b/test/TEST-06-SELINUX/test.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="SELinux tests" IMAGE_NAME="selinux" TEST_NO_NSPAWN=1 @@ -12,32 +13,39 @@ TEST_NO_NSPAWN=1 # Check if selinux-policy-devel is installed, and if it isn't bail out early instead of failing test -f /usr/share/selinux/devel/include/system/systemd.if || exit 0 -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" + SETUP_SELINUX=yes -KERNEL_APPEND="$KERNEL_APPEND selinux=1 security=selinux" +KERNEL_APPEND="${KERNEL_APPEND:=} selinux=1 security=selinux" test_append_files() { ( + local workspace="${1:?}" + local policy_headers_dir=/usr/share/selinux/devel + local modules_dir=/var/lib/selinux + setup_selinux - local _modules_dir=/var/lib/selinux - rm -rf $1/$_modules_dir - if ! cp -ar $_modules_dir $1/$_modules_dir; then - dfatal "Failed to copy $_modules_dir" + # Make sure we never expand this to "/..." + rm -rf "${workspace:?}/$modules_dir" + + if ! cp -ar "$modules_dir" "$workspace/$modules_dir"; then + dfatal "Failed to copy $modules_dir" exit 1 fi - local _policy_headers_dir=/usr/share/selinux/devel - rm -rf $1/$_policy_headers_dir + rm -rf "${workspace:?}/$policy_headers_dir" inst_dir /usr/share/selinux - if ! cp -ar $_policy_headers_dir $1/$_policy_headers_dir; then - dfatal "Failed to copy $_policy_headers_dir" + + if ! cp -ar "$policy_headers_dir" "$workspace/$policy_headers_dir"; then + dfatal "Failed to copy $policy_headers_dir" exit 1 fi - mkdir $1/systemd-test-module - cp systemd_test.te $1/systemd-test-module - cp systemd_test.if $1/systemd-test-module - cp systemd_test.fc $1/systemd-test-module + mkdir "$workspace/systemd-test-module" + cp systemd_test.te "$workspace/systemd-test-module" + cp systemd_test.if "$workspace/systemd-test-module" + cp systemd_test.fc "$workspace/systemd-test-module" dracut_install -o sesearch dracut_install runcon dracut_install checkmodule semodule semodule_package m4 make load_policy sefcontext_compile -- cgit v1.2.3