public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Milos Malik <mmalik@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] main: add a new basic test which covers the kmscon service
Date: Tue, 20 Oct 2026 10:45:23 GMT [thread overview]
Message-ID: <179249312377.1.16204908343270891584.tests-selinux-20301e571ca4@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : tests/selinux
Branch : main
Commit : 20301e571ca424e3419f139a5873abb49a04c53f
Author : Milos Malik <mmalik@redhat.com>
Date : 2026-10-20T10:45:02+00:00
Stats : +131/-0 in 2 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/20301e571ca424e3419f139a5873abb49a04c53f?branch=main
Log:
add a new basic test which covers the kmscon service
The kmscon service is confined by SELinux. Purpose of this automated
test is to check whether the service starts and runs successfully
in default configuration while SELinux policy is active.
The test looks for SELinux denials triggered by the service.
---
diff --git a/selinux-policy/kmscon-and-similar/main.fmf b/selinux-policy/kmscon-and-similar/main.fmf
new file mode 100644
index 0000000..08a9df6
--- /dev/null
+++ b/selinux-policy/kmscon-and-similar/main.fmf
@@ -0,0 +1,44 @@
+summary: SELinux interferes with kmscon and related programs
+description: |+
+ SELinux interferes with kmscon and related programs.
+
+contact: Milos Malik <mmalik@redhat.com>
+component:
+ - kmscon
+ - selinux-policy
+test: ./runtest.sh
+framework: beakerlib
+require:
+ - type: library
+ name: /selinux-policy/Library/common
+ nick: selinux-policy
+recommend:
+ - audit
+ - libselinux
+ - libselinux-utils
+ - policycoreutils
+ - selinux-policy
+ - selinux-policy-targeted
+ - setools-console
+ - kmscon
+ - /usr/sbin/service
+environment:
+ AVC_ERROR: +no_avc_check
+duration: 10m
+enabled: true
+tag:
+ - NoRHEL4
+ - NoRHEL5
+ - NoRHEL6
+ - NoRHEL7
+ - NoRHEL8
+ - NoRHEL9
+ - NoRHEL10
+ - targeted
+ - NoRHIVOS
+adjust+:
+ - enabled: false
+ when: distro == rhel-4, rhel-5, rhel-6, rhel-7, rhel-8, rhel-9, rhel-10, centos-stream-9, centos-stream-10
+ because: the kmscon package is not available there
+id: 4c5f9f5b-9adb-4c13-a354-aab45e0f18ab
+extra-nitrate: TC#0620386
diff --git a/selinux-policy/kmscon-and-similar/runtest.sh b/selinux-policy/kmscon-and-similar/runtest.sh
new file mode 100755
index 0000000..9bf249c
--- /dev/null
+++ b/selinux-policy/kmscon-and-similar/runtest.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of /CoreOS/selinux-policy/Regression/kmscon-and-similar
+# Description: SELinux interferes kmscon and related programs
+# Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2026 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, see
+# <https://www.gnu.org/licenses/>.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include Beaker environment
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="selinux-policy"
+FILE_PATH="/usr/bin/kmscon"
+SERVICE_NAME="kmscon"
+PROCESS_NAME="kmscon"
+if seinfo -t | grep -q kmscon ; then
+ FILE_CONTEXT="kmscon_exec_t"
+ PROCESS_CONTEXT="kmscon_t"
+else
+ FILE_CONTEXT="bin_t"
+ PROCESS_CONTEXT="unconfined_service_t"
+fi
+
+rlJournalStart
+ rlPhaseStartSetup
+ rlRun "rlImport 'selinux-policy/common'" 0,1
+ rlAssertRpm ${PACKAGE}
+ rlAssertRpm ${PACKAGE}-targeted
+ rlRun "rpm -qf ${FILE_PATH}"
+
+ rlServiceStop ${SERVICE_NAME}
+
+ rlSESetEnforce
+ rlSEStatus
+ rlSESetTimestamp
+ sleep 2
+ rlPhaseEnd
+
+ if grep -q 'ELN 11' /etc/fedora-release ; then
+ rlPhaseStartTest "policy rules check"
+ rlSEMatchPathCon ${FILE_PATH} ${FILE_CONTEXT}
+ rlSESearchRule "allow kmscon_t kmscon_t : capability2 { bpf } [ ]"
+ rlPhaseEnd
+ fi
+
+ if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.service ] ; then
+ rlPhaseStartTest "real scenario -- standalone service"
+ rlRun "cp -f /usr/lib/systemd/system/${SERVICE_NAME}.service /etc/systemd/system/"
+ rlRun "sed -i 's|^.*ConditionPathExists.*$||' /etc/systemd/system/${SERVICE_NAME}.service"
+ rlRun "systemctl daemon-reload"
+ rlSEService - ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "start status" 2
+ rlRun "restorecon -Rv /etc /run /var -e /var/ARTIFACTS" 0-255
+ rlSEService - ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "restart status stop status" 2
+ rlRun "rm -f /etc/systemd/system/${SERVICE_NAME}.service"
+ rlRun "systemctl daemon-reload"
+ rlPhaseEnd
+ fi
+
+ # TODO: add test phase for kmsconvt@.service
+ rlPhaseStartCleanup
+ sleep 2
+ rlSECheckAVC
+
+ rlServiceRestore ${SERVICE_NAME}
+ rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
+
reply other threads:[~2026-10-20 10:45 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=179249312377.1.16204908343270891584.tests-selinux-20301e571ca4@fedoraproject.org \
--to=mmalik@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