5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/tests
/functional
/acl
/acl_common.kshlib
36 # Verify that the write_xattr for remove the extended attributes of
37 # owner/group/everyone are correct.
40 # 1. Create file and directory in zfs filesystem
41 # 2. Set special write_xattr ACE to the file and directory
42 # 3. Try to remove the extended attributes of the file and directory
43 # 4. Verify above operation is successful.
46 verify_runnable
"both"
52 cleanup_test_files
$TESTDIR/basedir
54 if [[ -e $TESTDIR/$ARCHIVEFILE ]]; then
55 log_must
rm -f $TESTDIR/$ARCHIVEFILE
61 # owner@ group group_users other_users
63 "root" "root" "$ZFS_ACL_ADMIN" "$ZFS_ACL_OTHER1" \
64 "$ZFS_ACL_STAFF1" "$ZFS_ACL_STAFF_GROUP" "$ZFS_ACL_STAFF2" \
71 set -A a_flag
"owner@" "group@" "everyone@"
73 MYTESTFILE
=/etc
/passwd
75 log_assert
"Verify that the permission of write_xattr for " \
76 "owner/group/everyone while remove extended attributes are correct."
79 function operate_node
#user node acl
86 if [[ $user == "" ||
$node == "" ]]; then
87 log_fail
"user, node are not defined."
90 chgusr_exec
$user runat
$node rm -f attr
.0 ; ret
=$?
92 if [[ $ret -eq 0 ]]; then
93 log_must cleanup_test_files
$TESTDIR/basedir
94 log_must
tar xpf@
$TESTDIR/$ARCHIVEFILE
100 function logname
#acl_target owner user
102 typeset acl_target
=$1
105 typeset ret
="log_mustnot"
107 # To super user, read and write deny permission was override.
108 if [[ $user == root ||
$owner == $user ]] then
115 function check_chmod_results
#node flag acl_target owner g_usr o_usr
119 typeset acl_target
=$2:$3
125 if [[ $flag == "owner@" ||
$flag == "everyone@" ]]; then
126 log
=$
(logname
$acl_target $owner $ZFS_ACL_CUR_USER)
127 $log operate_node
$ZFS_ACL_CUR_USER $node $acl_target
129 if [[ $flag == "group@" ||
$flag == "everyone@" ]]; then
130 log
=$
(logname
$acl_target $owner $g_usr)
131 $log operate_node
$g_usr $node $acl_target
133 if [[ $flag == "everyone@" ]]; then
134 log
=$
(logname
$acl_target $owner $o_usr)
135 $log operate_node
$o_usr $node $acl_target
139 function test_chmod_basic_access
#node owner g_usr o_usr
145 typeset flag acl_p acl_t parent
149 for flag
in ${a_flag[@]}; do
150 for acl_t
in "${a_access[@]}"; do
151 log_must usr_exec
chmod A
+$flag:$acl_t $node
153 log_must
tar cpf@
$TESTDIR/$ARCHIVEFILE basedir
155 check_chmod_results
"$node" "$flag" \
156 "$acl_t" "$owner" "$g_usr" "$o_usr"
158 log_must usr_exec
chmod A0-
$node
163 function setup_test_files
#base_node user group
169 cleanup_test_files
$base_node
171 log_must mkdir
-p $base_node
172 log_must chown
$user:$group $base_node
174 log_must set_cur_usr
$user
176 # Prepare all files/sub-dirs for testing.
178 file0
=$base_node/testfile_rm
180 dir0
=$base_node/testdir_rm
182 log_must usr_exec
touch $file0
183 log_must usr_exec
chmod 444 $file0
185 log_must usr_exec runat
$file0 cp $MYTESTFILE attr
.0
187 log_must usr_exec mkdir
-p $dir0
188 log_must usr_exec
chmod 555 $dir0
190 log_must usr_exec runat
$dir0 cp $MYTESTFILE attr
.0
192 log_must usr_exec
chmod 555 $base_node
196 function cleanup_test_files
#base_node
200 if [[ -d $base_node ]]; then
201 log_must
rm -rf $base_node
202 elif [[ -e $base_node ]]; then
203 log_must
rm -f $base_node
210 typeset ARCHIVEFILE
=archive.
tar
216 while (( i
< ${#users[@]} )); do
217 setup_test_files
$TESTDIR/basedir
${users[i]} ${users[((i+1))]}
221 while (( j
< 1 )); do
223 test_chmod_basic_access
$target ${users[i]} \
224 "${users[((i+2))]}" "${users[((i+3))]}"
227 test_chmod_basic_access
$target ${users[i]} \
228 "${users[((i+2))]}" "${users[((i+3))]}"
236 log_pass
"Verify that the permission of write_xattr for " \
237 "owner/group/everyone while remove extended attributes are correct."