public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jan Zarsky <jzarsky@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: test mounting filesystems
Date: Fri, 11 Sep 2026 13:17:19 GMT	[thread overview]
Message-ID: <178913263993.1.6469968000298498676.tests-selinux-78a4769cedbe@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 78a4769cedbe7f5f5753a0cb4e3e7ddfd5096a26
            Author : Jan Zarsky <jzarsky@redhat.com>
            Date   : 2018-07-31T22:58:16+02:00
            Stats  : +196/-0 in 4 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/78a4769cedbe7f5f5753a0cb4e3e7ddfd5096a26?branch=pr775-checkpolicy-revdeps

            Log:
            test mounting filesystems

Test the context and defcontext options of the mount command. Test
different filesystems: ext2, ext3, ext4. XFS, FAT32.

Requires e2fsprogs and dosfstools.

---
diff --git a/other/mounting/Makefile b/other/mounting/Makefile
new file mode 100644
index 0000000..d2bedf4
--- /dev/null
+++ b/other/mounting/Makefile
@@ -0,0 +1,66 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Makefile of /CoreOS/selinux-policy/Sanity/mounting
+#   Description: Mount various filesystems, test context options.
+#   Author: Jan Zarsky <jzarsky@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2018 Red Hat, Inc.
+#
+#   This program is free software: you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation, either version 2 of
+#   the License, or (at your option) any later version.
+#
+#   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 http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+export TEST=/CoreOS/selinux-policy/Sanity/mounting
+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)
+	test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+	rm -f *~ $(BUILT_FILES)
+
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+	@echo "Owner:           Jan Zarsky <jzarsky@redhat.com>" > $(METADATA)
+	@echo "Name:            $(TEST)" >> $(METADATA)
+	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)
+	@echo "Path:            $(TEST_DIR)" >> $(METADATA)
+	@echo "Description:     Mount various filesystems, test context options." >> $(METADATA)
+	@echo "Type:            Sanity" >> $(METADATA)
+	@echo "TestTime:        5m" >> $(METADATA)
+	@echo "RunFor:          selinux-policy" >> $(METADATA)
+	@echo "Requires:        selinux-policy" >> $(METADATA)
+	@echo "Requires:        util-linux" >> $(METADATA)
+	@echo "Requires:        e2fsprogs" >> $(METADATA)
+	@echo "Requires:        dosfstools" >> $(METADATA)
+	@echo "Priority:        Normal" >> $(METADATA)
+	@echo "License:         GPLv2+" >> $(METADATA)
+	@echo "Confidential:    no" >> $(METADATA)
+	@echo "Destructive:     no" >> $(METADATA)
+	@echo "Releases:        -RHEL4 -RHELClient5 -RHELServer5 -RHEL6" >> $(METADATA)
+
+	rhts-lint $(METADATA)

diff --git a/other/mounting/PURPOSE b/other/mounting/PURPOSE
new file mode 100644
index 0000000..30484dd
--- /dev/null
+++ b/other/mounting/PURPOSE
@@ -0,0 +1,3 @@
+PURPOSE of /CoreOS/selinux-policy/Sanity/mounting
+Description: Mount various filesystems, test context options.
+Author: Jan Zarsky <jzarsky@redhat.com>

diff --git a/other/mounting/main.fmf b/other/mounting/main.fmf
new file mode 100644
index 0000000..a695b6f
--- /dev/null
+++ b/other/mounting/main.fmf
@@ -0,0 +1,8 @@
+path: /other/mounting
+summary: Mount various filesystems, test context options
+description: |
+    Test the context and defcontext options of the mount command. Test
+    different filesystems: ext2, ext3, ext4. XFS, FAT32. Requires
+    e2fsprogs and dosfstools.
+relevancy:
+    - "distro = rhel-4, rhel-5, rhel-6: False"

