diff --git a/selinux-policy/systemd-localed/Makefile b/selinux-policy/systemd-localed/Makefile new file mode 100644 index 0000000..8727c1e --- /dev/null +++ b/selinux-policy/systemd-localed/Makefile @@ -0,0 +1,71 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/selinux-policy/Regression/systemd-localed +# Description: SELinux interferes with systemd-localed and localectl +# Author: Milos Malik +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2023 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-localed +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + test -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 " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: SELinux interferes with systemd-localed and localectl" >> $(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 /usr/sbin/service systemd" >> $(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 -RHEL5 -RHEL6 -RHEL7" >> $(METADATA) + @echo "Bug: 2240159" >> $(METADATA) # Fedora 38 + @echo "Bug: RHEL-16715" >> $(METADATA) # RHEL-8 + @echo "Bug: RHEL-16716" >> $(METADATA) # RHEL-9 + + rhts-lint $(METADATA) + diff --git a/selinux-policy/systemd-localed/main.fmf b/selinux-policy/systemd-localed/main.fmf index 151a009..02d31cc 100644 --- a/selinux-policy/systemd-localed/main.fmf +++ b/selinux-policy/systemd-localed/main.fmf @@ -1,5 +1,5 @@ summary: SELinux interferes with systemd-localed and localectl -test: ./test.sh +test: ./runtest.sh framework: beakerlib contact: Milos Malik component: @@ -28,6 +28,8 @@ tag: - targeted link: - verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2240159 + - verifies: https://issues.redhat.com/browse/RHEL-16715 + - verifies: https://issues.redhat.com/browse/RHEL-16716 adjust: - enabled: false when: distro == rhel-4, rhel-5, rhel-6, rhel-7 diff --git a/selinux-policy/systemd-localed/runtest.sh b/selinux-policy/systemd-localed/runtest.sh new file mode 100755 index 0000000..e104b55 --- /dev/null +++ b/selinux-policy/systemd-localed/runtest.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="selinux-policy" +SERVICE_PACKAGE="systemd" + +rlJournalStart + rlPhaseStartSetup + rlRun "rlImport 'selinux-policy/common'" + rlAssertRpm ${PACKAGE} + rlAssertRpm ${PACKAGE}-targeted + rlAssertRpm ${SERVICE_PACKAGE} + + rlServiceStop systemd-localed + rlFileBackup --clean --missing-ok /etc/X11/xorg.conf.d + + rlSESetEnforce + rlSEStatus + rlSESetTimestamp + sleep 2 + rlPhaseEnd + + rlPhaseStartTest "bz#2240159 + RHEL-16715 + RHEL-16716" + rlSEMatchPathCon "/usr/lib/systemd/systemd-localed" "systemd_localed_exec_t" + rlSEMatchPathCon "/etc/X11/xorg.conf.d" "xserver_etc_t" + rlSESearchRule "allow systemd_localed_t xserver_etc_t : dir { create } [ ]" + rlPhaseEnd + + rlPhaseStartTest "real scenario -- bz#2240159" + if [ -d /etc/X11/xorg.conf.d ] ; then + rlRun "rpm -qf /etc/X11/xorg.conf.d" 0,1 + rlRun "rm -rf /etc/X11/xorg.conf.d" + fi + rlRun "service systemd-localed start" + rlRun "service systemd-localed status" + rlRun "localectl set-x11-keymap us" + rlRun "ls -lZ /etc/X11/xorg.conf.d" + rlRun "service systemd-localed stop" + rlRun "service systemd-localed status" 3 + rlPhaseEnd + + rlPhaseStartCleanup + sleep 2 + rlSECheckAVC + + rlFileRestore + rlServiceRestore systemd-localed + rlPhaseEnd +rlJournalEnd + diff --git a/selinux-policy/systemd-localed/test.sh b/selinux-policy/systemd-localed/test.sh deleted file mode 100755 index 84ba7d2..0000000 --- a/selinux-policy/systemd-localed/test.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -PACKAGE="selinux-policy" -SERVICE_PACKAGE="systemd" - -rlJournalStart - rlPhaseStartSetup - rlRun "rlImport 'selinux-policy/common'" - rlAssertRpm ${PACKAGE} - rlAssertRpm ${PACKAGE}-targeted - rlAssertRpm ${SERVICE_PACKAGE} - - rlServiceStop systemd-localed - rlFileBackup --clean --missing-ok /etc/X11/xorg.conf.d - - rlSESetEnforce - rlSEStatus - rlSESetTimestamp - sleep 2 - rlPhaseEnd - - rlPhaseStartTest "bz#2240159" - rlSEMatchPathCon "/usr/lib/systemd/systemd-localed" "systemd_localed_exec_t" - rlSEMatchPathCon "/etc/X11/xorg.conf.d" "xserver_etc_t" - rlSESearchRule "allow systemd_localed_t xserver_etc_t : dir { create } [ ]" - rlPhaseEnd - - rlPhaseStartTest "real scenario -- bz#2240159" - if [ -d /etc/X11/xorg.conf.d ] ; then - rlRun "rpm -qf /etc/X11/xorg.conf.d" 0,1 - rlRun "rm -rf /etc/X11/xorg.conf.d" - fi - rlRun "service systemd-localed start" - rlRun "service systemd-localed status" - rlRun "localectl set-x11-keymap us" - rlRun "ls -lZ /etc/X11/xorg.conf.d" - rlRun "service systemd-localed stop" - rlRun "service systemd-localed status" 3 - rlPhaseEnd - - rlPhaseStartCleanup - sleep 2 - rlSECheckAVC - - rlFileRestore - rlServiceRestore systemd-localed - rlPhaseEnd -rlJournalEnd -