public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: policycoreutils/setfiles: Make the relabel test robust
Date: Fri, 11 Sep 2026 13:18:49 GMT	[thread overview]
Message-ID: <178913272966.1.17284261336448933632.tests-selinux-e48b62767b4c@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : e48b62767b4c20bdd9954326bc9c77ce77ba7e04
            Author : Petr Lautrbach <plautrba@redhat.com>
            Date   : 2021-02-05T15:28:21+01:00
            Stats  : +28/-12 in 1 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/e48b62767b4c20bdd9954326bc9c77ce77ba7e04?branch=pr775-checkpolicy-revdeps

            Log:
            policycoreutils/setfiles: Make the relabel test robust

- use directory which is not usually mounted as tmpfs
- use own spec_file
- use -F option
- check context of all directories and files inside chroot

---
diff --git a/policycoreutils/setfiles/runtest.sh b/policycoreutils/setfiles/runtest.sh
index 539eaae..a760694 100755
--- a/policycoreutils/setfiles/runtest.sh
+++ b/policycoreutils/setfiles/runtest.sh
@@ -66,23 +66,39 @@ EOF"
 
     rlPhaseStartTest "setfiles should not abort when it can't label a file - bz#1794518"
         USER=$(mktemp -u userXXXX)
-        USERTMP=$(mktemp -d)
+        USERTMP=$(mktemp -d -p /var/tmp)
         rlRun "useradd ${USER}"
+        rlRun "cat > ${USERTMP}/spec_file <<EOF
+/   -d system_u:object_r:default_t:s0
+/.*  system_u:object_r:default_t:s0
+EOF"
+        DIRS="${USERTMP}/1/1 ${USERTMP}/1/2 ${USERTMP}/2/2 ${USERTMP}/3/4 ${USERTMP}/5/6"
         rlRun "
-chown ${USER} ${USERTMP}
-mkdir -p ${USERTMP}/1/1 ${USERTMP}/1/2
-mkdir -p ${USERTMP}/2/1 ${USERTMP}/2/2
-mkdir -p ${USERTMP}/3/4
-mkdir -p ${USERTMP}/5/6
-touch ${USERTMP}/3/4/i
+for DIR in ${DIRS}; do
+    mkdir -p \${DIR}
+done
+touch ${USERTMP}/1/1/${USER} ${USERTMP}/3/4/chattr
 chown -R ${USER} ${USERTMP}
-chown root: ${USERTMP}/1/2
-chattr +i ${USERTMP}/3/4/i
+mkdir -p ${USERTMP}/2/1
+touch ${USERTMP}/2/1/root
+chattr +i ${USERTMP}/3/4/chattr
 " 0,1 "Prepare directory structure"
-        rlRun "su ${USER} -c '/usr/sbin/setfiles -v -r ${USERTMP} /etc/selinux/targeted/contexts/files/file_contexts ${USERTMP}'"
-        rlRun "userdel -r ${USER}"
-        chattr -i ${USERTMP}/3/4/i
+        rlRun "su ${USER} -c '/usr/sbin/setfiles -F -d -v -r ${USERTMP} ${USERTMP}/spec_file ${USERTMP}'" 0-255
+        for DIR in ${DIRS}; do
+            CONTEXT=$(secon --prompt --file ${DIR})
+            rlAssertEquals "${DIR}" ${CONTEXT} "system_u:object_r:default_t:s0"
+        done
+        CONTEXT=$(secon --prompt --file ${USERTMP}/1/1/${USER})
+        rlAssertEquals "${USERTMP}/1/1/${USER}" ${CONTEXT} "system_u:object_r:default_t:s0"
+        CONTEXT=$(secon --prompt --file ${USERTMP}/2/1)
+        rlAssertNotEquals "${USERTMP}/2/1" ${CONTEXT} "system_u:object_r:default_t:s0"
+        CONTEXT=$(secon --prompt --file ${USERTMP}/2/1/root)
+        rlAssertNotEquals "${USERTMP}/2/1/root" ${CONTEXT} "system_u:object_r:default_t:s0"
+        CONTEXT=$(secon --prompt --file ${USERTMP}/3/4/chattr)
+        rlAssertNotEquals "${USERTMP}/3/4/chattr" ${CONTEXT} "system_u:object_r:default_t:s0"
+        chattr -i ${USERTMP}/3/4/chattr
         rlRun "rm -rf ${USERTMP}"
+        rlRun "userdel -r ${USER}"
     rlPhaseEnd
     rlPhaseStartCleanup
         rlRun "popd"

                 reply	other threads:[~2026-09-11 13:18 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=178913272966.1.17284261336448933632.tests-selinux-e48b62767b4c@fedoraproject.org \
    --to=plautrba@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