]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfstests: mount xfs with a context when selinux is on
authorEric Sandeen <sandeen@sandeen.net>
Fri, 19 Feb 2010 15:33:45 +0000 (09:33 -0600)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 19 Feb 2010 15:33:45 +0000 (09:33 -0600)
When selinux is on, we get tons of new xattrs, which messes
up all kinds of output.

The simplest way out of this, for now, seems to be to just mount
with a global context instead and skip writing the extra xattrs.

I've been using this internally on Fedora and RHEL for a while now.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Dave Chinner <david@fromorbit.com>
189
common.rc

diff --git a/189 b/189
index 8f1c0e15d36aab3d6042e46fcb065d5326b9ef05..e91d5cdd956570c47177e2341b10be3558330cf2 100755 (executable)
--- a/189
+++ b/189
@@ -45,7 +45,8 @@ _cleanup()
 _scratch_filter()
 {
        sed -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
-           -e "s#$SCRATCH_MNT#SCRATCH_MNT#"
+           -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
+           -e "s#,context.*s0\"##"
 }
 
 _check_mount()
index c76bcde08fd92c1d164d6a570126d842503b1afe..ca2cd2cb2f99e1363b1de4d7cf22a8c18cd0ea58 100644 (file)
--- a/common.rc
+++ b/common.rc
@@ -47,8 +47,16 @@ _ls_l()
 
 _mount_opts()
 {
+    # SELinux adds extra xattrs which can mess up our expected output.
+    # So, mount with a context, and they won't be created
+    # nfs_t is a "liberal" context so we can use it.
+    if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+       SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
+    fi
+
     case $FSTYP in
     xfs)
+       export SELINUX_MOUNT_OPTIONS
        export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
        ;;
     udf)
@@ -214,7 +222,7 @@ _scratch_mount_options()
 {
     _scratch_options mount
 
-    echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
+    echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
 }
 
 _scratch_mount()
@@ -236,7 +244,7 @@ _scratch_remount()
 _test_mount()
 {
     _test_options mount
-    _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $* $TEST_DEV $TEST_DIR
+    _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
 }
 
 _scratch_mkfs_options()