Skip to contentSkip to conversation

xfstests: ensure selinux xattrs don't interfere with quota tests

PATCH In review Eric Sandeen 3 participants 3 messages Mar 18, 2011 – Mar 22, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: ensure selinux xattrs don't interfere with quota tests

219 and 235 were failing on ext3 with selinux, because the extra xattrs upped the quota usage.

Do the same trick we've used in the past to mount with an selinux global context when doing quota tests.

Note the gross hack for remount,ro, though.

---

235 +5 -0
index 5d9c7c0..de0d0fc 100755
@@ -61,6 +61,11 @@ chown $qa_user:$qa_user $SCRATCH_MNT/testfile
 
 repquota -u -g $SCRATCH_MNT  | grep -v "^root" | _filter_scratch
 
+# XXX This is a nasty hack.  remount doesn't work on a fileystem
+# with a context; see https://bugzilla.redhat.com/show_bug.cgi?id=563267
+#
+# We work around it by editing the context out of mtab.  Sigh.
+sed -i "s#^$SCRATCH_DEV\(.*\),context=\"system_u:object_r:nfs_t:s0\"#$SCRATCH_DEV\1#" /etc/mtab
 mount -o remount,ro $SCRATCH_DEV 2>&1 | tee -a $seq.full | _filter_scratch
 touch $SCRATCH_MNT/failed 2>&1 | tee -a $seq.full | _filter_scratch
 mount -o remount,rw $SCRATCH_DEV 2>&1 | tee -a $seq.full | _filter_scratch
common.quota +7 -0
index 96a36a6..3c87ce1 100644
@@ -45,6 +45,13 @@ _require_quota()
 	_notrun "disk quotas not supported by this filesystem type: $FSTYP"
 	;;
     esac
+
+    # 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
+        export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
+    fi
 }
 
 #

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Eric Sandeen

219 and 235 were failing on ext3 with selinux, because the extra xattrs upped the quota usage.

Do the same trick we've used in the past to mount with an selinux global context when doing quota tests.

Note the gross hack for remount,ro, though.

Looks good to me,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Sandeen
Quoted 10 lines · Eric Sandeen

219 and 235 were failing on ext3 with selinux, because the extra xattrs upped the quota usage.

Do the same trick we've used in the past to mount with an selinux global context when doing quota tests.

Note the gross hack for remount,ro, though.

---

My only suggestion would be to define the value of the security context using a variable, so it's easier to see that the thing you're editing out of /etc/mtab is identical to the thing that was supplied as a mount option. I.e., define

    MOUNT_CONTEXT="system_u:object_r:nfs_t:s0"

and use it in the two spots elsewhere.

But even if you don't take that suggestion this looks good to me.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs