]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/pjdfstest/tests/granular/02.t
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / pjdfstest / tests / granular / 02.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="NFSv4 granular permissions checking - ACL_READ_ACL and ACL_WRITE_ACL"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 [ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit
10
11 echo "1..83"
12
13 n0=`namegen`
14 n1=`namegen`
15 n2=`namegen`
16
17 expect 0 mkdir ${n2} 0755
18 cdir=`pwd`
19 cd ${n2}
20
21 # Check whether user 65534 is permitted to read ACL.
22 expect 0 create ${n0} 0644
23 expect 0 readacl ${n0}
24 expect 0 -u 65534 -g 65534 readacl ${n0}
25 expect 0 prependacl ${n0} user:65534:read_acl::deny
26 expect 0 readacl ${n0}
27 expect EACCES -u 65534 -g 65534 readacl ${n0}
28 expect 0 prependacl ${n0} user:65534:read_acl::allow
29 expect 0 -u 65534 -g 65534 readacl ${n0}
30 expect 0 readacl ${n0}
31 expect 0 unlink ${n0}
32
33 # Check whether user 65534 is permitted to write ACL.
34 expect 0 create ${n0} 0644
35 expect EPERM -u 65534 -g 65534 prependacl ${n0} user:65534:read_data::allow
36 expect 0 prependacl ${n0} user:65534:write_acl::allow
37 expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_data::allow
38 expect 0 unlink ${n0}
39
40 # Check whether user 65534 is permitted to write mode.
41 expect 0 create ${n0} 0755
42 expect EPERM -u 65534 -g 65534 chmod ${n0} 0777
43 expect 0 prependacl ${n0} user:65534:write_acl::allow
44 expect 0 -u 65534 -g 65534 chmod ${n0} 0777
45 expect 0 unlink ${n0}
46
47 # There is an interesting problem with interaction between ACL_WRITE_ACL
48 # and SUID/SGID bits.  In case user does have ACL_WRITE_ACL, but is not
49 # a file owner, Solaris does the following:
50 # 1. Setting SUID fails with EPERM.
51 # 2. Setting SGID succeeds, but mode is not changed.
52 # 3. Modifying ACL does not clear SUID nor SGID bits.
53 # 4. Writing the file does clear both SUID and SGID bits.
54 #
55 # What we are doing is the following:
56 # 1. Setting SUID or SGID fails with EPERM.
57 # 2. Modifying ACL does not clear SUID nor SGID bits.
58 # 3. Writing the file does clear both SUID and SGID bits.
59 #
60 # Check whether user 65534 is denied to write mode with SUID bit.
61 expect 0 create ${n0} 0755
62 expect EPERM -u 65534 -g 65534 chmod ${n0} 04777
63 expect 0 prependacl ${n0} user:65534:write_acl::allow
64 expect EPERM -u 65534 -g 65534 chmod ${n0} 04777
65 expect 0 unlink ${n0}
66
67 # Check whether user 65534 is denied to write mode with SGID bit.
68 expect 0 create ${n0} 0755
69 expect EPERM -u 65534 -g 65534 chmod ${n0} 02777
70 expect 0 prependacl ${n0} user:65534:write_acl::allow
71 expect EPERM -u 65534 -g 65534 chmod ${n0} 02777
72 expect 0 unlink ${n0}
73
74 # Check whether user 65534 is allowed to write mode with sticky bit.
75 expect 0 mkdir ${n0} 0755
76 expect EPERM -u 65534 -g 65534 chmod ${n0} 01777
77 expect 0 prependacl ${n0} user:65534:write_acl::allow
78 expect 0 -u 65534 -g 65534 chmod ${n0} 01777
79 expect 0 rmdir ${n0}
80
81 # Check whether modifying the ACL by not-owner preserves the SUID.
82 expect 0 create ${n0} 04755
83 expect 0 prependacl ${n0} user:65534:write_acl::allow
84 expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow
85 expect 04755 stat ${n0} mode
86 expect 0 unlink ${n0}
87
88 # Check whether modifying the ACL by not-owner preserves the SGID.
89 expect 0 create ${n0} 02755
90 expect 0 prependacl ${n0} user:65534:write_acl::allow
91 expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow
92 expect 02755 stat ${n0} mode
93 expect 0 unlink ${n0}
94
95 # Check whether modifying the ACL by not-owner preserves the sticky bit.
96 expect 0 mkdir ${n0} 0755
97 expect 0 chmod ${n0} 01755
98 expect 0 prependacl ${n0} user:65534:write_acl::allow
99 expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow
100 expect 01755 stat ${n0} mode
101 expect 0 rmdir ${n0}
102
103 # Clearing the SUID and SGID bits when being written to by non-owner
104 # is checked in chmod/12.t.
105
106 # Check whether the file owner is always permitted to get and set
107 # ACL and file mode, even if ACL_{READ,WRITE}_ACL would deny it.
108 expect 0 chmod . 0777
109 expect 0 -u 65534 -g 65534 create ${n0} 0600
110 expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_acl::deny
111 expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_acl::deny
112 expect 0 -u 65534 -g 65534 readacl ${n0}
113 expect 0600 -u 65534 -g 65534 stat ${n0} mode
114 expect 0 -u 65534 -g 65534 chmod ${n0} 0777
115 expect 0 unlink ${n0}
116
117 expect 0 -u 65534 -g 65534 mkdir ${n0} 0600
118 expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_acl::deny
119 expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_acl::deny
120 expect 0 -u 65534 -g 65534 readacl ${n0}
121 expect 0600 -u 65534 -g 65534 stat ${n0} mode
122 expect 0 -u 65534 -g 65534 chmod ${n0} 0777
123 expect 0 rmdir ${n0}
124
125 # Check whether the root is allowed for these as well.
126 expect 0 -u 65534 -g 65534 create ${n0} 0600
127 expect 0 prependacl ${n0} everyone@:write_acl::deny
128 expect 0 prependacl ${n0} everyone@:read_acl::deny
129 expect 0 readacl ${n0}
130 expect 0600 stat ${n0} mode
131 expect 0 chmod ${n0} 0777
132 expect 0 unlink ${n0}
133
134 expect 0 -u 65534 -g 65534 mkdir ${n0} 0600
135 expect 0 prependacl ${n0} everyone@:write_acl::deny
136 expect 0 prependacl ${n0} everyone@:read_acl::deny
137 expect 0600 stat ${n0} mode
138 expect 0 readacl ${n0}
139 expect 0600 stat ${n0} mode
140 expect 0 chmod ${n0} 0777
141 expect 0 rmdir ${n0}
142
143 cd ${cdir}
144 expect 0 rmdir ${n2}