1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 00:51:24 +03:00
systemd/test/TEST-06-SELINUX/test.sh
Frantisek Sumsal 31db4c20ea test: reintroduce m4 dependency for TEST-06-SELINUX
m4 is required to build the test SELinux module:

```
[   31.321789] sh[483]: /bin/sh: line 1: m4: command not found
[   31.882668] sh[488]: Compiling targeted systemd_test module
[   32.120862] sh[492]: /bin/sh: line 1: m4: command not found
[   32.159897] sh[458]: make: *** [/usr/share/selinux/devel/include/Makefile:156: tmp/systemd_test.mod] Error 127
```
2021-05-19 13:01:07 +02:00

58 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="SELinux tests"
IMAGE_NAME="selinux"
TEST_NO_NSPAWN=1
# Requirements:
# Fedora 23
# selinux-policy-targeted
# selinux-policy-devel
# 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
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
SETUP_SELINUX=yes
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
# 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
rm -rf "${workspace:?}/$policy_headers_dir"
inst_dir /usr/share/selinux
if ! cp -ar "$policy_headers_dir" "$workspace/$policy_headers_dir"; then
dfatal "Failed to copy $policy_headers_dir"
exit 1
fi
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
dracut_install -o /usr/libexec/selinux/hll/pp # Fedora/RHEL/...
dracut_install -o /usr/lib/selinux/hll/pp # Debian/Ubuntu/...
)
}
do_test "$@"