public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Richard Filo <rfilo@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: selinux-policy: Checks if dbus daemon is able to send message to hal daemon and vice versa
Date: Fri, 11 Sep 2026 13:18:25 GMT	[thread overview]
Message-ID: <178913270563.1.11501470640401244960.tests-selinux-9b92d7be6d9c@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 9b92d7be6d9c06944b7948c2409cec0d93351e0e
            Author : Richard Filo <rfilo@redhat.com>
            Date   : 2020-11-09T09:04:15+00:00
            Stats  : +268/-0 in 5 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/9b92d7be6d9c06944b7948c2409cec0d93351e0e?branch=pr775-checkpolicy-revdeps

            Log:
            selinux-policy: Checks if dbus daemon is able to send message to hal daemon and vice versa

Original author: Milos Malik <mmalik@redhat.com>

---
diff --git a/selinux-policy/bz481628-send-msg-to-dbus/Makefile b/selinux-policy/bz481628-send-msg-to-dbus/Makefile
new file mode 100644
index 0000000..06e84fa
--- /dev/null
+++ b/selinux-policy/bz481628-send-msg-to-dbus/Makefile
@@ -0,0 +1,74 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Makefile of /CoreOS/selinux-policy/Regression/bz481628-send-msg-to-dbus
+#   Description: checks if dbus daemon is able to send message to hal daemon and vice versa
+#   Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2009 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/bz481628-send-msg-to-dbus
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE ssh.exp
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+	./runtest.sh
+
+build: $(BUILT_FILES)
+	chmod a+x ./runtest.sh ./ssh.exp
+
+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:     checks if dbus daemon is able to send message to hal daemon and vice versa" >> $(METADATA)
+	@echo "Type:            Regression" >> $(METADATA)
+	@echo "TestTime:        10m" >> $(METADATA)
+	@echo "RunFor:          selinux-policy" >> $(METADATA)
+	@echo "RunFor:          dbus" >> $(METADATA)
+	@echo "Requires:        audit libselinux libselinux-utils policycoreutils selinux-policy selinux-policy-targeted setools setools-console expect openssh-clients dbus-daemon shadow-utils" >> $(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 "Bug:             463267" >> $(METADATA) # RHEL-5
+	@echo "Bug:             481628" >> $(METADATA) # RHEL-5
+	@echo "Bug:             1546721" >> $(METADATA) # RHEL-7
+	@echo "Bug:             1614236" >> $(METADATA) # RHEL-7
+	@echo "Bug:             1688671" >> $(METADATA) # RHEL-8
+	@echo "Bug:             1727887" >> $(METADATA) # RHEL-8
+	@echo "Bug:             1754476" >> $(METADATA) # RHEL-8
+
+	rhts-lint $(METADATA)
+

diff --git a/selinux-policy/bz481628-send-msg-to-dbus/PURPOSE b/selinux-policy/bz481628-send-msg-to-dbus/PURPOSE
new file mode 100644
index 0000000..8829df6
--- /dev/null
+++ b/selinux-policy/bz481628-send-msg-to-dbus/PURPOSE
@@ -0,0 +1,5 @@
+PURPOSE of /CoreOS/selinux-policy/Regression/bz481628-send-msg-to-dbus
+Author: Milos Malik <mmalik@redhat.com>
+
+SELinux interferes with D-bus daemon and related programs.
+

diff --git a/selinux-policy/bz481628-send-msg-to-dbus/main.fmf b/selinux-policy/bz481628-send-msg-to-dbus/main.fmf
new file mode 100644
index 0000000..8763a30
--- /dev/null
+++ b/selinux-policy/bz481628-send-msg-to-dbus/main.fmf
@@ -0,0 +1,2 @@
+path: /selinux-policy/bz481628-send-msg-to-dbus
+tier: 2

diff --git a/selinux-policy/bz481628-send-msg-to-dbus/runtest.sh b/selinux-policy/bz481628-send-msg-to-dbus/runtest.sh
new file mode 100755
index 0000000..97c4f41
--- /dev/null
+++ b/selinux-policy/bz481628-send-msg-to-dbus/runtest.sh
@@ -0,0 +1,167 @@
+#!/bin/bash
+# vim: set dictionary=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k:
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/selinux-policy/Regression/bz481628-send-msg-to-dbus
+#   Description: checks if dbus daemon is able to send message to hal daemon and vice versa
+#   Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2009 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"
+FILE_PATH="/bin/dbus-daemon"
+FILE_CONTEXT="dbusd_exec_t"
+SERVICE_PACKAGE="dbus"
+if [ -f /usr/lib/systemd/system/dbus-broker.service ] ; then
+    PROCESS_NAME="dbus-broker"
+    SERVICE_NAME="dbus-broker"
+else
+    PROCESS_NAME="dbus-daemon"
+    SERVICE_NAME="dbus"
+fi
+PROCESS_CONTEXT="system_dbusd_t"
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlRun "rlImport 'selinux-policy/common'"
+        rlSESatisfyRequires
+        rlAssertRpm ${PACKAGE}
+        rlAssertRpm ${PACKAGE}-targeted
+        rlAssertRpm ${SERVICE_PACKAGE}
+
+        rlSESetEnforce
+        rlSEStatus
+        rlSESetTimestamp
+        sleep 2
+    rlPhaseEnd
+
+    rlPhaseStartTest "bz#463267"
+        if rlIsRHEL 5 ; then
+            rlSEMatchPathCon "/lib/dbus-1/dbus-daemon-launch-helper" "system_dbusd_exec_t"
+            rlSEMatchPathCon "/lib64/dbus-1/dbus-daemon-launch-helper" "system_dbusd_exec_t"
+            rlSESearchRule "allow system_dbusd_t system_dbusd_exec_t : file { execute_no_trans }"
+        else
+            rlSEMatchPathCon "/lib/dbus-1/dbus-daemon-launch-helper" "dbusd_exec_t"
+            rlSEMatchPathCon "/lib64/dbus-1/dbus-daemon-launch-helper" "dbusd_exec_t"
+            rlSESearchRule "allow system_dbusd_t dbusd_exec_t : file { execute_no_trans }"
+        fi
+    rlPhaseEnd
+
+    if rlSEDefined "hald_t" ; then
+    rlPhaseStartTest "bz#481628"
+        if rlIsRHEL 5 ; then
+            rlSEMatchPathCon "/bin/dbus-daemon" "system_dbusd_exec_t"
+        else
+            rlSEMatchPathCon "/bin/dbus-daemon" "dbusd_exec_t"
+        fi
+        rlSESearchRule "allow system_dbusd_t hald_t : dbus { send_msg }"
+        rlSESearchRule "allow hald_t system_dbusd_t : dbus { send_msg }"
+        rlSESearchRule "allow system_dbusd_t unconfined_t : dbus { send_msg }"
+        rlSESearchRule "allow unconfined_t system_dbusd_t : dbus { send_msg }"
+        if rlIsRHEL 5 ; then
+            rlSESearchRule "allow initrc_t system_dbusd_exec_t : file { getattr open read execute }"
+            rlSESearchRule "type_transition initrc_t system_dbusd_exec_t : process system_dbusd_t"
+        else
+            rlSESearchRule "allow initrc_t dbusd_exec_t : file { getattr open read execute }"
+            rlSESearchRule "type_transition initrc_t dbusd_exec_t : process system_dbusd_t"
+        fi
+        rlSESearchRule "allow initrc_t system_dbusd_t : process { transition }"
+    rlPhaseEnd
+    fi
+
+    if ! rlIsRHEL 5 6 ; then
+    rlPhaseStartTest "bz#1546721"
+        rlSEMatchPathCon "/usr/libexec/dbus-1/dbus-daemon-launch-helper" "dbusd_exec_t"
+    rlPhaseEnd
+
+    rlPhaseStartTest "bz#1614236"
+        rlSEMatchPathCon "/usr/bin/dbus-daemon" "dbusd_exec_t"
+        rlSEMatchPathCon "/dev/nvme0n1p1" "nvme_device_t"
+        rlSESearchRule "allow system_dbusd_t nvme_device_t : blk_file { getattr open read }"
+    rlPhaseEnd
+    fi
+
+    rlPhaseStartTest "real scenario -- standalone service"
+        rlSEService "nopassword" ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "reload status" 1
+    rlPhaseEnd
+
+    if ! rlIsRHEL 5 6 7 ; then
+    rlPhaseStartTest "bz#1688671"
+        rlSEMatchPathCon "/run/user/1000" "user_tmp_t"
+        if [ -f /usr/lib/systemd/system/dbus-broker.service ] ; then
+                rlSEMatchPathCon "/run/user/1000/dbus" "session_dbusd_tmp_t"
+                rlSEMatchPathCon "/run/user/1000/dbus/services" "session_dbusd_tmp_t"
+	else
+                rlSEMatchPathCon "/run/user/1000/dbus-1" "session_dbusd_tmp_t"
+                rlSEMatchPathCon "/run/user/1000/dbus-1/services" "session_dbusd_tmp_t"
+        fi
+        rlSESearchRule "allow init_t session_dbusd_tmp_t : dir { read } [ ]"
+        rlSESearchRule "type_transition staff_dbusd_t user_tmp_t : dir session_dbusd_tmp_t"
+        rlSESearchRule "type_transition sysadm_dbusd_t user_tmp_t : dir session_dbusd_tmp_t"
+        rlSESearchRule "type_transition unconfined_dbusd_t user_tmp_t : dir session_dbusd_tmp_t"
+        rlSESearchRule "type_transition user_dbusd_t user_tmp_t : dir session_dbusd_tmp_t"
+        rlSESearchRule "type_transition xguest_dbusd_t user_tmp_t : dir session_dbusd_tmp_t"
+    rlPhaseEnd
+
+    rlPhaseStartTest "bz#1727887 + bz#1754476"
+        rlSESearchRule "allow guest_t init_t : process { signal } [ ]"
+    rlPhaseEnd
+
+    rlPhaseStartTest "real scenario -- user session service"
+        rlRun "setsebool ssh_sysadm_login on"
+        rlRun "setsebool selinuxuser_tcp_server on"
+        # TODO: guest_u, xguest_u cannot successfully run systemctl
+        for SELINUX_USER in user_u staff_u sysadm_u unconfined_u ; do
+            USER_NAME="user${RANDOM}"
+            USER_SECRET="S3kr3t${RANDOM}"
+            rlRun "useradd -Z ${SELINUX_USER} ${USER_NAME}"
+            rlRun "echo ${USER_SECRET} | passwd --stdin ${USER_NAME}"
+            rlRun "restorecon -RvF /home/${USER_NAME}"
+            rlRun "./ssh.exp ${USER_NAME} ${USER_SECRET} localhost /usr/bin/systemctl --user --no-pager status dbus"
+            rlRun "rm -f files.txt"
+            USER_ID=`id -u ${USER_NAME}`
+            ( sleep 3 ; ls -RZ /run/user/${USER_ID} > files.txt ) &
+            rlRun "./ssh.exp ${USER_NAME} ${USER_SECRET} localhost /usr/bin/systemctl --user --no-pager start dbus"
+            if ! [ -f /usr/lib/systemd/system/dbus-broker.service ] ; then
+                rlRun "grep \"${SELINUX_USER}:object_r:session_dbusd_tmp_t:.* dbus-1\" files.txt"
+                rlRun "grep \"${SELINUX_USER}:object_r:session_dbusd_tmp_t:.* services\" files.txt"
+            fi
+            rlRun "./ssh.exp ${USER_NAME} ${USER_SECRET} localhost /usr/bin/busctl --user --no-pager"
+            rlRun "userdel -rfZ ${USER_NAME}"
+            sleep 10
+        done
+        rlRun "setsebool selinuxuser_tcp_server off"
+        rlRun "setsebool ssh_sysadm_login off"
+    rlPhaseEnd
+    fi
+
+    rlPhaseStartCleanup
+        sleep 2
+        rlSECheckAVC
+        rm -f files.txt
+    rlPhaseEnd
+    rlJournalPrintText
+rlJournalEnd
+

diff --git a/selinux-policy/bz481628-send-msg-to-dbus/ssh.exp b/selinux-policy/bz481628-send-msg-to-dbus/ssh.exp
new file mode 100755
index 0000000..1244013
--- /dev/null
+++ b/selinux-policy/bz481628-send-msg-to-dbus/ssh.exp
@@ -0,0 +1,20 @@
+#!/usr/bin/expect -f
+# Expect script for SSH logging as $username to $hostname using $password and executing $command.
+# Usage:
+#   ./ssh.exp username password hostname command
+set username [lrange $argv 0 0]
+set password [lrange $argv 1 1]
+set hostname [lrange $argv 2 2]
+set command  [lrange $argv 3 10]
+set timeout 15
+# connect to remote host and execute given command
+log_user 1
+spawn ssh -t $username@$hostname "$command ; sleep 5"
+expect {
+  -nocase "yes/no" { send -- "yes\r" ; exp_continue }
+  -nocase "password" { send -- "$password\r" }
+}
+log_user 1
+# send -- "\r"
+expect eof
+

                 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=178913270563.1.11501470640401244960.tests-selinux-9b92d7be6d9c@fedoraproject.org \
    --to=rfilo@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