generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 369
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 369
6 #
7 # RichACL delete test
8 #
9 . ./common/preamble
10 _begin_fstest auto quick richacl
11
12 # Import common functions.
13
14 # real QA test starts here
15
16 _supported_fs generic
17
18 _require_scratch
19 _require_scratch_richacl
20 _require_richacl_prog
21 _require_runas
22
23 _scratch_mkfs_richacl >> $seqres.full
24 _scratch_mount
25
26 cd $SCRATCH_MNT
27
28 r()
29 {
30         echo "--- runas -u 99 -g 99 $*"
31         _runas -u 99 -g 99 -- "$@"
32 }
33
34 umask 022
35
36 chmod go+w .
37 mkdir d1 d2 d3 d4 d5 d6 d7
38 touch d1/f d1/g d2/f d3/f d4/f d5/f d6/f d7/f d7/g d7/h
39 chmod o+w d1/g
40 chown 99 d2
41 chgrp 99 d3
42 chmod g+w d3
43 $SETRICHACL_PROG --set 'u:99:wx::allow' d4
44 $SETRICHACL_PROG --set 'u:99:d::allow' d5
45 $SETRICHACL_PROG --set 'u:99:xd::allow' d6
46 $SETRICHACL_PROG --set 'u:99:D::allow' d7/f d7/g d7/h
47 chmod 664 d7/g
48
49 mkdir s2 s3 s4 s5 s6 s7
50 chmod +t s2 s3 s4 s5 s6 s7
51 touch s2/f s3/f s4/f s5/f s6/f s7/f s7/g s7/h
52 chown 99 s2
53 chgrp 99 s3
54 chmod g+w s3
55 $SETRICHACL_PROG --set 'u:99:wx::allow' s4
56 $SETRICHACL_PROG --set 'u:99:d::allow' s5
57 $SETRICHACL_PROG --set 'u:99:xd::allow' s6
58 $SETRICHACL_PROG --set 'u:99:D::allow' s7/f s7/g s7/h
59 chmod 664 s7/g
60
61 # Cannot delete files with no or only with write permissions on the directory
62 r rm -f d1/f d1/g
63
64 # Can delete files in directories we own
65 r rm -f d2/f s2/f
66
67 # Can delete files in non-sticky directories we have write access to
68 r rm -f d3/f s3/f
69
70 # "Write_data/execute" access does not include delete_child access, so deleting
71 # is not allowed:
72 r rm -f d4/f s4/f
73
74 # "Delete_child" access alone also is not sufficient
75 r rm -f d5/f s5/f
76
77 # "Execute/delete_child" access is sufficient for non-sticky directories
78 r rm -f d6/f s6/f
79
80 # "Delete" access on the child is sufficient, even in sticky directories.
81 r rm -f d7/f s7/f
82
83 # Regression: Delete access must not override add_file / add_subdirectory
84 # access.
85 r touch h
86 r mv -f h d7/
87 r mv -f h s7/
88
89 # A chmod turns off the "delete" permission
90 r rm -f d7/g s7/g
91
92 # success, all done
93 status=0
94 exit