public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] main: libselinux: add UTF-8 local file-context regression test
@ 2026-09-10  8:54 Petr Lautrbach
  0 siblings, 0 replies; only message in thread
From: Petr Lautrbach @ 2026-09-10  8:54 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : main
            Commit : da9aa8c2bdaacbbbe3740ad0d89138922f817234
            Author : Petr Lautrbach <lautrbach@redhat.com>
            Date   : 2026-09-07T18:33:44+02:00
            Stats  : +71/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/da9aa8c2bdaacbbbe3740ad0d89138922f817234?branch=main

            Log:
            libselinux: add UTF-8 local file-context regression test

Add a new beakerlib test that verifies semanage fcontext and restorecon
work correctly with non-ASCII (UTF-8) paths. The test creates a UTF-8
directory name, applies a local file-context rule, restores labels, and
checks labeling with matchpathcon.

Related: rhbz#2427550

---
diff --git a/libselinux/UTF-8-file-contexts/main.fmf b/libselinux/UTF-8-file-contexts/main.fmf
new file mode 100644
index 0000000..5607d64
--- /dev/null
+++ b/libselinux/UTF-8-file-contexts/main.fmf
@@ -0,0 +1,19 @@
+summary: Verify UTF-8 paths in local file contexts
+description: |+
+    Verify that semanage fcontext can add and use a local file-context rule
+    for a path containing UTF-8 characters.
+
+contact: Petr Lautrbach <lautrbach@redhat.com>
+component:
+  - libselinux
+require:
+  - libselinux-utils
+  - policycoreutils
+  - policycoreutils-python-utils
+enabled: true
+duration: 5m
+tier: 1
+tag:
+  - CI-Tier-1
+link:
+  - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2427550

diff --git a/libselinux/UTF-8-file-contexts/runtest.sh b/libselinux/UTF-8-file-contexts/runtest.sh
new file mode 100755
index 0000000..42743bd
--- /dev/null
+++ b/libselinux/UTF-8-file-contexts/runtest.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/libselinux/Sanity/UTF-8-file-contexts
+#   Description: Verify UTF-8 paths in local file contexts
+#   Author: Petr Lautrbach <lautrbach@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+FCONTEXT_TYPE="etc_t"
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlAssertRpm libselinux-utils
+        rlAssertRpm policycoreutils
+        rlAssertRpm policycoreutils-python-utils
+        rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
+        rlRun "UTF8_PATH='${TmpDir}/Öffentlich'"
+        rlRun "mkdir -p '${UTF8_PATH}/subdir'"
+        rlRun "touch '${UTF8_PATH}/subdir/file'"
+    rlPhaseEnd
+
+    rlPhaseStartTest
+        rlRun "semanage fcontext -a -t ${FCONTEXT_TYPE} '${UTF8_PATH}(/.*)?'"
+
+        rlRun -s "semanage fcontext -l -C"
+        rlAssertGrep "${UTF8_PATH}" "$rlRun_LOG"
+
+        rlRun -s "restorecon -RFvv '${UTF8_PATH}'"
+        rlAssertNotGrep "Non-ASCII characters found" "$rlRun_LOG"
+
+        rlRun -s "matchpathcon '${UTF8_PATH}'"
+        rlAssertGrep ":${FCONTEXT_TYPE}:" "$rlRun_LOG"
+
+        rlRun -s "matchpathcon '${UTF8_PATH}/subdir/file'"
+        rlAssertGrep ":${FCONTEXT_TYPE}:" "$rlRun_LOG"
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        rlRun "semanage fcontext -d '${UTF8_PATH}(/.*)?'"
+    rlPhaseEnd
+
+    # Cleanup phase: Remove test directory
+    rlPhaseStartCleanup
+        rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
+    rlPhaseEnd
+        
+rlJournalPrintText
+rlJournalEnd

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

only message in thread, other threads:[~2026-09-10  8:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-10  8:54 [tests/selinux] main: libselinux: add UTF-8 local file-context regression test Petr Lautrbach

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