From f21da5c13bdad62eecc4bfb7a90c3e7eba066191 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Jul 28 2019 18:05:40 +0000 Subject: Fix selinux tests in CentOS8 --- diff --git a/tests/p_selinux/0_install_tools.sh b/tests/p_selinux/0_install_tools.sh index 814f096..1e852dc 100755 --- a/tests/p_selinux/0_install_tools.sh +++ b/tests/p_selinux/0_install_tools.sh @@ -4,6 +4,8 @@ t_Log "Running $0 - install package selinux policycoreutils tools" if [ "$centos_ver" = "6" ] ; then t_InstallPackage policycoreutils-python +elif [ "$centos_ver" = "8" ] ; then + t_InstallPackage python3-libselinux else t_InstallPackage libselinux-python fi diff --git a/tests/p_selinux/selinux_enforce.sh b/tests/p_selinux/selinux_enforce.sh index b3c90d2..0a065e1 100755 --- a/tests/p_selinux/selinux_enforce.sh +++ b/tests/p_selinux/selinux_enforce.sh @@ -3,14 +3,14 @@ t_Log "Running $0 - check if SELinux is in enforcing mode" -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then selinux_file=/sys/fs/selinux/enforce else selinux_file=/selinux/enforce fi if [ "$SKIP_QA_HARNESS" = "1" ] ; then - echo "Skipping this test ..." + t_Log "Skipping this test ..." else cat $selinux_file | grep 1 > /dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_selinux/selinux_policy_mismatch.py b/tests/p_selinux/selinux_policy_mismatch.py deleted file mode 100755 index 11d7186..0000000 --- a/tests/p_selinux/selinux_policy_mismatch.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -import sys -import selinux.audit2why as audit2why - -print "Testing audit2why for policy mismatch ..." - -try: - audit2why.init() -except: - sys.exit(1) - -sys.exit(0) - diff --git a/tests/p_selinux/selinux_policy_mismatch.sh b/tests/p_selinux/selinux_policy_mismatch.sh new file mode 100755 index 0000000..b6f0af2 --- /dev/null +++ b/tests/p_selinux/selinux_policy_mismatch.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ "$centos_ver" -ge 8 ] ; then +PYTHON=python3 +else +PYTHON=python +fi + +t_Log "Running $0 - Testing audit2why for policy mismatch ..." + +cat << __EOF__ | $PYTHON - +import sys +import selinux.audit2why as audit2why + +try: + audit2why.init() +except: + sys.exit(1) +sys.exit(0) +__EOF__ + +t_CheckExitStatus $?