public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: add the pcscd test to upstream repo
@ 2026-09-11 13:19 Milos Malik
  0 siblings, 0 replies; only message in thread
From: Milos Malik @ 2026-09-11 13:19 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 600c907d1e33b3b987a63d34d698f41fa8354625
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2021-05-20T10:19:12+00:00
            Stats  : +218/-0 in 4 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/600c907d1e33b3b987a63d34d698f41fa8354625?branch=pr775-checkpolicy-revdeps

            Log:
            add the pcscd test to upstream repo

The pcsc-lite package is available in various versions of RHEL
and Fedora. The pcscd service is also used in these environments,
so it makes sense to run this TC in upstream testing too.
Moving the downstream TC to upstream repository.
There are only slight changes when comparing the upstream and
downstream version of this TC.

---
diff --git a/selinux-policy/bz624405-pcsc-and-similar/Makefile b/selinux-policy/bz624405-pcsc-and-similar/Makefile
new file mode 100644
index 0000000..d0e27fd
--- /dev/null
+++ b/selinux-policy/bz624405-pcsc-and-similar/Makefile
@@ -0,0 +1,92 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Makefile of /CoreOS/selinux-policy/Regression/bz624405-pcsc-and-similar
+#   Description: SELinux interferes with pcscd
+#   Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2021 Red Hat, Inc. All rights reserved.
+#
+#   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/selinux-policy/Regression/bz624405-pcsc-and-similar
+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)
+	chmod a+x runtest.sh
+	chcon -t bin_t runtest.sh
+
+clean:
+	rm -f *~ $(BUILT_FILES)
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+	@echo "Owner:           Milos Malik <mmalik@redhat.com>" > $(METADATA)
+	@echo "Name:            $(TEST)" >> $(METADATA)
+	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)
+	@echo "Path:            $(TEST_DIR)" >> $(METADATA)
+	@echo "Description:     SELinux interferes with pcscd" >> $(METADATA)
+	@echo "Type:            Regression" >> $(METADATA)
+	@echo "TestTime:        15m" >> $(METADATA)
+	@echo "RunFor:          selinux-policy" >> $(METADATA)
+	@echo "RunFor:          pcsc-lite" >> $(METADATA)
+	@echo "Requires:        audit" >> $(METADATA)
+	@echo "Requires:        expect" >> $(METADATA)
+	@echo "Requires:        grep" >> $(METADATA)
+	@echo "Requires:        initscripts" >> $(METADATA)
+	@echo "Requires:        libselinux" >> $(METADATA)
+	@echo "Requires:        libselinux-utils" >> $(METADATA)
+	@echo "Requires:        pcsc-lite" >> $(METADATA)
+	@echo "Requires:        policycoreutils" >> $(METADATA)
+	@echo "Requires:        procps" >> $(METADATA)
+	@echo "Requires:        selinux-policy" >> $(METADATA)
+	@echo "Requires:        selinux-policy-mls" >> $(METADATA)
+	@echo "Requires:        selinux-policy-targeted" >> $(METADATA)
+	@echo "Requires:        setools" >> $(METADATA)
+	@echo "Requires:        setools-console" >> $(METADATA)
+	@echo "RhtsRequires:    library(selinux-policy/common)" >> $(METADATA)
+	@echo "Priority:        Normal" >> $(METADATA)
+	@echo "License:         GPLv2" >> $(METADATA)
+	@echo "Confidential:    no" >> $(METADATA)
+	@echo "Destructive:     no" >> $(METADATA)
+	@echo "Environment:     AVC_ERROR=+no_avc_check" >> $(METADATA)
+	@echo "Releases:        -RHEL4" >> $(METADATA)
+	@echo "Architectures:   i386 ia64 ppc ppc64 x86_64" >> $(METADATA)
+	@echo "Bug:             624405" >> $(METADATA) # RHEL-6
+	@echo "Bug:             752453" >> $(METADATA) # RHEL-6
+	@echo "Bug:             1605641" >> $(METADATA) # RHEL-7
+	@echo "Bug:             1802423" >> $(METADATA) # Fedora 32
+	@echo "Bug:             1805719" >> $(METADATA) # Fedora 32
+	@echo "Bug:             1806129" >> $(METADATA) # Fedora 32
+	@echo "Bug:             1816787" >> $(METADATA) # Fedora 32
+	@echo "Bug:             1818759" >> $(METADATA) # Fedora 32
+	@echo "Bug:             1825182" >> $(METADATA) # Fedora 32
+	@echo "Bug:             1825188" >> $(METADATA) # Fedora 32
+
+	rhts-lint $(METADATA)
+

diff --git a/selinux-policy/bz624405-pcsc-and-similar/PURPOSE b/selinux-policy/bz624405-pcsc-and-similar/PURPOSE
new file mode 100644
index 0000000..c9c36f2
--- /dev/null
+++ b/selinux-policy/bz624405-pcsc-and-similar/PURPOSE
@@ -0,0 +1,5 @@
+PURPOSE of /CoreOS/selinux-policy/Regression/bz624405-pcsc-and-similar
+Author: Milos Malik <mmalik@redhat.com>
+
+SELinux interferes with pcscd and related programs.
+

