From 28aaa75dde48779df78ffec408732e0f215c7339 Mon Sep 17 00:00:00 2001 From: Milos Malik Date: May 14 2021 08:00:47 +0000 Subject: skip the policy which is not installed The TC expected that all SELinux policies are installed before the TC is executed. If some of them is not installed, one of the test phases failed. Now, the test phase checks if particular policy is installed before calling the D-bus interface on it. --- diff --git a/policycoreutils/org-selinux-dbus-interfaces/Makefile b/policycoreutils/org-selinux-dbus-interfaces/Makefile index 92c8af6..6756710 100644 --- a/policycoreutils/org-selinux-dbus-interfaces/Makefile +++ b/policycoreutils/org-selinux-dbus-interfaces/Makefile @@ -63,3 +63,4 @@ $(METADATA): Makefile @echo "Bug: 1754873" >> $(METADATA) # RHEL-8 rhts-lint $(METADATA) + diff --git a/policycoreutils/org-selinux-dbus-interfaces/runtest.sh b/policycoreutils/org-selinux-dbus-interfaces/runtest.sh index 458c695..14779a5 100755 --- a/policycoreutils/org-selinux-dbus-interfaces/runtest.sh +++ b/policycoreutils/org-selinux-dbus-interfaces/runtest.sh @@ -91,13 +91,16 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest "org.selinux.change_default_policy" + # 1 argument is missing rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy" 1 - rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:minimum" - rlRun "grep SELINUXTYPE=minimum /etc/selinux/config" - rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:mls" - rlRun "grep SELINUXTYPE=mls /etc/selinux/config" - rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:targeted" - rlRun "grep SELINUXTYPE=targeted /etc/selinux/config" + # test existing policies + for POLICY_KIND in minimum mls targeted ; do + if rpm -q selinux-policy-${POLICY_KIND} ; then + rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:${POLICY_KIND}" + rlRun "grep SELINUXTYPE=${POLICY_KIND} /etc/selinux/config" + fi + done + # test a non-existent policy rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:xyz" 1 rlPhaseEnd