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 test which covers the tpm2-abrmd service
Date: Fri, 06 Nov 2026 15:04:07 GMT	[thread overview]
Message-ID: <179397744754.1.17858482574477126966.tests-selinux-8aa65248df5b@fedoraproject.org> (raw)

            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
+

                 reply	other threads:[~2026-11-06 15:04 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=179397744754.1.17858482574477126966.tests-selinux-8aa65248df5b@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