diff --git a/other/mounting/runtest.sh b/other/mounting/runtest.sh
new file mode 100755
index 0000000..d012460
--- /dev/null
+++ b/other/mounting/runtest.sh
@@ -0,0 +1,119 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/selinux-policy/Sanity/mounting
+#   Description: Mount various filesystems, test context options.
+#   Author: Jan Zarsky <jzarsky@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2018 Red Hat, Inc.
+#
+#   This program is free software: you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation, either version 2 of
+#   the License, or (at your option) any later version.
+#
+#   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 http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include Beaker environment
+. /usr/bin/rhts-environment.sh || exit 1
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="selinux-policy"
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlAssertRpm $PACKAGE
+        rlAssertRpm "util-linux"
+        rlAssertRpm "e2fsprogs"
+        rlAssertRpm "dosfstools"
+
+        # create a loopback device
+        rlRun "fallocate -l 100M loop_file"
+        rlRun "losetup -f loop_file"
+        rlRun "losetup -l | grep loop_file"
+        DEV="$(losetup -l | tail -n 1 | cut -f1 -d' ')"
+
+        # create a mounting directory
+        rlRun "mkdir mnt"
+        MNT="$(realpath mnt)"
+        rlRun "semanage fcontext -a -t user_tmp_t '$MNT/.*'"
+
+        # list the context twice so that it will be visible even when the grep
+        # fails
+        function checkFC {
+            ls -Z $1
+            ls -Z $1 | grep $2
+            return $?
+        }
+    rlPhaseEnd
+
+    for FS in mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.xfs ; do
+    rlPhaseStartTest "Test $FS"
+        # create the filesystem
+        if [[ $FS = "mkfs.xfs" ]]; then
+            rlRun "$FS $DEV -f"
+        else
+            rlRun "$FS $DEV -F"
+        fi
+
+        # create testfile and run restorecon on it
+        rlRun "mount $DEV $MNT"
+        rlRun "touch $MNT/testfile"
+        rlRun "checkFC $MNT/testfile unlabeled_t"
+        rlRun "restorecon $MNT/testfile -v"
+        rlRun "checkFC $MNT/testfile user_tmp_t"
+        rlRun "umount $DEV"
+
+        # test the context option
+        rlRun "mount $DEV $MNT -o 'context="unconfined_u:object_r:user_home_t:s0"'"
+        rlRun "checkFC $MNT/testfile user_home_t"
+        # create unlabeled file (because of the context option, xattrs won't be
+        # assigned)
+        rlRun "touch $MNT/unlabeled"
+        rlRun "checkFC $MNT/unlabeled user_home_t"
+        rlRun "umount $DEV"
+
+        # test the defcontext option
+        rlRun "mount $DEV $MNT -o 'defcontext="unconfined_u:object_r:tmp_t:s0"'"
+        # file with xattrs
+        rlRun "checkFC $MNT/testfile user_tmp_t"
+        # file without xattrs
+        rlRun "checkFC $MNT/unlabeled tmp_t"
+        rlRun "umount $DEV"
+    rlPhaseEnd
+    done
+
+    rlPhaseStartTest "Test mkfs.fat"
+        # create the filesystem
+        rlRun "mkfs.fat $DEV"
+
+        # create testfile
+        rlRun "mount $DEV $MNT"
+        rlRun "touch $MNT/testfile"
+        rlRun "checkFC $MNT/testfile dosfs_t"
+        rlRun "umount $DEV"
+
+        # test the context option
+        rlRun "mount $DEV $MNT -t vfat -o 'context="unconfined_u:object_r:user_home_t:s0"'"
+        rlRun "checkFC $MNT/testfile user_home_t"
+        rlRun "umount $DEV"
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        rlRun "losetup -d $DEV"
+        rlRun "semanage fcontext -d '$MNT/.*'"
+        rlRun "rm -rf $MNT loop_file"
+    rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd

                 reply	other threads:[~2026-09-11 13:17 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=178913263993.1.6469968000298498676.tests-selinux-78a4769cedbe@fedoraproject.org \
    --to=jzarsky@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