public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: add the systemd-userdbd test to upstream repository
@ 2026-09-11 13:18 Milos Malik
0 siblings, 0 replies; only message in thread
From: Milos Malik @ 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 : 5aa3d4cead9d74ad1f30cea3907e9d8d75bd0449
Author : Milos Malik <mmalik@redhat.com>
Date : 2020-09-10T13:11:54+00:00
Stats : +221/-0 in 5 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/5aa3d4cead9d74ad1f30cea3907e9d8d75bd0449?branch=pr775-checkpolicy-revdeps
Log:
add the systemd-userdbd test to upstream repository
The systemd-userdbd service is available in various Fedoras and
RHELs, so it's a good idea to run the TC during upstream testing.
There are no changes in the TC functionality, only moving the
downstream TC to the upstream repo.
---
diff --git a/selinux-policy/systemd-userdbd-and-similar/Makefile b/selinux-policy/systemd-userdbd-and-similar/Makefile
new file mode 100644
index 0000000..b73f589
--- /dev/null
+++ b/selinux-policy/systemd-userdbd-and-similar/Makefile
@@ -0,0 +1,69 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Makefile of /CoreOS/selinux-policy/Regression/systemd-userdbd-and-similar
+# Description: SELinux interferes with systemd-userdbd and related programs
+# Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2012 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-userdbd-and-similar
+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
+ chcon -t bin_t 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: SELinux interferes with systemd-userdbd and related programs" >> $(METADATA)
+ @echo "Type: Regression" >> $(METADATA)
+ @echo "TestTime: 10m" >> $(METADATA)
+ @echo "RunFor: selinux-policy" >> $(METADATA)
+ @echo "RunFor: systemd" >> $(METADATA)
+ @echo "Requires: audit libselinux libselinux-utils policycoreutils selinux-policy selinux-policy-targeted setools-console expect openssh-clients systemd initscripts shadow-utils" >> $(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" >> $(METADATA)
+ @echo "Bug: 1835630" >> $(METADATA) # Fedora 32
+
+ rhts-lint $(METADATA)
+
diff --git a/selinux-policy/systemd-userdbd-and-similar/PURPOSE b/selinux-policy/systemd-userdbd-and-similar/PURPOSE
new file mode 100644
index 0000000..16b9758
--- /dev/null
+++ b/selinux-policy/systemd-userdbd-and-similar/PURPOSE
@@ -0,0 +1,5 @@
+PURPOSE of /CoreOS/selinux-policy/Regression/systemd-userdbd-and-similar
+Author: Milos Malik <mmalik@redhat.com>
+
+SELinux interferes with systemd-userdbd and related programs.
+
diff --git a/selinux-policy/systemd-userdbd-and-similar/main.fmf b/selinux-policy/systemd-userdbd-and-similar/main.fmf
new file mode 100644
index 0000000..4b73bfc
--- /dev/null
+++ b/selinux-policy/systemd-userdbd-and-similar/main.fmf
@@ -0,0 +1,2 @@
+path: /selinux-policy/systemd-userdbd-and-similar
+tier: 2
diff --git a/selinux-policy/systemd-userdbd-and-similar/runtest.sh b/selinux-policy/systemd-userdbd-and-similar/runtest.sh
new file mode 100755
index 0000000..1301c95
--- /dev/null
+++ b/selinux-policy/systemd-userdbd-and-similar/runtest.sh
@@ -0,0 +1,125 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of /CoreOS/selinux-policy/Regression/systemd-userdbd-and-similar
+# Description: SELinux interferes with systemd-userdbd and related programs
+# Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2012 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/bin/rhts-environment.sh || exit 1
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="selinux-policy"
+ROOT_PASSWORD="redhat"
+FILE_PATH="/usr/lib/systemd/systemd-userdbd"
+FILE_CONTEXT="systemd_userdbd_exec_t"
+SERVICE_PACKAGE="systemd"
+SERVICE_NAME="systemd-userdbd"
+PROCESS_NAME="systemd-userdbd"
+PROCESS_CONTEXT="systemd_userdbd_t"
+ALLOWED_USERS=${ALLOWED_USERS:-"staff_u user_u guest_u xguest_u sysadm_u unconfined_u"}
+DENIED_USERS=${DENIED_USERS:-""}
+
+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 rlSEDefined ${PROCESS_CONTEXT} ; then
+ rlPhaseStartTest "SELinux contexts and rules"
+ rlSEMatchPathCon "${FILE_PATH}" "${FILE_CONTEXT}"
+ SOURCE_TYPE="init_t" # systemd runs the process
+ rlSESearchRule "allow ${SOURCE_TYPE} ${FILE_CONTEXT} : file { getattr open read execute } $BOOLEANS"
+ rlSESearchRule "allow ${SOURCE_TYPE} ${PROCESS_CONTEXT} : process { transition } $BOOLEANS"
+ rlSESearchRule "type_transition ${SOURCE_TYPE} ${FILE_CONTEXT} : process ${PROCESS_CONTEXT} $BOOLEANS"
+ rlPhaseEnd
+
+ rlPhaseStartTest "bz#1835630"
+ rlSEMatchPathCon "/run/systemd/userdb/io.systemd.Multiplexer" "systemd_userdbd_runtime_t"
+ rlSESearchRule "allow guest_t systemd_userdbd_runtime_t : sock_file { write } [ ]"
+ rlSESearchRule "allow xguest_t systemd_userdbd_runtime_t : sock_file { write } [ ]"
+ rlPhaseEnd
+ fi
+
+ rlPhaseStartTest "real scenario -- confined users"
+ rlRun "setsebool ssh_sysadm_login on"
+ rlRun "setsebool selinuxuser_tcp_server on"
+ rlLog "configuration says not to test SELinux users: ${DENIED_USERS}"
+ for SELINUX_USER in ${ALLOWED_USERS} ; 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 -Rv /home/${USER_NAME}"
+ rlRun "./ssh.exp ${USER_NAME} ${USER_SECRET} localhost userdbctl user"
+ rlRun "./ssh.exp ${USER_NAME} ${USER_SECRET} localhost userdbctl group"
+ rlRun "./ssh.exp ${USER_NAME} ${USER_SECRET} localhost userdbctl services"
+ rlRun "userdel -rfZ ${USER_NAME}"
+ sleep 10
+ done
+ rlRun "setsebool selinuxuser_tcp_server off"
+ rlRun "setsebool ssh_sysadm_login off"
+ rlPhaseEnd
+
+ rlPhaseStartTest "real scenario -- standalone service"
+ rlRun "echo ${ROOT_PASSWORD} | passwd --stdin root"
+ if ! rlSEDefined ${PROCESS_CONTEXT} ; then
+ PROCESS_CONTEXT="unconfined_service_t"
+ 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
+
+ rlPhaseStartTest "real scenario -- ${SERVICE_NAME}.socket"
+ rlRun "systemctl stop systemd-userdbd.socket"
+ rlRun "systemctl status systemd-userdbd.socket" 3
+ rlRun "systemctl start systemd-userdbd.socket"
+ rlRun "systemctl status systemd-userdbd.socket"
+ rlRun "ls -dZ /run/systemd/userdb | grep :systemd_userdbd_runtime_t"
+ rlRun "ls -Z /run/systemd/userdb/io.systemd.Multiplexer | grep :systemd_userdbd_runtime_t"
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ sleep 2
+ rlSECheckAVC
+
+ rlFileRestore
+ rlServiceRestore ${SERVICE_NAME}
+ rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
+
diff --git a/selinux-policy/systemd-userdbd-and-similar/ssh.exp b/selinux-policy/systemd-userdbd-and-similar/ssh.exp
new file mode 100755
index 0000000..58c9647
--- /dev/null
+++ b/selinux-policy/systemd-userdbd-and-similar/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
+expect {
+ -nocase "yes/no" { send -- "yes\r" ; exp_continue }
+ -nocase "password" { send -- "$password\r" }
+}
+log_user 1
+# send -- "\r"
+expect eof
+
^ 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: add the systemd-userdbd test to upstream repository Milos Malik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox