public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: policycoreutils/setfiles: Basic sanity test for setfiles
@ 2026-09-11 13:18 Petr Lautrbach
0 siblings, 0 replies; only message in thread
From: Petr Lautrbach @ 2026-09-11 13:18 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : tests/selinux
Branch : pr775-checkpolicy-revdeps
Commit : 33abfe035c2124566ef8f4b2319b18998e5f233d
Author : Petr Lautrbach <plautrba@redhat.com>
Date : 2021-02-04T18:18:44+01:00
Stats : +182/-0 in 4 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/33abfe035c2124566ef8f4b2319b18998e5f233d?branch=pr775-checkpolicy-revdeps
Log:
policycoreutils/setfiles: Basic sanity test for setfiles
---
diff --git a/policycoreutils/setfiles/Makefile b/policycoreutils/setfiles/Makefile
new file mode 100644
index 0000000..6e1a5af
--- /dev/null
+++ b/policycoreutils/setfiles/Makefile
@@ -0,0 +1,70 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Makefile of /CoreOS/policycoreutils/Sanity/setfiles
+# Description: Basic sanity tests for setfiles
+# Author: Michal Trunecka <mtruneck@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2021 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing
+# to use, modify, copy, or redistribute it subject to the terms
+# and conditions of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+export TEST=/CoreOS/policycoreutils/Sanity/setfiles
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ./runtest.sh
+
+build: $(BUILT_FILES)
+ test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Michal Trunecka <mtruneck@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: Basic sanity tests for setfiles" >> $(METADATA)
+ @echo "Type: Sanity" >> $(METADATA)
+ @echo "TestTime: 30m" >> $(METADATA)
+ @echo "RunFor: policycoreutils" >> $(METADATA)
+ @echo "Requires: policycoreutils" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+ @echo "Bug: 1098062" >> $(METADATA) # RHEL-6
+ @echo "Bug: 1086572" >> $(METADATA) # RHEL-6
+ @echo "Bug: 1086456" >> $(METADATA) # RHEL-6
+ @echo "Bug: 1271326" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1271327" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1584116" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1794518" >> $(METADATA) # RHEL-8
+
+ rhts-lint $(METADATA)
diff --git a/policycoreutils/setfiles/PURPOSE b/policycoreutils/setfiles/PURPOSE
new file mode 100644
index 0000000..eb93ba3
--- /dev/null
+++ b/policycoreutils/setfiles/PURPOSE
@@ -0,0 +1,3 @@
+PURPOSE of /CoreOS/policycoreutils/Sanity/setfiles
+Description: Basic sanity tests for setfiles
+Author: Michal Trunecka <mtruneck@redhat.com>
diff --git a/policycoreutils/setfiles/main.fmf b/policycoreutils/setfiles/main.fmf
new file mode 100644
index 0000000..23b5eec
--- /dev/null
+++ b/policycoreutils/setfiles/main.fmf
@@ -0,0 +1,16 @@
+summary: Basic sanity tests for setfiles
+description: Basic sanity tests for setfiles
+contact: Petr Lautrbach <plautrba@redhat.com>
+component:
+- policycoreutils
+framework: beakerlib
+require:
+- e2fsprogs
+- policycoreutils
+duration: 5m
+tier: 1
+enabled: true
+adjust:
+ enabled: false
+ when: distro ~< rhel-8.4
+ because: not expected to be fixed in RHEL-8 below 8.4
diff --git a/policycoreutils/setfiles/runtest.sh b/policycoreutils/setfiles/runtest.sh
new file mode 100755
index 0000000..539eaae
--- /dev/null
+++ b/policycoreutils/setfiles/runtest.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of /CoreOS/policycoreutils/Sanity/setfiles
+# Description: Basic sanity tests for setfiles
+# Author: Michal Trunecka <mtruneck@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2021 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing
+# to use, modify, copy, or redistribute it subject to the terms
+# and conditions of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include Beaker environment
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="policycoreutils"
+
+rlJournalStart
+ rlPhaseStartSetup
+ rlAssertRpm $PACKAGE
+ rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
+ rlRun "pushd $TmpDir"
+ OUTPUT=`mktemp`
+ rlPhaseEnd
+
+ rlPhaseStartTest "bz1086456 + bz1086572 + bz1098062 + bz1584116"
+ rlLog "Check for bz#1086456"
+ rlRun "touch /tmp/file"
+ rlRun "cat > spec_file <<EOF
+/tmp/file -- system_u:object_r:etc_t:s0
+
+EOF"
+ rlRun "chcon -t etc_t ./spec_file"
+ rlRun -s "setfiles -r -v spec_file /tmp" 1-255
+ rlAssertGrep "No such file or directory" $rlRun_LOG
+ rm -f $rlRun_LOG
+
+
+ rlLog "Check for bz#1086572, bz1271326"
+ rlRun "setfiles spec_file /tmp/dir_not_exist" 1-255
+
+
+ rlIsRHEL '<7' && {
+ rlLog "Check for bz#1098062"
+ rlRun -s "setfiles -q -d spec_file /tmp" 1-255
+ rlAssertGrep "mutually exclusive" $rlRun_LOG
+ rm -f $rlRun_LOG
+ }
+ rlPhaseEnd
+
+ rlPhaseStartTest "setfiles should not abort when it can't label a file - bz#1794518"
+ USER=$(mktemp -u userXXXX)
+ USERTMP=$(mktemp -d)
+ rlRun "useradd ${USER}"
+ 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
+chown -R ${USER} ${USERTMP}
+chown root: ${USERTMP}/1/2
+chattr +i ${USERTMP}/3/4/i
+" 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 "rm -rf ${USERTMP}"
+ rlPhaseEnd
+ rlPhaseStartCleanup
+ rlRun "popd"
+ 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-11 13:18 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:18 [tests/selinux] pr775-checkpolicy-revdeps: policycoreutils/setfiles: Basic sanity test for setfiles Petr Lautrbach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox