public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: Update a file context and relabel
@ 2026-09-11 13:22 Petr Lautrbach
0 siblings, 0 replies; only message in thread
From: Petr Lautrbach @ 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 : c225414cf39df742f1aa4069c20a69575c48c782
Author : Petr Lautrbach <lautrbach@redhat.com>
Date : 2025-01-27T20:08:29+01:00
Stats : +58/-0 in 3 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/c225414cf39df742f1aa4069c20a69575c48c782?branch=pr775-checkpolicy-revdeps
Log:
Update a file context and relabel
Verifies: https://issues.redhat.com/browse/RHEL-73348
---
diff --git a/libsemanage/semanage_setfiles-selinux_restorecon/main.fmf b/libsemanage/semanage_setfiles-selinux_restorecon/main.fmf
new file mode 100644
index 0000000..9ed4f56
--- /dev/null
+++ b/libsemanage/semanage_setfiles-selinux_restorecon/main.fmf
@@ -0,0 +1,9 @@
+summary: Update a file context and relabel
+test: ./test.sh
+framework: beakerlib
+require:
+ - python3-policycoreutils
+ - policycoreutils-python-utils
+ - python3-libsemanage
+link:
+ - verifies: https://issues.redhat.com/browse/RHEL-73348
diff --git a/libsemanage/semanage_setfiles-selinux_restorecon/test.sh b/libsemanage/semanage_setfiles-selinux_restorecon/test.sh
new file mode 100755
index 0000000..788c938
--- /dev/null
+++ b/libsemanage/semanage_setfiles-selinux_restorecon/test.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+rlJournalStart
+ rlPhaseStartSetup
+ rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
+ rlRun "set -o pipefail"
+ 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
+ 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"
+ rlAssertEquals "Is $tmp/test $LABEL?" "$LABEL_TEST" "$LABEL"
+ rlAssertEquals "Is $tmp/test/subtest $LABEL?" "$LABEL_SUBTEST" "$LABEL"
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ rlRun "semanage fcontext -D"
+ rlRun "rm -r $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
new file mode 100755
index 0000000..6d2538a
--- /dev/null
+++ b/libsemanage/semanage_setfiles-selinux_restorecon/update_context.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+import sys
+import selinux
+import seobject
+
+def update_context(file_dir, new_context):
+ suffix = '(/.*)?'
+ trans = seobject.semanageRecords('targeted')
+ trans.start()
+
+ fcon = seobject.fcontextRecords(trans)
+ fcon.add(
+ file_dir + suffix,
+ new_context, '', 's0', '')
+ trans.finish()
+ selinux.restorecon(file_dir, True, True, True)
+
+
+if __name__ == "__main__":
+ update_context(sys.argv[1], sys.argv[2])
^ 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: Update a file context and relabel Petr Lautrbach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox