]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-06-SELINUX/test.sh
d65d273055f6785e601731ddc1b6ad5fcae91cca
[thirdparty/systemd.git] / test / TEST-06-SELINUX / test.sh
1 #!/usr/bin/env bash
2 set -e
3
4 TEST_DESCRIPTION="SELinux tests"
5 IMAGE_NAME="selinux"
6 TEST_NO_NSPAWN=1
7
8 # Requirements:
9 # Fedora 23
10 # selinux-policy-targeted
11 # selinux-policy-devel
12
13 # Check if selinux-policy-devel is installed, and if it isn't bail out early instead of failing
14 test -f /usr/share/selinux/devel/include/system/systemd.if || exit 0
15
16 # shellcheck source=test/test-functions
17 . "${TEST_BASE_DIR:?}/test-functions"
18
19 SETUP_SELINUX=yes
20 KERNEL_APPEND="${KERNEL_APPEND:=} selinux=1 security=selinux"
21
22 test_append_files() {
23 (
24 local workspace="${1:?}"
25 local policy_headers_dir=/usr/share/selinux/devel
26 local modules_dir=/var/lib/selinux
27
28 setup_selinux
29 # Make sure we never expand this to "/..."
30 rm -rf "${workspace:?}/$modules_dir"
31
32 if ! cp -ar "$modules_dir" "$workspace/$modules_dir"; then
33 dfatal "Failed to copy $modules_dir"
34 exit 1
35 fi
36
37 rm -rf "${workspace:?}/$policy_headers_dir"
38 inst_dir /usr/share/selinux
39
40 if ! cp -ar "$policy_headers_dir" "$workspace/$policy_headers_dir"; then
41 dfatal "Failed to copy $policy_headers_dir"
42 exit 1
43 fi
44
45 mkdir "$workspace/systemd-test-module"
46 cp systemd_test.te "$workspace/systemd-test-module"
47 cp systemd_test.if "$workspace/systemd-test-module"
48 cp systemd_test.fc "$workspace/systemd-test-module"
49 image_install -o sesearch
50 image_install runcon
51 image_install checkmodule semodule semodule_package m4 make load_policy sefcontext_compile
52 image_install -o /usr/libexec/selinux/hll/pp # Fedora/RHEL/...
53 image_install -o /usr/lib/selinux/hll/pp # Debian/Ubuntu/...
54 )
55 }
56
57 do_test "$@"