Skip to contentSkip to conversation

generic: add test of file mode when setfacl fails

PATCH Superseded Ernesto A. Fernández 2 participants 2 messages Jul 14, 2017

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 generic: add test of file mode when setfacl fails

Check that the group permission bits of a file are not altered when setfacl fails. At the time of this patch the test fails for at least ext2, ext4 and jfs.

Also add support for jfs in _scratch_mkfs_sized, which is needed here.

Note that this test is not meaningful for all filesystems, because some will still succeed in setting the acls. This does not mean they don't have a bug in how they would handle an error.

---
Changes in v2:
- Use the scratch dev instead of the test dev so we can make a small fs and fill it faster. As suggested by Christoph Hellwig.
- Make jfs work with _scratch_mkfs_sized, needed for the above.
- Remove the mention to an issue with reiserfs, since I now believe the problem is on their side.

 common/rc             |  5 ++-
 tests/generic/447     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/447.out |  2 ++
 tests/generic/group   |  1 +
 4 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100755 tests/generic/447
 create mode 100644 tests/generic/447.out
common/rc +4 -1
index b505365..a2258be 100644
@@ -1020,7 +1020,7 @@ _scratch_mkfs_sized()
     xfs)
 	def_blksz=`echo $MKFS_OPTIONS|sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
 	;;
-    ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2)
+    ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2|jfs)
 	def_blksz=`echo $MKFS_OPTIONS| sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
 	;;
     esac
@@ -1068,6 +1068,9 @@ _scratch_mkfs_sized()
 	(( fssize <= 100 * 1024 * 1024 )) && mixed_opt='--mixed'
 	$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
 	;;
+    jfs)
+	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+	;;
     reiser4)
 	# mkfs.resier4 requires size in KB as input for creating filesystem
 	$MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \
tests/generic/447 new file +91 -0

91 lines not on this page · raw message

tests/generic/447.out new file +2 -0
new file mode 100644
index 0000000..adec877
@@ -0,0 +1,2 @@
+QA output created by 447
+-rwx------
tests/generic/group +1 -0
index 8c1e21a..f11d798 100644
@@ -449,3 +449,4 @@
 444 auto quick acl
 445 auto quick rw
 446 auto quick rw dangerous
+447 acl
Signature · 1 line
2.1.4
#1 lore raw
Quoted 10 lines · Ernesto A. Fernández

Check that the group permission bits of a file are not altered when setfacl fails. At the time of this patch the test fails for at least ext2, ext4 and jfs.

Also add support for jfs in _scratch_mkfs_sized, which is needed here.

Note that this test is not meaningful for all filesystems, because some will still succeed in setting the acls. This does not mean they don't have a bug in how they would handle an error.

Quoted 8 lines

---
Changes in v2:
- Use the scratch dev instead of the test dev so we can make a small fs and fill it faster. As suggested by Christoph Hellwig.
- Make jfs work with _scratch_mkfs_sized, needed for the above.
- Remove the mention to an issue with reiserfs, since I now believe the problem is on their side.

Thanks for the updated patch! Some minor comments inline.

Quoted 23 lines
 common/rc             |  5 ++-
 tests/generic/447     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/447.out |  2 ++
 tests/generic/group   |  1 +
 4 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100755 tests/generic/447
 create mode 100644 tests/generic/447.out
common/rc +1 -1
index b505365..a2258be 100644
@@ -1020,7 +1020,7 @@ _scratch_mkfs_sized()
     xfs)
 	def_blksz=`echo $MKFS_OPTIONS|sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
 	;;
-    ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2)
+    ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2|jfs)
 	def_blksz=`echo $MKFS_OPTIONS| sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
 	;;
     esac

common/rc _scratch_mkfs_sized() · line 1076

Quoted 9 lines
common/rc +3 -0
@@ -1068,6 +1068,9 @@ _scratch_mkfs_sized()
 	(( fssize <= 100 * 1024 * 1024 )) && mixed_opt='--mixed'
 	$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
 	;;
+    jfs)
+	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+	;;
     reiser4)
 	# mkfs.resier4 requires size in KB as input for creating filesystem
 	$MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \

Could you please add jfs support to _scratch_mkfs_sized in a separate patch?

Quoted 34 lines
tests/generic/447 new file +28 -0
new file mode 100755
index 0000000..ff81355
@@ -0,0 +1,91 @@
+#! /bin/bash
+# FS QA Test 447
+#
+# Fill the device and set as many extended attributes to a file as
+# possible. Then call setfacl on it and, if this fails for lack of
+# space, test that the permissions remain the same.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Ernesto A. Fernandez.  All Rights Reserved.
+#
+# 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.
+#
+# This program is distributed in the hope that it would 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, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"

tests/generic/447 line 38

Quoted 10 lines
tests/generic/447 new file +10 -0
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	_scratch_unmount

This is not needed, SCRATCH_DEV will be unmounted by next test that calls _require_scratch.

Quoted 13 lines
tests/generic/447 new file +13 -0
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+

tests/generic/447 line 61

Quoted 10 lines
tests/generic/447 new file +10 -0
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_test
+_require_acls
+_require_attrs
+
+_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mount

Because this test is trying to consume all space on $SCRATCH_MNT, it'd be good to exit if _scratch_mount fails, otherwise it's filling rootfs.

_scratch_mount || _fail "mount failed"

tests/generic/447 line 64

Quoted 3 lines
tests/generic/447 new file +3 -0
+
+cd $SCRATCH_MNT
+TFILE=testfile.$seq

Hmm, fstests prefer:

TFILE=$SCRATCH_MNT/testfile.$seq
touch $TFILE
chmod u_rwx $TFILE
...

instead of cd to $SCRATCH_MNT.

tests/generic/447 line 67

Quoted 3 lines
tests/generic/447 new file +3 -0
+
+# Create the test file and choose its permissions
+rm -f $TFILE

$SCRATCH_DEV was just created, no need to remove $TFILE here.

tests/generic/447 line 73

Quoted 6 lines
tests/generic/447 new file +6 -0
+touch $TFILE
+chmod u+rwx $TFILE
+chmod go-rwx $TFILE
+
+# Try to run out of space so setfacl will fail
+yes xxxxxxxxxx &> $TFILE

How about just writing 50M to $TFILE?

$XFS_IO_PROG -fc "pwrite 0 50m" $TFILE >>$seqres.full 2>&1

Quoted 31 lines
tests/generic/447 new file +18 -0
+i=1
+while setfattr -n user.$i $TFILE &> /dev/null; do
+	((++i))
+done
+
+if setfacl -m m:r $TFILE &> /dev/null; then
+	# setfacl succeeded, so the test was meaningless
+	# The filesystem might still have an issue
+	status=0
+	echo "-rwx------"
+	exit
+fi
+
+# Since setfacl failed, the permissions should not have changed
+stat -c %A $TFILE
+
+status=0
+exit
tests/generic/447.out new file +2 -0
new file mode 100644
index 0000000..adec877
@@ -0,0 +1,2 @@
+QA output created by 447
+-rwx------
tests/generic/group +0 -0
index 8c1e21a..f11d798 100644

tests/generic/group line 452

Quoted 4 lines
tests/generic/group +1 -0
@@ -449,3 +449,4 @@
 444 auto quick acl
 445 auto quick rw
 446 auto quick rw dangerous
+447 acl

Should be in auto and quick group too. Basically auto group means this test is a well defined regression test and the run time is less than 300s, quick group is a subset of auto, and the run time is usually within 30s.

Thanks,
Eryu