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: test if sysadm_u can run dmidecode via sudo
Date: Fri, 11 Sep 2026 13:21:20 GMT	[thread overview]
Message-ID: <178913288074.1.18198179338430013963.tests-selinux-12ea165a341b@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 12ea165a341b5e0890fbb72d6866d38f7f6fee24
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2024-02-06T14:24:00+00:00
            Stats  : +27/-0 in 3 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/12ea165a341b5e0890fbb72d6866d38f7f6fee24?branch=pr775-checkpolicy-revdeps

            Log:
            test if sysadm_u can run dmidecode via sudo

A recently filed customer case revealed that SELinux prevents the
sysadm_u users from running the dmidecode command via sudo which
has the input/output logging enabled. The following error message
appears during the action:

  sudo: unable to open /var: Permission denied

The TC reproduces the situation.

In order to support the above-mentioned configuration, I believe that
SELinux policy should allow the necessary actions. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-16104.

---
diff --git a/selinux-policy/dmidecode-and-similar/Makefile b/selinux-policy/dmidecode-and-similar/Makefile
index 6de3c03..03a223f 100644
--- a/selinux-policy/dmidecode-and-similar/Makefile
+++ b/selinux-policy/dmidecode-and-similar/Makefile
@@ -68,6 +68,7 @@ $(METADATA): Makefile
 	@echo "Bug:             1300799" >> $(METADATA) # RHEL-7
 	@echo "Bug:             1608480" >> $(METADATA) # RHEL-7
 	@echo "Bug:             1926696" >> $(METADATA) # Fedora 34
+	@echo "Bug:             RHEL-16104" >> $(METADATA) # RHEL-9
 
 	rhts-lint $(METADATA)
 

diff --git a/selinux-policy/dmidecode-and-similar/main.fmf b/selinux-policy/dmidecode-and-similar/main.fmf
index 3c7d84d..21e4f79 100644
--- a/selinux-policy/dmidecode-and-similar/main.fmf
+++ b/selinux-policy/dmidecode-and-similar/main.fmf
@@ -41,6 +41,7 @@ link:
   - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1300799
   - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1608480
   - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1926696
+  - verifies: https://issues.redhat.com/browse/RHEL-16104
 adjust:
   - enabled: false
     when: distro == rhel-4

diff --git a/selinux-policy/dmidecode-and-similar/runtest.sh b/selinux-policy/dmidecode-and-similar/runtest.sh
index 51caa22..3b3d0bf 100755
--- a/selinux-policy/dmidecode-and-similar/runtest.sh
+++ b/selinux-policy/dmidecode-and-similar/runtest.sh
@@ -132,6 +132,31 @@ rlJournalStart
         done
     rlPhaseEnd
 
+    rlPhaseStartTest "RHEL-16104"
+        rlSEMatchPathCon "/var" "var_t"
+        rlSEMatchPathCon "/var/log" "var_log_t"
+        rlSEMatchPathCon "/var/log/sudo-io" "sudo_log_t"
+        rlSESearchRule "allow sysadm_sudo_t var_t : dir { read } [ ]"
+        rlSESearchRule "allow sysadm_sudo_t var_log_t : dir { read } [ ]"
+        rlSESearchRule "allow sysadm_sudo_t sudo_log_t : dir { read } [ ]"
+        rlRun "setsebool ssh_sysadm_login on"
+        rlRun "useradd -Z sysadm_u -G wheel sysadm-user"
+        USER_SECRET="S3kr3t${RANDOM}"
+        rlRun "echo ${USER_SECRET} | passwd --stdin sysadm-user"
+        rlRun "echo -en 'Defaults log_output\nDefaults log_input\nDefaults iolog_dir=/var/log/sudo-io\nsysadm-user ALL=(ALL) NOPASSWD: ALL\n' > /etc/sudoers.d/sysadm-user"
+        rlRun "rm -rf /var/log/sudo-io"
+        rlRun -s "./ssh.exp sysadm-user ${USER_SECRET} localhost sudo dmidecode"
+        rlRun "grep DMI $rlRun_LOG"
+        rlRun "rm -f $rlRun_LOG"
+        rlRun "rm -rf /var/log/sudo-io"
+        rlRun -s "./ssh.exp sysadm-user ${USER_SECRET} localhost sudo -r sysadm_r dmidecode"
+        rlRun "grep DMI $rlRun_LOG"
+        rlRun "rm -f $rlRun_LOG"
+        rlRun "rm -f /etc/sudoers.d/sysadm-user"
+        rlRun "userdel -rfZ sysadm-user"
+        rlRun "setsebool ssh_sysadm_login off"
+    rlPhaseEnd
+
     rlPhaseStartCleanup
         sleep 2
         rlSECheckAVC

                 reply	other threads:[~2026-09-11 13:21 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=178913288074.1.18198179338430013963.tests-selinux-12ea165a341b@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