public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: add basic test which covers systemd-mountfsd
@ 2026-09-11 13:22 Milos Malik
  0 siblings, 0 replies; only message in thread
From: Milos Malik @ 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 : 3184400050b9ea3730c51b025da0050126290800
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2024-10-07T09:06:40+00:00
            Stats  : +212/-0 in 4 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/3184400050b9ea3730c51b025da0050126290800?branch=pr775-checkpolicy-revdeps

            Log:
            add basic test which covers systemd-mountfsd

Recently, the systemd-mountfsd program/service got confined by SELinux.
Purpose of this automated test is to cover the basic scenarios in
which the daemon is used. The systemd-mountfsd man page was used as
the source of test scenarios/ideas.

---
diff --git a/selinux-policy/systemd-mountfsd-and-similar/Makefile b/selinux-policy/systemd-mountfsd-and-similar/Makefile
new file mode 100644
index 0000000..5e6e54e
--- /dev/null
+++ b/selinux-policy/systemd-mountfsd-and-similar/Makefile
@@ -0,0 +1,67 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Makefile of /CoreOS/selinux-policy/Regression/systemd-mountfsd-and-similar
+#   Description: SELinux interferes with systemd-mountfsd and related programs
+#   Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2024 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/systemd-mountfsd-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 systemd-mountfsd and related programs" >> $(METADATA)
+	@echo "Type:            Regression" >> $(METADATA)
+	@echo "TestTime:        10m" >> $(METADATA)
+	@echo "RunFor:          selinux-policy" >> $(METADATA)
+	@echo "Requires:        audit libselinux libselinux-utils policycoreutils selinux-policy selinux-policy-targeted setools-console systemd systemd-container /usr/sbin/service nmap-ncat" >> $(METADATA)
+	@echo "RhtsRequires:    library(selinux-policy/common)" >> $(METADATA)
+	@echo "Environment:     AVC_ERROR=+no_avc_check" >> $(METADATA)
+	@echo "Priority:        Normal" >> $(METADATA)
+	@echo "License:         GPLv2" >> $(METADATA)
+	@echo "Confidential:    no" >> $(METADATA)
+	@echo "Destructive:     no" >> $(METADATA)
+	@echo "Releases:        -RHEL4 -RHEL5 -RHEL6 -RHEL7 -RHEL8 -RHEL9 -RHEL10" >> $(METADATA)
+
+	rhts-lint $(METADATA)
+

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

diff --git a/selinux-policy/systemd-mountfsd-and-similar/main.fmf b/selinux-policy/systemd-mountfsd-and-similar/main.fmf
new file mode 100644
index 0000000..9d36ae7
--- /dev/null
+++ b/selinux-policy/systemd-mountfsd-and-similar/main.fmf
@@ -0,0 +1,43 @@
+summary: SELinux interferes with systemd-mountfsd and related programs
+description: |+
+    SELinux interferes with systemd-mountfsd and related programs.
+
+contact: Milos Malik <mmalik@redhat.com>
+component:
+  - selinux-policy
+require:
+  - library(selinux-policy/common)
+recommend:
+  - audit
+  - libselinux
+  - libselinux-utils
+  - policycoreutils
+  - selinux-policy
+  - selinux-policy-targeted
+  - setools-console
+  - systemd
+  - systemd-container
+  - /usr/sbin/service
+  - nmap-ncat
+environment:
+    AVC_ERROR: +no_avc_check
+duration: 10m
+enabled: true
+tag:
+  - NoRHEL4
+  - NoRHEL5
+  - NoRHEL6
+  - NoRHEL7
+  - NoRHEL8
+  - NoRHEL9
+  - targeted
+  - NoRHIVOS
+adjust:
+  - enabled: false
+    when: distro <= fedora-40
+    continue: false
+  - enabled: false
+    when: distro == rhel-4, rhel-5, rhel-6, rhel-7, rhel-8, centos-stream-8, rhel-9, centos-stream-9, rhel-10, centos-stream-10
+    continue: false
+extra-summary: /CoreOS/selinux-policy/Regression/systemd-mountfsd-and-similar
+extra-task: /CoreOS/selinux-policy/Regression/systemd-mountfsd-and-similar

diff --git a/selinux-policy/systemd-mountfsd-and-similar/runtest.sh b/selinux-policy/systemd-mountfsd-and-similar/runtest.sh
new file mode 100755
index 0000000..ddd5aae
--- /dev/null
+++ b/selinux-policy/systemd-mountfsd-and-similar/runtest.sh
@@ -0,0 +1,97 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/selinux-policy/Regression/systemd-mountfsd-and-similar
+#   Description: SELinux interferes with systemd-mountfsd and related programs
+#   Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2024 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 Beaker environment
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="selinux-policy"
+FILE_PATH="/usr/lib/systemd/systemd-mountfsd"
+SERVICE_PACKAGE="systemd"
+SERVICE_NAME="systemd-mountfsd"
+PROCESS_NAME="systemd-mountfsd"
+PROCESS_CONTEXT="systemd_mountfsd_t"
+FILE_CONTEXT="systemd_mountfsd_exec_t"
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlRun "rlImport 'selinux-policy/common'"
+        rlSESatisfyRequires
+        rlAssertRpm ${PACKAGE}
+        rlAssertRpm ${PACKAGE}-targeted
+        rlAssertRpm ${SERVICE_PACKAGE}
+
+        rlServiceStop ${SERVICE_NAME}
+        rlFileBackup /etc/shadow
+
+        rlSESetEnforce
+        rlSEStatus
+        rlSESetTimestamp
+        sleep 2
+    rlPhaseEnd
+
+    if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.service ] ; then
+    rlPhaseStartTest "real scenario -- standalone service"
+        if ! rlSEDefined ${PROCESS_CONTEXT} ; then
+            # for OSes where the SELinux domain does not exist yet
+            PROCESS_CONTEXT="unconfined_service_t"
+        fi
+        rlSEService - ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "start status" 1
+        rlRun "restorecon -Rv /etc /var /run -e /var/ARTIFACTS" 0-255
+        rlSEService - ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "restart status stop status" 1
+    rlPhaseEnd
+    fi
+
+    if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.socket ] ; then
+    rlPhaseStartTest "real scenario -- socket activation"
+        rlRun "systemctl enable ${SERVICE_NAME}.socket"
+        rlRun "systemctl start ${SERVICE_NAME}.socket"
+        ( tail -f - | ncat -U /run/systemd/io.systemd.MountFileSystem ) &
+        PROVOCATEUR_PID=$!
+        sleep 1
+        rlRun "ps -o pid,user,context,args -C ${PROCESS_NAME}"
+        rlRun "ps -o pid,user,context,args -C ${PROCESS_NAME} | grep :${PROCESS_CONTEXT}"
+        rlRun "kill -9 ${PROVOCATEUR_PID}"
+        rlRun "killall ncat" 0,1
+        if pgrep ncat >& /dev/null ; then
+            rlRun "killall ncat" 0-255
+        fi
+        rlRun "systemctl stop ${SERVICE_NAME}.socket"
+        rlRun "systemctl disable ${SERVICE_NAME}.socket"
+    rlPhaseEnd
+    fi
+
+    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: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: add basic test which covers systemd-mountfsd Milos Malik

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