public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eryu Guan <eguan@redhat.com>
To: fstests@vger.kernel.org
Cc: Eryu Guan <eguan@redhat.com>
Subject: [PATCH] generic/35[67]: update selinux context for mkswap
Date: Tue,  6 Dec 2016 16:09:27 +0800	[thread overview]
Message-ID: <20161206080927.22379-1-eguan@redhat.com> (raw)

With selinux enabled & the default selinux context in fstests,
mkswap is denied, generic/35[67] fail as:

+mkswap: unable to relabel /mnt/testarea/scratch/test-357/file1 to system_u:object_r:swapfile_t:s0: Operation not supported

So mount SCRATCH_DEV with swapfile selinux context if selinux is
enabled (SELINUX_MOUNT_OPTIONS not empty).

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 tests/generic/356 | 4 ++++
 tests/generic/357 | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/tests/generic/356 b/tests/generic/356
index 6bb90c0..8bebad2 100755
--- a/tests/generic/356
+++ b/tests/generic/356
@@ -49,6 +49,10 @@ _require_cp_reflink
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
+# the default selinux context won't allow mkswap
+if [ "$SELINUX_MOUNT_OPTIONS" != "" ]; then
+	export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:swapfile_t:s0"
+fi
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
diff --git a/tests/generic/357 b/tests/generic/357
index 439b314..8941927 100755
--- a/tests/generic/357
+++ b/tests/generic/357
@@ -49,6 +49,10 @@ _require_cp_reflink
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
+# the default selinux context won't allow mkswap
+if [ "$SELINUX_MOUNT_OPTIONS" != "" ]; then
+	export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:swapfile_t:s0"
+fi
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-- 
2.9.3


             reply	other threads:[~2016-12-06  8:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06  8:09 Eryu Guan [this message]
2016-12-06 22:54 ` [PATCH] generic/35[67]: update selinux context for mkswap Dave Chinner

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=20161206080927.22379-1-eguan@redhat.com \
    --to=eguan@redhat.com \
    --cc=fstests@vger.kernel.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