Skip to contentSkip to conversation

xfstests: mount with security context if SELinux is enabled

PATCH In review Eric Sandeen 1 participant 2 messages Nov 4, 2008 – Nov 5, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: mount with security context if SELinux is enabled

When SELinux is enabled, it adds extra xattrs for security attributes which can change the output of various tests, causing them to fail.

If SELinux is enabled, mount with a liberal/permissive context for the entire filesystem, so that SELinux xattrs don't get created.

---

xfstests/common.rc +10 -1
Index: xfs-cmds/xfstests/common.rc
===================================================================
@@ -39,9 +39,18 @@ dd()
 
 _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 [ "$HOSTOS" == "Linux" ]; then
+	if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+		SELINUX_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
+	fi
+    fi
+
     case $FSTYP in
     xfs)
-	export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
+	export MOUNT_OPTIONS="$XFS_MOUNT_OPTIONS $SELINUX_OPTIONS"
 	;;
     udf)
 	export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
#1 lore raw
Quoted 10 lines · Eric Sandeen

When SELinux is enabled, it adds extra xattrs for security attributes which can change the output of various tests, causing them to fail.

If SELinux is enabled, mount with a liberal/permissive context for the entire filesystem, so that SELinux xattrs don't get created.

---

hold off on this one, I've needed to make a few more changes.

Thanks,
-Eric