diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2021-04-19 13:01:59 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-04-20 10:26:43 +0200 |
commit | 3f161ba9bc43e68e5ac3dd9ef18309e6e88bee89 (patch) | |
tree | 08f9ff10b2b06341ab6f4ea97bc83817d30a4154 /test/TEST-06-SELINUX | |
parent | mount-util: make umount_and_rmdir_and_freep() cleanup handler deal with NULL (diff) | |
download | systemd-3f161ba9bc43e68e5ac3dd9ef18309e6e88bee89.tar.xz systemd-3f161ba9bc43e68e5ac3dd9ef18309e6e88bee89.zip |
test: make the test entrypoint scripts shellcheck-compliant
Diffstat (limited to 'test/TEST-06-SELINUX')
-rwxr-xr-x | test/TEST-06-SELINUX/test.sh | 36 |
1 files changed, 22 insertions, 14 deletions
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 |