public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] main: add a new test which covers the tpm2-abrmd service
@ 2026-11-06 15:04 Milos Malik
0 siblings, 0 replies; only message in thread
From: Milos Malik @ 2026-11-06 15:04 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : tests/selinux
Branch : main
Commit : 8aa65248df5bc01d6d981ba1a1786ad9747fcde2
Author : Milos Malik <mmalik@redhat.com>
Date : 2026-11-06T15:03:36+00:00
Stats : +137/-0 in 2 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/8aa65248df5bc01d6d981ba1a1786ad9747fcde2?branch=main
Log:
add a new test which covers the tpm2-abrmd service
There was a file conflict between the selinux-policy-devel package
and the tpm2-abrmd-selinux package. Both packages claimed to own
the following file:
* /usr/share/selinux/devel/include/contrib/tabrmd.if
The file conflict is already resolved.
The test also covers basic operations of the tpm2-abrmd service
which is brought by the tpm2-abrmd package. The service needs a
TPM device which is provided via swtpm tools.
The TC covers RHEL-247190.
---
diff --git a/selinux-policy/tpm2-abrmd-and-similar/main.fmf b/selinux-policy/tpm2-abrmd-and-similar/main.fmf
new file mode 100644
index 0000000..35718ec
--- /dev/null
+++ b/selinux-policy/tpm2-abrmd-and-similar/main.fmf
@@ -0,0 +1,44 @@
+summary: SELinux interferes with tpm2-abrmd and related programs
+description: |+
+ SELinux interferes with tpm2-abrmd and related programs.
+
+contact: Milos Malik <mmalik@redhat.com>
+component:
+ - tpm2-abrmd
+ - 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
+ - tpm2-abrmd
+ - tpm2-tools
+ - swtpm
+ - swtpm-tools
+ - /usr/sbin/service
+environment:
+ AVC_ERROR: +no_avc_check
+duration: 10m
+enabled: true
+tag:
+ - NoRHEL4
+ - NoRHEL5
+ - NoRHEL6
+ - NoRHEL7
+ - targeted
+ - NoRHIVOS
+adjust+:
+ - enabled: false
+ when: distro == rhel-4, rhel-5, rhel-6, rhel-7
+ because: the tpm2-abrmd package is not available there
+id: 59f78c88-e4d0-434c-afeb-2b5509302136
+extra-nitrate: TC#0620398
diff --git a/selinux-policy/tpm2-abrmd-and-similar/runtest.sh b/selinux-policy/tpm2-abrmd-and-similar/runtest.sh
new file mode 100755
index 0000000..9d37ccf
--- /dev/null
+++ b/selinux-policy/tpm2-abrmd-and-similar/runtest.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of /CoreOS/selinux-policy/Regression/tpm2-abrmd-and-similar
+# Description: SELinux interferes tpm2-abrmd 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/sbin/tpm2-abrmd"
+SERVICE_NAME="tpm2-abrmd"
+PROCESS_NAME="tpm2-abrmd"
+if seinfo -t | grep -q tabrmd ; then
+ FILE_CONTEXT="tabrmd_exec_t"
+ PROCESS_CONTEXT="tabrmd_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
+
+ rlPhaseStartTest "RHEL-247190"
+ rlRun "rpm -qa | grep tpm2-abrmd-selinux"
+ rlRun "semodule -lfull | grep tabrmd"
+ rlRun "rpm -qf /usr/share/selinux/devel/include/contrib/tabrmd.if | grep tpm2-abrmd-selinux"
+ rlRun "rpm -qf /usr/share/selinux/devel/include/contrib/tabrmd.if | grep selinux-policy-devel" 1
+ rlPhaseEnd
+
+ if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.service ] ; then
+ rlPhaseStartTest "real scenario -- standalone service"
+ rlRun "modprobe tpm_vtpm_proxy"
+ rlRun "lsmod | grep tpm"
+ rlRun "ls -lZ /dev/vtpmx"
+ rlRun "mkdir -p /var/lib/swtpm/tpm0"
+ rlRun "chown -R tss:tss /var/lib/swtpm"
+ rlRun "swtpm_setup --tpm-state /var/lib/swtpm/tpm0 --tpm2 --create-ek-cert --create-platform-cert"
+ rlRun "swtpm chardev --vtpm-proxy --tpm2 --tpmstate dir=/var/lib/swtpm/tpm0 --daemon"
+ sleep 2
+ rlRun "ls -lZ /dev/tpm*"
+ rlRun "tpm2_getrandom --hex 16"
+ 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" 2
+ rlRun "gdbus introspect --system --dest com.intel.tss2.Tabrmd --object-path /com/intel/tss2/Tabrmd --recurse"
+ rlSEService - ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "stop status" 2
+ rlPhaseEnd
+ fi
+
+ rlPhaseStartCleanup
+ sleep 2
+ rlSECheckAVC
+
+ rlServiceRestore ${SERVICE_NAME}
+ rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
+
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-06 15:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 15:04 [tests/selinux] main: add a new test which covers the tpm2-abrmd service Milos Malik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox