public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: selinux-policy: Move tlp tests to upstream
@ 2026-09-11 13:18 Amith Kumar
  0 siblings, 0 replies; only message in thread
From: Amith Kumar @ 2026-09-11 13:18 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 5e5913141f2dd90b839ccaf27b2f4553e87235fc
            Author : Amith Kumar <apeetham@redhat.com>
            Date   : 2020-12-01T14:00:21+00:00
            Stats  : +207/-0 in 5 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/5e5913141f2dd90b839ccaf27b2f4553e87235fc?branch=pr775-checkpolicy-revdeps

            Log:
            selinux-policy: Move tlp tests to upstream

Migrate cases from downstream test suite tlp-and-similar to upstream.

Signed-off-by: Amith Kumar <apeetham@redhat.com>

---
diff --git a/selinux-policy/tlp-and-similar/Makefile b/selinux-policy/tlp-and-similar/Makefile
new file mode 100644
index 0000000..386b5bd
--- /dev/null
+++ b/selinux-policy/tlp-and-similar/Makefile
@@ -0,0 +1,69 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Makefile of /CoreOS/selinux-policy/Regression/tlp-and-similar
+#   Description: the service was running as initrc_t or init_t, now it is confined by SELinux
+#   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/tlp-and-similar
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE ssh.exp
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+	./runtest.sh
+
+build: $(BUILT_FILES)
+	chmod a+x runtest.sh ssh.exp
+	chcon -t bin_t runtest.sh ssh.exp
+
+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:     the service was running as initrc_t or init_t, now it is confined by SELinux" >> $(METADATA)
+	@echo "Type:            Regression" >> $(METADATA)
+	@echo "TestTime:        10m" >> $(METADATA)
+	@echo "RunFor:          selinux-policy" >> $(METADATA)
+	@echo "RunFor:          tlp" >> $(METADATA)
+	@echo "Requires:        audit libselinux libselinux-utils policycoreutils selinux-policy selinux-policy-targeted setools-console expect openssh-clients tlp rfkill" >> $(METADATA)
+	@echo "RhtsRequires:    library(selinux-policy/common)" >> $(METADATA)
+	@echo "Environment:     AVC_ERROR=+no_avc_check" >> $(METADATA)
+	@echo "Priority:        Normal" >> $(METADATA)
+	@echo "License:         GPLv2" >> $(METADATA)
+	@echo "Confidential:    no" >> $(METADATA)
+	@echo "Destructive:     no" >> $(METADATA)
+	@echo "Releases:        -RHEL4 -RHEL5" >> $(METADATA)
+	@echo "Bug:             1460481" >> $(METADATA) # RHEL-7
+
+	rhts-lint $(METADATA)
+

diff --git a/selinux-policy/tlp-and-similar/PURPOSE b/selinux-policy/tlp-and-similar/PURPOSE
new file mode 100644
index 0000000..3e011a7
--- /dev/null
+++ b/selinux-policy/tlp-and-similar/PURPOSE
@@ -0,0 +1,5 @@
+PURPOSE of /CoreOS/selinux-policy/Regression/tlp-and-similar
+Author: Milos Malik <mmalik@redhat.com>
+
+SELinux interferes with tlp and related programs.
+

diff --git a/selinux-policy/tlp-and-similar/main.fmf b/selinux-policy/tlp-and-similar/main.fmf
new file mode 100644
index 0000000..46dac8a
--- /dev/null
+++ b/selinux-policy/tlp-and-similar/main.fmf
@@ -0,0 +1,5 @@
+path: /selinux-policy/tlp-and-similar
+summary: SELinux interferes with tlp and related programs
+description: |
+    Test coverage for SELinux AVC issues against tlp and related
+    programs. 

diff --git a/selinux-policy/tlp-and-similar/runtest.sh b/selinux-policy/tlp-and-similar/runtest.sh
new file mode 100755
index 0000000..55a0f5f
--- /dev/null
+++ b/selinux-policy/tlp-and-similar/runtest.sh
@@ -0,0 +1,108 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/selinux-policy/Regression/tlp-and-similar
+#   Description: the service was running as initrc_t or init_t, now it is confined by SELinux
+#   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/bin/rhts-environment.sh || exit 1
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="selinux-policy"
+ROOT_PASSWORD="redhat"
+FILE_PATH="/usr/sbin/tlp"
+FILE_CONTEXT="tlp_exec_t"
+SERVICE_PACKAGE="tlp"
+SERVICE_NAME="tlp"
+PROCESS_NAME="tlp"
+PROCESS_CONTEXT="tlp_t"
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlRun "rlImport 'selinux-policy/common'"
+        rlSESatisfyRequires
+        rlAssertRpm ${PACKAGE}
+        rlAssertRpm ${PACKAGE}-targeted
+        rlAssertRpm ${SERVICE_PACKAGE}
+
+        rlServiceStop ${SERVICE_NAME}
+        rlFileBackup /etc/shadow
+
+        rlSESetEnforce
+        rlSEStatus
+        rlSESetTimestamp
+        sleep 2
+    rlPhaseEnd
+
+    if rlSEDefined ${PROCESS_CONTEXT} ; then
+    rlPhaseStartTest "bz#1460481"
+        rlSEMatchPathCon "${FILE_PATH}" "${FILE_CONTEXT}"
+        rlSEMatchPathCon "/usr/sbin/iw" "ifconfig_exec_t"
+        rlSEMatchPathCon "/usr/sbin/ethtool" "ifconfig_exec_t"
+        rlSEMatchPathCon "/run/tlp" "tlp_var_run_t"
+        rlSEMatchPathCon "/run/tlp/lock_tlp" "tlp_var_run_t"
+        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 tlp_t var_run_t : dir { write add_name } [ ]"
+        rlSESearchRule "type_transition tlp_t var_run_t : dir tlp_var_run_t"
+        rlSESearchRule "type_transition tlp_t var_run_t : file tlp_var_run_t"
+        rlSESearchRule "allow ifconfig_t tlp_var_run_t : dir { add_name write } [ ]"
+        rlSESearchRule "allow ifconfig_t tlp_var_run_t : file { create write } [ ]"
+    rlPhaseEnd
+    fi
+
+    rlPhaseStartTest "real scenario -- standalone service"
+        rlRun "echo ${ROOT_PASSWORD} | passwd --stdin root"
+        if ! rlSEDefined ${PROCESS_CONTEXT} ; then
+            if rlIsRHEL 5 6 ; then
+                PROCESS_CONTEXT="initrc_t"
+            else # RHEL-7 and above
+                PROCESS_CONTEXT="unconfined_service_t"
+            fi
+        fi
+        rlSEService ${ROOT_PASSWORD} ${SERVICE_NAME} - ${PROCESS_CONTEXT} "start status" 1
+        rlRun "tlp-stat -v"
+        rlSEService ${ROOT_PASSWORD} ${SERVICE_NAME} - ${PROCESS_CONTEXT} "restart status stop status" 1
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        sleep 2
+        rlSECheckAVC
+
+        rlFileRestore
+        rlServiceRestore ${SERVICE_NAME}
+    rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
+

diff --git a/selinux-policy/tlp-and-similar/ssh.exp b/selinux-policy/tlp-and-similar/ssh.exp
new file mode 100755
index 0000000..58c9647
--- /dev/null
+++ b/selinux-policy/tlp-and-similar/ssh.exp
@@ -0,0 +1,20 @@
+#!/usr/bin/expect -f
+# Expect script for SSH logging as $username to $hostname using $password and executing $command.
+# Usage:
+#   ./ssh.exp username password hostname command
+set username [lrange $argv 0 0]
+set password [lrange $argv 1 1]
+set hostname [lrange $argv 2 2]
+set command  [lrange $argv 3 10]
+set timeout 15
+# connect to remote host and execute given command
+log_user 1
+spawn ssh -t $username@$hostname $command
+expect {
+  -nocase "yes/no" { send -- "yes\r" ; exp_continue }
+  -nocase "password" { send -- "$password\r" }
+}
+log_user 1
+# send -- "\r"
+expect eof
+

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-11 13:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 13:18 [tests/selinux] pr775-checkpolicy-revdeps: selinux-policy: Move tlp tests to upstream Amith Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox