d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2016 by Delphix. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/acl/acl_common.kshlib
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Verify that the write_xattr for remove the extended attributes of
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Create file and directory in zfs filesystem
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Set special write_xattr ACE to the file and directory
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Try to remove the extended attributes of the file and directory
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 4. Verify above operation is successful.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -e $TESTDIR/$ARCHIVEFILE ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# owner@ group group_users other_users
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "root" "root" "$ZFS_ACL_ADMIN" "$ZFS_ACL_OTHER1" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "$ZFS_ACL_STAFF1" "$ZFS_ACL_STAFF_GROUP" "$ZFS_ACL_STAFF2" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "write_xattr:allow" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "write_xattr:deny"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyset -A a_flag "owner@" "group@" "everyone@"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Verify that the permission of write_xattr for " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "owner/group/everyone while remove extended attributes are correct."
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy chgusr_exec $user runat $node rm -f attr.0 ; ret=$?
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $ret -eq 0 ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_must cleanup_test_files $TESTDIR/basedir
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # To super user, read and write deny permission was override.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $user == root || $owner == $user ]] then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfunction check_chmod_results #node flag acl_target owner g_usr o_usr
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $flag == "owner@" || $flag == "everyone@" ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log=$(logname $acl_target $owner $ZFS_ACL_CUR_USER)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy $log operate_node $ZFS_ACL_CUR_USER $node $acl_target
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $flag == "group@" || $flag == "everyone@" ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy $log operate_node $g_usr $node $acl_target
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy $log operate_node $o_usr $node $acl_target
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfunction test_chmod_basic_access #node owner g_usr o_usr
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy typeset node=${1%/}
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec chmod A+$flag:$acl_t $node
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must tar cpf@ $TESTDIR/$ARCHIVEFILE basedir
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfunction setup_test_files #base_node user group
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec runat $file0 cp $MYTESTFILE attr.0
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec runat $dir0 cp $MYTESTFILE attr.0
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -d $base_node ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy elif [[ -e $base_node ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy setup_test_files $TESTDIR/basedir ${users[i]} ${users[((i+1))]}
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy test_chmod_basic_access $target ${users[i]} \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy test_chmod_basic_access $target ${users[i]} \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_pass "Verify that the permission of write_xattr for " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "owner/group/everyone while remove extended attributes are correct."