1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # NFSv4 ACL attributes:
27 #
28 # a: Test set ACL flag attr ACE4_NO_PROPAGATE_INHERIT_ACE; expect ATTRNOTSUPP
29 # b: Test set ACL flag attr ACE4_SUCCESSFUL_ACCESS_ACE_FLAG; expect ATTRNOTSUPP
30 # c: Test set ACL flag attr ACE4_FAILED_ACCESS_ACE_FLAG; expect ATTRNOTSUPP
31 #
32
33 set TESTROOT $env(TESTROOT)
34
35 # include common code and init section
36 source [file join ${TESTROOT} tcl.init]
37 source [file join ${TESTROOT} testproc]
38 source [file join ${TESTROOT} acltools]
39
40 # connect to the test server
41 Connect
42
43 # setting local variables
44 set TNAME $argv0
45
46 # Set params relating to test file
47 set filename "newfile.[pid]"
48 set fpath [file join ${BASEDIR} ${filename}]
49
50 # Create the test file and get its handle.
51 set tfh "[creatv4_file $fpath 777]"
52 if {$tfh == $NULL} {
53 putmsg stdout 0 "$TNAME: test setup"
54 putmsg stderr 0 "\t Test UNRESOLVED: failed to create tmp file=($filename)"
55 putmsg stderr 0 "\t\t status=($status)."
56 Disconnect
57 exit $UNRESOLVED
58 }
59
60 # Get handle for base directory
61 set bfh [get_fh "$BASEDIRS"]
62
63
64 # Start testing
65 # ---------------------------------------------------------------
66 #a: Test set ACL flag attr ACE4_NO_PROPAGATE_INHERIT_ACE
67 # expect ATTRNOTSUPP for UFS
68 # expect OK for ZFS
69
70 if $IsZFS {
71 set expcode "INVAL"
72 } else {
73 set expcode "ATTRNOTSUPP"
74 }
75 set tag "$TNAME{a}"
76 set ASSERTION "Test set ACL flag attr ACE4_NO_PROPAGATE_INHERIT_ACE, expect $expcode"
77 putmsg stdout 0 "$tag: $ASSERTION"
78
79 set ACE4_NO_PROPAGATE_INHERIT_ACE 4
80 set sid {0 0}
81
82 # get the initial ACL settings.
83 set initial_acl [compound {Putfh $tfh; \
84 Getattr acl }]
85
86 ckres "Getattr acl" $status "OK" $initial_acl $FAIL
87
88 #
89 # Break the string returned from the Geattr acl command into
90 # a list and then extract the actual ACL settings.
91 #
92 set acl_list [extract_acl_list $initial_acl]
93 putmsg stderr 1 "$tag: initial ACL : $acl_list"
94
95 # Create the new ACL settings by replacing the appropriate entries.
96 #
97 # Order of entries in the list is as follows:
98 # <OWNER><OWNER><GROUP><GROUP><GROUP><EVERYONE><EVERYONE>
99 #
100 # The <OWNER> block is itself composed of 4 fields <type><flag><mask><who>
101 # so we need to extract the <type> field and replace it with the TYPE we
102 # are testing.
103 #
104 set owner [lindex $acl_list 0]
105 set new_owner [lreplace [split $owner] 1 1 "$ACE4_NO_PROPAGATE_INHERIT_ACE"]
106
107 # Replace the original OWNER block with the one we have modified.
108 set acl_list [lreplace $acl_list 0 0 $new_owner]
109 putmsg stderr 1 "$tag: new ACL : $acl_list"
110
111 # Attempt to set the new ACL values, expect this to fail.
112 set res [compound {Putfh $tfh; \
113 Setattr $sid { {acl \
114 { $acl_list } } } } ]
115
116 ckres "Setattr" $status $expcode $res $PASS
117
118 puts ""
119
120 # ---------------------------------------------------------------
121 #b: Test set ACL flag attr ACE4_SUCCESSFUL_ACCESS_ACE_FLAG expect ATTRNOTSUPP
122
123 set tag "$TNAME{b}"
124 set ASSERTION "Test set ACL flag attr ACE4_SUCCESSFUL_ACCESS_ACE_FLAG, expect ATTRNOTSUPP"
125 putmsg stdout 0 "$tag: $ASSERTION"
126
127 set ACE4_SUCCESSFUL_ACCESS_ACE_FLAG 10
128 set sid {0 0}
129
130 # get the initial ACL settings.
131 set expcode "OK"
132 set initial_acl [compound {Putfh $tfh; \
133 Getattr acl }]
134
135 ckres "Getattr acl" $status $expcode $initial_acl $FAIL
136
137 #
138 # Break the string returned from the Geattr acl command into
139 # a list and then extract the actual ACL settings.
140 #
141 set acl_list [extract_acl_list $initial_acl]
142 putmsg stderr 1 "$tag: initial ACL : $acl_list"
143
144 # Create the new ACL settings by replacing the appropriate entries.
145 #
146 # Order of entries in the list is as follows:
147 # <OWNER><OWNER><GROUP><GROUP><GROUP><EVERYONE><EVERYONE>
148 #
149 # The <OWNER> block is itself composed of 4 fields <type><flag><mask><who>
150 # so we ned to extract the <type> field and replace it with the TYPE we
151 # are testing.
152 #
153 set owner [lindex $acl_list 0]
154 set new_owner [lreplace [split $owner] 1 1 "$ACE4_SUCCESSFUL_ACCESS_ACE_FLAG"]
155
156 # Replace the original OWNER block with the one we have modified.
157 set acl_list [lreplace $acl_list 0 0 $new_owner]
158 putmsg stderr 1 "$tag: new ACL : $acl_list"
159
160 # Attempt to set the new ACL values, expect this to fail.
161 set expcode "ATTRNOTSUPP"
162 set res [compound {Putfh $tfh; \
163 Setattr $sid { {acl \
164 { $acl_list } } } } ]
165
166 ckres "Setattr" $status $expcode $res $PASS
167
168 puts ""
169
170 # ---------------------------------------------------------------
171 #c: Test set ACL flag attr ACE4_FAILED_ACCESS_ACE_FLAG expect ATTRNOTSUPP
172
173 set tag "$TNAME{c}"
174 set ASSERTION "Test set ACL flag attr ACE4_FAILED_ACCESS_ACE_FLAG, expect ATTRNOTSUPP"
175 putmsg stdout 0 "$tag: $ASSERTION"
176
177 set ACE4_FAILED_ACCESS_ACE_FLAG 20
178 set sid {0 0}
179
180 # get the initial ACL settings.
181 set expcode "OK"
182 set initial_acl [compound {Putfh $tfh; \
183 Getattr acl }]
184
185 ckres "Getattr acl" $status $expcode $initial_acl $FAIL
186
187 #
188 # Break the string returned from the Geattr acl command into
189 # a list and then extract the actual ACL settings.
190 #
191 set acl_list [extract_acl_list $initial_acl]
192 putmsg stderr 1 "$tag: initial ACL : $acl_list"
193
194 # Create the new ACL settings by replacing the appropriate entries.
195 #
196 # Order of entries in the list is as follows:
197 # <OWNER><OWNER><GROUP><GROUP><GROUP><EVERYONE><EVERYONE>
198 #
199 # The <OWNER> block is itself composed of 4 fields <type><flag><mask><who>
200 # so we ned to extract the <type> field and replace it with the TYPE we
201 # are testing.
202 #
203 set owner [lindex $acl_list 0]
204 set new_owner [lreplace [split $owner] 1 1 "$ACE4_FAILED_ACCESS_ACE_FLAG"]
205
206 # Replace the original OWNER block with the one we have modified.
207 set acl_list [lreplace $acl_list 0 0 $new_owner]
208 putmsg stderr 1 "$tag: new ACL : $acl_list"
209
210 # Attempt to set the new ACL values, expect this to fail.
211 set expcode "ATTRNOTSUPP"
212 set res [compound {Putfh $tfh; \
213 Setattr $sid { {acl \
214 { $acl_list } } } } ]
215
216 ckres "Setattr" $status $expcode $res $PASS
217
218 puts ""
219
220 #
221 # Cleanup
222 #
223 set tag "$TNAME-cleanup"
224 set res2 [compound {Putfh $bfh; Remove $filename}]
225 if {$status != "OK"} {
226 putmsg stderr 0 "\t WARNING: cleanup to remove created tmp file failed"
227 putmsg stderr 0 "\t status=$status; please cleanup manually."
228 putmsg stderr 1 "\t res=($res2)"
229 putmsg stderr 1 " "
230 Disconnect
231 exit $WARNING
232 }
233
234 Disconnect
235 exit $PASS