From 55944e5e40b1be2afc4855d8d2baf4b73d1876b5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:49:52 +0200 Subject: Adding upstream version 255.4. Signed-off-by: Daniel Baumann --- test/TEST-06-SELINUX/Makefile | 1 + test/TEST-06-SELINUX/test.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 120000 test/TEST-06-SELINUX/Makefile create mode 100755 test/TEST-06-SELINUX/test.sh (limited to 'test/TEST-06-SELINUX') diff --git a/test/TEST-06-SELINUX/Makefile b/test/TEST-06-SELINUX/Makefile new file mode 120000 index 0000000..e9f93b1 --- /dev/null +++ b/test/TEST-06-SELINUX/Makefile @@ -0,0 +1 @@ +../TEST-01-BASIC/Makefile \ No newline at end of file diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh new file mode 100755 index 0000000..3841015 --- /dev/null +++ b/test/TEST-06-SELINUX/test.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e + +TEST_DESCRIPTION="SELinux tests" +IMAGE_NAME="selinux" +TEST_NO_NSPAWN=1 + +if [[ -e /etc/selinux/config ]]; then + SEPOLICY="$(awk -F= '/^SELINUXTYPE=/ {print $2; exit}' /etc/selinux/config)" + + # C8S doesn't set SELINUXTYPE in /etc/selinux/config, so default to 'targeted' + if [[ -z "$SEPOLICY" ]]; then + echo "Failed to parse SELinux policy from /etc/selinux/config, falling back to 'targeted'" + SEPOLICY="targeted" + fi + + if [[ ! -d "/etc/selinux/$SEPOLICY" ]]; then + echo "Missing policy directory /etc/selinux/$SEPOLICY, skipping the test" + exit 0 + fi + + echo "Using SELinux policy '$SEPOLICY'" +else + echo "/etc/selinux/config is missing, skipping the test" + exit 0 +fi + +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" + +SETUP_SELINUX=yes +KERNEL_APPEND="${KERNEL_APPEND:-} selinux=1 enforcing=0 lsm=selinux" + +test_append_files() { + local workspace="${1:?}" + + setup_selinux + # Config file has (unfortunately) always precedence, so let's switch it there as well + sed -i '/^SELINUX=disabled$/s/disabled/permissive/' "$workspace/etc/selinux/config" +} + +do_test "$@" -- cgit v1.2.3