public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: test if samba-bgqd can collaborate with rpcclient
@ 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 : b64b1c6467468b40ddd182b361adf4b22fb95f11
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2024-11-13T08:06:22+00:00
            Stats  : +216/-0 in 4 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/b64b1c6467468b40ddd182b361adf4b22fb95f11?branch=pr775-checkpolicy-revdeps

            Log:
            test if samba-bgqd can collaborate with rpcclient

A recent samba + selinux-policy testing revealed that SELinux
prevents the rpcclient command from enumerating printers. The
TC reproduces the situation.

A follow-up testing revealed that the samba-bgqd service, which
plays an important role in this scenario, is not confined by
SELinux.

In order to support the expected rpcclient + samba-bgqd functionality,
I believe that SELinux policy should allow the necessary actions.
The TC looks for policy rules and file context patterns which
reflect the fact that the samba-bgqd program is now confined
by SELinux.

The TC covers RHEL-53124 and RHEL-64908.

---
diff --git a/selinux-policy/samba-bgqd-and-similar/Makefile b/selinux-policy/samba-bgqd-and-similar/Makefile
new file mode 100644
index 0000000..93dcc29
--- /dev/null
+++ b/selinux-policy/samba-bgqd-and-similar/Makefile
@@ -0,0 +1,68 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Makefile of /CoreOS/selinux-policy/Regression/samba-bgqd-and-similar
+#   Description: SELinux interferes with samba-bgqd 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/samba-bgqd-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 samba-bgqd and related programs" >> $(METADATA)
+	@echo "Type:            Regression" >> $(METADATA)
+	@echo "TestTime:        15m" >> $(METADATA)
+	@echo "RunFor:          selinux-policy" >> $(METADATA)
+	@echo "Requires:        audit libselinux libselinux-utils policycoreutils selinux-policy selinux-policy-targeted setools-console samba samba-client samba-common-tools" >> $(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 "Releases:        -RHEL4 -RHEL5 -RHEL6 -RHEL7 -RHEL8" >> $(METADATA)
+	@echo "Bug:             RHEL-53124" >> $(METADATA) # RHEL-9
+	@echo "Bug:             RHEL-64908" >> $(METADATA) # RHEL-10
+
+	rhts-lint $(METADATA)
+

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

diff --git a/selinux-policy/samba-bgqd-and-similar/main.fmf b/selinux-policy/samba-bgqd-and-similar/main.fmf
new file mode 100644
index 0000000..9ab8a49
--- /dev/null
+++ b/selinux-policy/samba-bgqd-and-similar/main.fmf
@@ -0,0 +1,39 @@
+summary: SELinux interferes with samba-bgqd and related programs
+description: |+
+    SELinux interferes with samba-bgqd 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
+  - samba
+  - samba-client
+  - samba-common-tools
+duration: 15m
+enabled: true
+tag:
+  - NoRHEL4
+  - NoRHEL5
+  - NoRHEL6
+  - NoRHEL7
+  - NoRHEL8
+  - targeted
+  - NoRHIVOS
+link:
+  - verifies: https://issues.redhat.com/browse/RHEL-53124
+  - verifies: https://issues.redhat.com/browse/RHEL-64908
+adjust:
+  - enabled: false
+    when: distro == rhel-4, rhel-5, rhel-6, rhel-7, rhel-8
+    continue: false
+extra-summary: /CoreOS/selinux-policy/Regression/samba-bgqd-and-similar
+extra-task: /CoreOS/selinux-policy/Regression/samba-bgqd-and-similar

diff --git a/selinux-policy/samba-bgqd-and-similar/runtest.sh b/selinux-policy/samba-bgqd-and-similar/runtest.sh
new file mode 100755
index 0000000..ab78817
--- /dev/null
+++ b/selinux-policy/samba-bgqd-and-similar/runtest.sh
@@ -0,0 +1,104 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/selinux-policy/Regression/samba-bgqd-and-similar
+#   Description: SELinux interferes with samba-bgqd 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"
+SERVICE_PACKAGE="samba"
+FILE_PATH="/usr/libexec/samba/samba-bgqd"
+PROCESS_NAME="samba-bgqd"
+SERVICE_NAME="samba-bgqd"
+if seinfo -t | grep -q samba_bgqd ; then
+    PROCESS_CONTEXT="samba_bgqd_t"
+    FILE_CONTEXT="samba_bgqd_exec_t"
+else
+    PROCESS_CONTEXT="unconfined_service_t"
+    FILE_CONTEXT="bin_t"
+fi
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlRun "rlImport 'selinux-policy/common'" 0,1
+        rlSESatisfyRequires
+        rlAssertRpm ${PACKAGE}
+        rlAssertRpm ${PACKAGE}-targeted
+        rlAssertRpm ${SERVICE_PACKAGE}
+
+        rlFileBackup /etc/shadow
+        rlServiceStop ${SERVICE_NAME}
+
+        rlSESetEnforce
+        rlSEStatus
+        rlSESetTimestamp
+        sleep 2
+    rlPhaseEnd
+
+    if seinfo -t | grep -q samba_bgqd ; then
+    rlPhaseStartTest "RHEL-53124 + RHEL-64908"
+        rlSEMatchPathCon ${FILE_PATH} ${FILE_CONTEXT}
+        rlSEMatchPathCon "/run/samba-bgqd.pid" "samba_bgqd_var_run_t"
+        rlSEMatchPathCon "/var/lib/sss" "sssd_var_lib_t"
+        rlSEMatchPathCon "/var/lib/sss/mc" "sssd_public_t"
+        rlSESearchRule "allow winbind_rpcd_t samba_bgqd_var_run_t : file { open write lock } [ ]"
+        rlSESearchRule "allow winbind_rpcd_t samba_bgqd_t : unix_dgram_socket { sendto } [ ]"
+        rlSESearchRule "allow winbind_rpcd_t samba_bgqd_exec_t : file { getattr open read map execute } [ ]"
+        rlSESearchRule "allow samba_bgqd_t sssd_public_t : dir { search } [ ]"
+        rlSESearchRule "allow samba_bgqd_t sssd_var_lib_t : dir { search } [ ]"
+        rlSESearchRule "allow samba_bgqd_t winbind_rpcd_t : fifo_file { write } [ ]"
+    rlPhaseEnd
+    fi
+
+    rlPhaseStartTest "real scenario"
+        USER_NAME="smbuser${RANDOM}"
+        USER_SECRET="S3kr3T${RANDOM}"
+        rlRun "useradd ${USER_NAME}"
+        rlRun "echo ${USER_SECRET} | passwd --stdin ${USER_NAME}"
+        rlRun "echo -en '${USER_SECRET}\n${USER_SECRET}\n' | smbpasswd -s -a ${USER_NAME}"
+        rlRun "systemctl start samba-bgqd"
+        rlRun "systemctl start smb"
+        rlRun "restorecon -Rv /etc /run /var -e /var/ARTIFACTS" 0-255
+        sleep 2
+        rlRun "rpcclient ncacn_np:localhost -c 'enumprinters' -U${USER_NAME}%${USER_SECRET}"
+        sleep 2
+        rlRun "systemctl stop smb"
+        rlRun "systemctl stop samba-bgqd"
+        rlRun "smbpasswd -x ${USER_NAME}"
+        rlRun "userdel -rf ${USER_NAME}"
+    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: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: test if samba-bgqd can collaborate with rpcclient Milos Malik

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