diff --git a/selinux-policy/bz624405-pcsc-and-similar/main.fmf b/selinux-policy/bz624405-pcsc-and-similar/main.fmf
new file mode 100644
index 0000000..798179e
--- /dev/null
+++ b/selinux-policy/bz624405-pcsc-and-similar/main.fmf
@@ -0,0 +1,3 @@
+path: /selinux-policy/bz624405-pcsc-and-similar
+tier: 2
+

diff --git a/selinux-policy/bz624405-pcsc-and-similar/runtest.sh b/selinux-policy/bz624405-pcsc-and-similar/runtest.sh
new file mode 100755
index 0000000..5123da8
--- /dev/null
+++ b/selinux-policy/bz624405-pcsc-and-similar/runtest.sh
@@ -0,0 +1,118 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/selinux-policy/Regression/bz624405-pcsc-and-similar
+#   Description: SELinux interferes with pcscd
+#   Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2021 Red Hat, Inc. All rights reserved.
+#
+#   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 rhts environment
+. /usr/bin/rhts-environment.sh
+. /usr/share/beakerlib/beakerlib.sh
+
+PACKAGE="selinux-policy"
+ROOT_PASSWORD="redhat"
+SERVICE_NAME="pcscd"
+PROCESS_CONTEXT="pcscd_t"
+PROCESS_NAME="pcscd"
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlRun "rlImport 'selinux-policy/common'"
+        rlSESatisfyRequires
+        rlAssertRpm ${PACKAGE}
+        rlAssertRpm ${PACKAGE}-mls
+        rlAssertRpm ${PACKAGE}-targeted
+        rlAssertRpm pcsc-lite
+
+        rlServiceStop ${SERVICE_NAME}
+        rlFileBackup /etc/shadow
+
+        rlSESetEnforce
+        rlSEStatus
+        rlSESetTimestamp
+        sleep 2
+    rlPhaseEnd
+
+    rlPhaseStartTest "bz#624405"
+        rlSEMatchPathCon "/usr/sbin/pcscd" "pcscd_exec_t"
+        if rlIsRHEL 5 ; then
+            rlRun "ls -dZ /sys | grep :sysfs_t"
+            rlRun "ls -dZ /sys/devices | grep :sysfs_t"
+            rlSESearchRule "allow pcscd_t sysfs_t : dir { getattr search }"
+        else
+            rlSEMatchPathCon "/sys" "sysfs_t"
+            rlSEMatchPathCon "/sys/devices" "sysfs_t"
+            rlSESearchRule "allow pcscd_t sysfs_t : dir { getattr open read search }"
+            rlSESearchRule "allow pcscd_t sysfs_t : file { getattr open read }"
+        fi
+    rlPhaseEnd
+
+    rlPhaseStartTest "bz#752453"
+        rlSEMatchPathCon "/usr/sbin/pcscd" "pcscd_exec_t"
+        rlSESearchRule "allow pcscd_t usb_device_t : chr_file { getattr read write }"
+    rlPhaseEnd
+
+    if ! rlIsRHEL 5 6 7 ; then
+    rlPhaseStartTest "bz#1605641"
+        rlSEMatchPathCon "/usr/sbin/pcscd" "pcscd_exec_t"
+        rlSESearchRule "dontaudit pcscd_t pcscd_t : capability { sys_admin }"
+    rlPhaseEnd
+    fi
+
+    if rlIsFedora ; then
+    rlPhaseStartTest "bz#1806129 + bz#1816787 + bz#1818759 + bz#1825182 + bz#1825188"
+        rlSEMatchPathCon "/usr/sbin/pcscd" "pcscd_exec_t"
+        rlSESearchRule "dontaudit pcscd_t pcscd_t : capability { sys_nice } [ daemons_dontaudit_scheduling ]"
+    rlPhaseEnd
+
+    rlPhaseStartTest "bz#1802423 + bz#1805719"
+        rlSEMatchPathCon "/usr/sbin/pcscd" "pcscd_exec_t"
+        rlSESearchRule "dontaudit pcscd_t pcscd_t : process { setsched } [ ]"
+    rlPhaseEnd
+    fi
+
+    rlPhaseStartTest "real scenario -- bz#624405"
+        rlRun "echo ${ROOT_PASSWORD} | passwd --stdin root"
+        if ! rlSEDefined ${PROCESS_CONTEXT} ; then
+            if rlIsRHEL 5 6 ; then
+                PROCESS_CONTEXT="initrc_t"
+            else
+                PROCESS_CONTEXT="unconfined_service_t"
+            fi
+        fi
+        rlSEService ${ROOT_PASSWORD} ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "start status" 1
+        rlRun "restorecon -Rv /run /var" 0-255
+        rlSEService ${ROOT_PASSWORD} ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "restart status stop status" 1
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        sleep 2
+        rlSECheckAVC
+
+        rlFileRestore
+        rlServiceRestore ${SERVICE_NAME}
+    rlPhaseEnd
+    rlJournalPrintText
+rlJournalEnd
+

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

only message in thread, other threads:[~2026-09-11 13:19 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:19 [tests/selinux] pr775-checkpolicy-revdeps: add the pcscd test to upstream repo Milos Malik

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