2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2022 Oracle. All Rights Reserved.
7 # Functional test for dropping capability bits as part of an fallocate.
10 _begin_fstest auto prealloc quick
12 # Override the default cleanup function.
16 rm -r -f $tmp.* $junk_dir
19 # Import common functions.
22 # real QA test starts here
24 # Modify as appropriate.
27 _require_command "$GETCAP_PROG" getcap
28 _require_command "$SETCAP_PROG" setcap
29 _require_xfs_io_command falloc
32 junk_dir=$TEST_DIR/$seq
40 chmod a+rwx $junk_file
41 $SETCAP_PROG cap_setgid,cap_setuid+ep $junk_file
48 stat -c '%a %A %n' $junk_file | _filter_test_dir
49 _getcap -v $junk_file | _filter_test_dir
51 local cmd="$XFS_IO_PROG -c 'falloc 0 64k' $junk_file"
52 if [ -n "$user" ]; then
53 su - "$user" -c "$cmd" >> $seqres.full
55 $SHELL -c "$cmd" >> $seqres.full
58 stat -c '%a %A %n' $junk_file | _filter_test_dir
59 _getcap -v $junk_file | _filter_test_dir
61 # Blank line in output
65 # Commit by an unprivileged user clears capability bits.
66 echo "Test 1 - qa_user"
68 commit_and_check "$qa_user"
70 # Commit by root leaves capability bits.