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] pr775-checkpolicy-revdeps: add the targetd test to upstream repo
Date: Fri, 11 Sep 2026 13:20:51 GMT [thread overview]
Message-ID: <178913285109.1.8579788287373565826.tests-selinux-bf25ac6f2685@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : tests/selinux
Branch : pr775-checkpolicy-revdeps
Commit : bf25ac6f26854ee8ecee31bd77151d1464d4e03e
Author : Milos Malik <mmalik@redhat.com>
Date : 2023-07-12T08:39:32+00:00
Stats : +330/-0 in 4 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/bf25ac6f26854ee8ecee31bd77151d1464d4e03e?branch=pr775-checkpolicy-revdeps
Log:
add the targetd test to upstream repo
The targetd component is also used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
---
diff --git a/selinux-policy/targetd-and-similar/Makefile b/selinux-policy/targetd-and-similar/Makefile
new file mode 100644
index 0000000..3303609
--- /dev/null
+++ b/selinux-policy/targetd-and-similar/Makefile
@@ -0,0 +1,77 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Makefile of /CoreOS/selinux-policy/Regression/targetd-and-similar
+# Description: SELinux interferes with targetd 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/targetd-and-similar
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ./runtest.sh
+
+build: $(BUILT_FILES)
+ chmod a+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 <mmalik@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: SELinux interferes with targetd and related programs" >> $(METADATA)
+ @echo "Type: Regression" >> $(METADATA)
+ @echo "TestTime: 15m" >> $(METADATA)
+ @echo "RunFor: selinux-policy" >> $(METADATA)
+ @echo "RunFor: targetd" >> $(METADATA)
+ @echo "Requires: audit libselinux libselinux-utils policycoreutils selinux-policy selinux-policy-targeted setools-console targetd targetcli lvm2 /usr/sbin/service httpd" >> $(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" >> $(METADATA)
+ @echo "Bug: 1063714" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1373860" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1424621" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1486252" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1486259" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1546671" >> $(METADATA) # RHEL-7
+ @echo "Bug: 1569663" >> $(METADATA) # RHEL-8
+ @echo "Bug: 2062183" >> $(METADATA) # RHEL-8
+ @echo "Bug: 2203720" >> $(METADATA) # RHEL-8
+
+ rhts-lint $(METADATA)
+
diff --git a/selinux-policy/targetd-and-similar/PURPOSE b/selinux-policy/targetd-and-similar/PURPOSE
new file mode 100644
index 0000000..f057996
--- /dev/null
+++ b/selinux-policy/targetd-and-similar/PURPOSE
@@ -0,0 +1,5 @@
+PURPOSE of /CoreOS/selinux-policy/Regression/targetd-and-similar
+Author: Milos Malik <mmalik@redhat.com>
+
+SELinux interferes with targetd and related programs. Possible interactions: targetd + btrfs.
+
diff --git a/selinux-policy/targetd-and-similar/main.fmf b/selinux-policy/targetd-and-similar/main.fmf
new file mode 100644
index 0000000..90a3e75
--- /dev/null
+++ b/selinux-policy/targetd-and-similar/main.fmf
@@ -0,0 +1,54 @@
+summary: SELinux interferes with targetd and related programs
+description: |+
+ SELinux interferes with targetd and related programs. Possible interactions: targetd + btrfs.
+
+contact: Milos Malik <mmalik@redhat.com>
+component:
+ - selinux-policy
+ - targetd
+test: ./runtest.sh
+framework: beakerlib
+require:
+ - library(selinux-policy/common)
+recommend:
+ - audit
+ - libselinux
+ - libselinux-utils
+ - policycoreutils
+ - selinux-policy
+ - selinux-policy-targeted
+ - setools-console
+ - targetd
+ - targetcli
+ - lvm2
+ - /usr/sbin/service
+ - httpd
+environment:
+ AVC_ERROR: +no_avc_check
+duration: 15m
+enabled: false
+tag:
+ - NoRHEL4
+ - NoRHEL5
+ - NoRHEL6
+ - TierCandidatesPASS
+ - epel
+ - rhel8-epel
+ - targeted
+link:
+ - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1063714
+ - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1373860
+ - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1424621
+ - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1486252
+ - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1486259
+ - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1546671
+ - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1569663
+ - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2062183
+ - verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2203720
+adjust:
+ - enabled: true
+ when: distro == rhel-7, rhel-8, fedora
+ because: the targetd package is not available elsewhere
+extra-nitrate: TC#0337221
+extra-summary: /CoreOS/selinux-policy/Regression/targetd-and-similar
+extra-task: /CoreOS/selinux-policy/Regression/targetd-and-similar
diff --git a/selinux-policy/targetd-and-similar/runtest.sh b/selinux-policy/targetd-and-similar/runtest.sh
new file mode 100755
index 0000000..605daf6
--- /dev/null
+++ b/selinux-policy/targetd-and-similar/runtest.sh
@@ -0,0 +1,194 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of /CoreOS/selinux-policy/Regression/targetd-and-similar
+# Description: SELinux interferes with targetd 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/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="selinux-policy"
+ROOT_PASSWORD="redhat"
+FILE_PATH="/usr/bin/targetd"
+FILE_CONTEXT="targetd_exec_t"
+SERVICE_PACKAGE="targetd"
+SERVICE_NAME="targetd"
+PROCESS_NAME="targetd"
+PROCESS_CONTEXT="targetd_t"
+
+rlJournalStart
+ rlPhaseStartSetup
+ rlRun "rlImport 'selinux-policy/common'"
+ rlSESatisfyRequires
+ rlAssertRpm ${PACKAGE}
+ rlAssertRpm ${PACKAGE}-targeted
+ rlAssertRpm ${SERVICE_PACKAGE}
+
+ rlServiceStop ${SERVICE_NAME}
+ rlFileBackup --clean /etc/target/saveconfig.json
+ rlFileBackup --clean /etc/target/targetd.yaml
+ rlFileBackup /etc/lvm/lvm.conf
+ rlFileBackup /etc/shadow
+
+ rlSESetEnforce
+ rlSEStatus
+ rlSESetTimestamp
+ sleep 2
+ rlPhaseEnd
+
+ rlPhaseStartTest "bz#1063714"
+ rlSEMatchPathCon "${FILE_PATH}" "${FILE_CONTEXT}"
+ if rlIsRHEL 5 ; then
+ SOURCE_TYPE="initrc_t"
+ BOOLEANS="[ ]"
+ elif rlIsRHEL 6 ; then
+ SOURCE_TYPE="initrc_t"
+ else # RHEL-7 etc.
+ SOURCE_TYPE="init_t" # systemd runs the process
+ fi
+ 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"
+ rlSESearchRule "allow targetd_t lvm_control_t : chr_file { getattr open read write ioctl } [ ]"
+ rlPhaseEnd
+
+ rlPhaseStartTest "bz#1373860 + bz#1486252"
+ rlSEMatchPathCon "/usr/bin/targetd" "targetd_exec_t"
+ rlSESearchRule "allow targetd_t targetd_t : unix_dgram_socket { create getopt setopt ioctl }"
+ rlSESearchRule "allow targetd_t proc_net_t : file { getattr open read }"
+ rlSESearchRule "dontaudit targetd_t targetd_t : capability { net_admin }"
+ rlSESearchRule "allow targetd_t kernel_t : unix_dgram_socket { sendto }"
+ rlSESearchRule "dontaudit targetd_t rpm_exec_t : file { getattr }"
+ rlSESearchRule "allow targetd_t tmp_t : dir { getattr open read }"
+ rlSESearchRule "dontaudit targetd_t rpm_var_lib_t : file { getattr open }"
+ rlSESearchRule "dontaudit targetd_t semanage_store_t : dir { getattr }"
+ rlSESearchRule "allow targetd_t bin_t : file { getattr open read execute_no_trans }"
+ rlPhaseEnd
+
+ rlPhaseStartTest "bz#1424621 + bz#1486259"
+ rlSEMatchPathCon "/var/run/dmeventd-client" "lvm_var_run_t"
+ rlSESearchRule "allow targetd_t bin_t : file { getattr open read execute_no_trans }"
+ rlSESearchRule "allow targetd_t targetd_t : tcp_socket { accept }"
+ if rlIsRHEL 5 6 7 ; then
+ rlSESearchRule "dontaudit targetd_t insmod_exec_t : file { getattr }"
+ fi
+ rlSESearchRule "allow targetd_t configfs_t : dir { add_name create getattr open read remove_name rmdir search write }"
+ rlSESearchRule "allow targetd_t configfs_t : file { getattr open read write }"
+ rlSESearchRule "allow targetd_t configfs_t : lnk_file { create getattr read unlink }"
+ # following 2 rules seem to needed by btrfs tool
+ # rlSESearchRule "allow targetd_t default_t : dir { ioctl read write }"
+ # rlSESearchRule "allow targetd_t unlabeled_t : dir { ioctl read write }"
+ # rlSESearchRule "allow targetd_t mnt_t : dir { ioctl read write }"
+ rlSESearchRule "allow targetd_t exports_t : file { getattr open read }"
+ rlSESearchRule "allow targetd_t fixed_disk_device_t : blk_file { write }"
+ rlSESearchRule "allow targetd_t fs_t : filesystem { getattr }"
+ rlSESearchRule "allow targetd_t kernel_t : system { ipc_info module_request }"
+ if rlIsRHEL 7 ; then
+ rlSESearchRule "allow targetd_t lvm_metadata_t : dir { add_name read remove_name write }"
+ rlSESearchRule "allow targetd_t lvm_metadata_t : file { create link rename unlink append }"
+ rlSESearchRule "allow targetd_t lvm_var_run_t : fifo_file { getattr open lock read write }"
+ fi
+ rlSESearchRule "allow targetd_t modules_conf_t : dir { getattr open read }"
+ rlSESearchRule "allow targetd_t modules_conf_t : file { getattr open read }"
+ rlSESearchRule "allow targetd_t modules_object_t : dir { search }"
+ rlSESearchRule "allow targetd_t modules_object_t : file { getattr open read }"
+ rlSESearchRule "allow targetd_t nfsd_fs_t : file { getattr open read }"
+ rlSESearchRule "allow targetd_t targetd_t : capability { ipc_lock sys_admin sys_nice }"
+ rlSESearchRule "allow targetd_t targetd_t : process { setsched }"
+ rlSESearchRule "allow targetd_t sysctl_rpc_t : dir { search }"
+ rlSESearchRule "allow targetd_t sysctl_rpc_t : file { getattr open read write }"
+ rlSESearchRule "allow targetd_t sysfs_t : file { write }"
+ rlSESearchRule "allow targetd_t var_lib_nfs_t : dir { add_name remove_name write }"
+ rlSESearchRule "allow targetd_t var_lib_nfs_t : file { create getattr lock open read rename unlink write }"
+ rlPhaseEnd
+
+ if ! rlIsRHEL 5 6 7 ; then
+ rlPhaseStartTest "bz#1569663"
+ rlSEMatchPathCon "/etc/lvm/lvm.conf" "lvm_etc_t"
+ rlSESearchRule "allow targetd_t lvm_etc_t : file { map }"
+ rlPhaseEnd
+
+ rlPhaseStartTest "bz#2062183"
+ rlSEMatchPathCon "/usr/sbin/lvm" "lvm_exec_t"
+ rlSESearchRule "allow targetd_t lvm_exec_t : file { getattr open read execute map } [ ]"
+ rlSESearchRule "type_transition targetd_t lvm_exec_t : process lvm_t"
+ rlSESearchRule "allow targetd_t lvm_t : process { transition } [ ]"
+ rlPhaseEnd
+ fi
+
+ rlPhaseStartTest "bz#1546671"
+ rlSEMatchPathCon "/usr/bin/targetd" "targetd_exec_t"
+ rlSEMatchPathCon "/root/.local" "gconf_home_t"
+ rlSEMatchPathCon "/home/user/.local" "gconf_home_t"
+ rlSEMatchPathCon "/etc/lvm/lvm.conf" "lvm_etc_t"
+ rlSESearchRule "allow targetd_t gconf_home_t : dir { search }"
+ rlSESearchRule "allow targetd_t lvm_etc_t : file { map }"
+ rlPhaseEnd
+
+ rlPhaseStartTest "bz#2203720"
+ rlSEMatchPathCon "/usr/bin/targetd" "targetd_exec_t"
+ rlSEMatchPathCon "/etc/httpd" "httpd_config_t"
+ rlSEMatchPathCon "/etc/httpd/conf" "httpd_config_t"
+ rlSESearchRule "dontaudit targetd_t httpd_config_t : dir { search } [ ]"
+ rlPhaseEnd
+
+ rlPhaseStartTest "real scenario -- standalone service"
+ rlRun "rm -f /etc/target/saveconfig.json"
+ rlRun "rm -f /etc/target/targetd.yaml"
+ rlRun "targetctl clear"
+ rlRun "targetctl save"
+ rlRun "echo \"password: Str0nGp4ssw0rD\" > /etc/target/targetd.yaml"
+ rlRun "sed -i \"s/use_lvmetad = 1/use_lvmetad = 0/\" /etc/lvm/lvm.conf"
+ rlRun "ls -Z /etc/target"
+ LOOP_FILE="vg-targetd.img"
+ LOOP_DEVICE=`losetup -f`
+ rlRun "dd if=/dev/zero of=${LOOP_FILE} bs=1MB count=128"
+ rlRun "losetup ${LOOP_DEVICE} ${LOOP_FILE}"
+ rlRun "vgcreate vg-targetd ${LOOP_DEVICE}"
+ rlRun "vgdisplay"
+ rlRun "echo ${ROOT_PASSWORD} | passwd --stdin root"
+ if ! rlSEDefined ${PROCESS_CONTEXT} ; then
+ # for RHELs where the SELinux domain does not exist yet
+ PROCESS_CONTEXT="initrc_t"
+ fi
+ rlSEService ${ROOT_PASSWORD} ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "start status" 1
+ rlRun "targetcli ls"
+ rlRun "targetcli version"
+ rlSEService ${ROOT_PASSWORD} ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "restart status stop status" 1
+ rlRun "vgremove vg-targetd"
+ rlRun "losetup -d ${LOOP_DEVICE}"
+ rlRun "rm -f ${LOOP_FILE}"
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ sleep 2
+ rlSECheckAVC
+
+ rlFileRestore
+ rlServiceRestore ${SERVICE_NAME}
+ rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
+
reply other threads:[~2026-09-11 13:20 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=178913285109.1.8579788287373565826.tests-selinux-bf25ac6f2685@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