generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 555
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 555
6 #
7 # Check that we can't set FS_XFLAG_APPEND and FS_XFLAG_IMMUTABLE inode
8 # flags without capbility CAP_LINUX_IMMUTABLE.
9 #
10 # This test uses xfs_io chattr, rather than the (e2fsprogs) chattr
11 # program to exercise the FS_IOC_FSSETXATTR ioctl.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1    # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         # Cleanup of flags on both file in case test is aborted
25         # (i.e. CTRL-C), so we have no immutable/append-only files
26         $XFS_IO_PROG -f -r -c "chattr -ia" $workdir/file1 >/dev/null 2>&1
27         $XFS_IO_PROG -f -r -c "chattr -ia" $workdir/file2 >/dev/null 2>&1
28
29         cd /
30         rm -rf $tmp.* $workdir
31 }
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/filter
36 . ./common/attr
37
38 # real QA test starts here
39 _supported_fs generic
40
41 _require_test
42 _require_xfs_io_command "chattr" "ia"
43 _require_command "$CAPSH_PROG" "capsh"
44
45 workdir="$TEST_DIR/test-$seq"
46 rm -rf $workdir
47 mkdir $workdir
48
49 echo "Create the original files"
50 touch $workdir/file1
51 touch $workdir/file2
52
53 do_filter_output()
54 {
55         grep -o "Operation not permitted"
56 }
57
58 echo "Try to xfs_io chattr +ia with capabilities CAP_LINUX_IMMUTABLE"
59 $XFS_IO_PROG -f -c "chattr +ia" $workdir/file1
60
61 echo "Try to xfs_io chattr +ia/-ia without capability CAP_LINUX_IMMUTABLE"
62 $CAPSH_PROG --drop=cap_linux_immutable -- -c "$XFS_IO_PROG -f -c 'chattr +a' $workdir/file2" 2>&1 | do_filter_output
63 $CAPSH_PROG --drop=cap_linux_immutable -- -c "$XFS_IO_PROG -f -c 'chattr +i' $workdir/file2" 2>&1 | do_filter_output
64
65 $CAPSH_PROG --drop=cap_linux_immutable -- -c "$XFS_IO_PROG -f -r -c 'chattr -i' $workdir/file1" 2>&1 | do_filter_output
66 $CAPSH_PROG --drop=cap_linux_immutable -- -c "$XFS_IO_PROG -f -r -c 'chattr -a' $workdir/file1" 2>&1 | do_filter_output
67
68 echo "Try to xfs_io chattr -ia with capability CAP_LINUX_IMMUTABLE"
69 $XFS_IO_PROG -f -r -c "chattr -ia" $workdir/file1
70
71 # success, all done
72 status=0
73 exit