public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: semanage_setfiles-selinux_restorecon: work with multiple SELINUXTYPES
@ 2026-09-11 13:22 Jan Onderka
  0 siblings, 0 replies; only message in thread
From: Jan Onderka @ 2026-09-11 13:22 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 56d272ebd876d984d2b51ad886113e36d8cff32c
            Author : Jan Onderka <jonderka@redhat.com>
            Date   : 2025-05-15T12:08:47+02:00
            Stats  : +9/-6 in 3 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/56d272ebd876d984d2b51ad886113e36d8cff32c?branch=pr775-checkpolicy-revdeps

            Log:
            semanage_setfiles-selinux_restorecon: work with multiple SELINUXTYPES

Enable test execution with different SELINXTYPE than 'targeted',
otherwise the test ends with failure due to hardcoded 'targeted' policy
and expected pki_tomcat_etc_rw_t type might not be present at current
policy

---
diff --git a/libsemanage/semanage_setfiles-selinux_restorecon/main.fmf b/libsemanage/semanage_setfiles-selinux_restorecon/main.fmf
index 4944deb..2dce7fb 100644
--- a/libsemanage/semanage_setfiles-selinux_restorecon/main.fmf
+++ b/libsemanage/semanage_setfiles-selinux_restorecon/main.fmf
@@ -5,6 +5,7 @@ require:
   - python3-policycoreutils
   - policycoreutils-python-utils
   - python3-libsemanage
+  - setools-console
 link:
   - verifies: https://issues.redhat.com/browse/RHEL-73348
 id: f4ecd93d-d4bc-45fc-8386-193dd4f922e4

diff --git a/libsemanage/semanage_setfiles-selinux_restorecon/test.sh b/libsemanage/semanage_setfiles-selinux_restorecon/test.sh
index 788c938..b52efd9 100755
--- a/libsemanage/semanage_setfiles-selinux_restorecon/test.sh
+++ b/libsemanage/semanage_setfiles-selinux_restorecon/test.sh
@@ -6,14 +6,16 @@ rlJournalStart
     rlPhaseStartSetup
         rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
         rlRun "set -o pipefail"
+        rlRun "source /etc/selinux/config"
+        rlRun "ETC_RW_T_LABEL=\"$(seinfo -t | grep etc_rw_t | head -1 | awk '{$1=$1};1')\""
     rlPhaseEnd
 
     rlPhaseStartTest
         rlRun "mkdir -p $tmp/test/subtest | cut -d ' ' -f 1"
         rlRun "ls -Zd $tmp/test $tmp/test/subtest | cut -d ' ' -f 1"
 
-        rlRun "python3 update_context.py $tmp/test pki_tomcat_etc_rw_t"
-        LABEL=system_u:object_r:pki_tomcat_etc_rw_t:s0
+        rlRun "python3 update_context.py $tmp/test ${ETC_RW_T_LABEL} ${SELINUXTYPE}"
+        LABEL="system_u:object_r:${ETC_RW_T_LABEL}:s0"
         LABEL_TEST=$(ls -Zd $tmp/test | cut -d ' ' -f 1)
         LABEL_SUBTEST=$(ls -Zd $tmp/test/subtest | cut -d ' ' -f 1)
         rlRun "ls -Zd $tmp/test $tmp/test/subtest"
@@ -23,6 +25,6 @@ rlJournalStart
 
     rlPhaseStartCleanup
         rlRun "semanage fcontext -D"
-        rlRun "rm -r $tmp" 0 "Remove tmp directory"
+        rlRun "rm -rf $tmp" 0 "Remove tmp directory"
     rlPhaseEnd
 rlJournalEnd

diff --git a/libsemanage/semanage_setfiles-selinux_restorecon/update_context.py b/libsemanage/semanage_setfiles-selinux_restorecon/update_context.py
index 6d2538a..e58eac8 100755
--- a/libsemanage/semanage_setfiles-selinux_restorecon/update_context.py
+++ b/libsemanage/semanage_setfiles-selinux_restorecon/update_context.py
@@ -4,9 +4,9 @@ import sys
 import selinux
 import seobject
 
-def update_context(file_dir, new_context):
+def update_context(file_dir, new_context, selinux_policy):
     suffix = '(/.*)?'
-    trans = seobject.semanageRecords('targeted')
+    trans = seobject.semanageRecords(selinux_policy)
     trans.start()
 
     fcon = seobject.fcontextRecords(trans)
@@ -18,4 +18,4 @@ def update_context(file_dir, new_context):
 
 
 if __name__ == "__main__":
-    update_context(sys.argv[1], sys.argv[2])
+    update_context(sys.argv[1], sys.argv[2], sys.argv[3])

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-11 13:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 13:22 [tests/selinux] pr775-checkpolicy-revdeps: semanage_setfiles-selinux_restorecon: work with multiple SELINUXTYPES Jan Onderka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox