public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jan Onderka <jonderka@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: semanage_setfiles-selinux_restorecon: work with multiple SELINUXTYPES
Date: Fri, 11 Sep 2026 13:22:49 GMT	[thread overview]
Message-ID: <178913296934.1.7356738316081595716.tests-selinux-56d272ebd876@fedoraproject.org> (raw)

            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])

                 reply	other threads:[~2026-09-11 13:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178913296934.1.7356738316081595716.tests-selinux-56d272ebd876@fedoraproject.org \
    --to=jonderka@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox