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 assigned read_acl/write_acl to owner@/group@/everyone@,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# specificied user and group. File have the correct access permission.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Separatedly verify file and directory was assigned read_acl/write_acl
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# by root and non-root user.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Verify owner always can read and write acl, even deny.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Verify group access permission, when group was assigned
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 4. Verify access permission, after everyone was assigned read_acl/write.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 5. Verify everyone@ was deny except specificied user, this user can read
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and write acl.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 6. Verify the group was deny except specified user, this user can read
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and write acl
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Verify chmod A[number]{+|-|=} read_acl/write_acl have correct " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "behaviour to access permission."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfunction read_ACL #<node> <user1> <user2> ...
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy chgusr_exec $user ls -vd $node > /dev/null 2>&1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfunction write_ACL #<node> <user1> <user2> ...
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy chgusr_exec $user chmod A0+owner@:read_data:allow $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if (( after_cnt - before_cnt != 1 )); then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy chmod A0+owner@:read_acl/write_acl:$acc $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_must write_ACL $node $ZFS_ACL_CUR_USER
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $ZFS_ACL_CUR_USER == root ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy elif [[ $ZFS_ACL_CUR_USER == $ZFS_ACL_STAFF1 ]]; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec chmod A0+group@:read_acl/write_acl:allow $node
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec chmod A0+group@:read_acl/write_acl:deny $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $flag == allow ]]; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy chmod A0+everyone@:read_acl/write_acl:$flag $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy $log read_ACL $node $ZFS_ACL_OTHER1 $ZFS_ACL_OTHER2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy $log write_ACL $node $ZFS_ACL_OTHER1 $ZFS_ACL_OTHER2
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec chmod A0+everyone@:read_acl/write_acl:deny $node
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy chmod A0+user:$ZFS_ACL_OTHER1:read_acl/write_acl:allow $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # The specified user can read and write acl
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # All the other user can't read and write acl
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy read_ACL $node $ZFS_ACL_ADMIN $ZFS_ACL_STAFF2 $ZFS_ACL_OTHER2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy write_ACL $node $ZFS_ACL_ADMIN $ZFS_ACL_STAFF2 $ZFS_ACL_OTHER2
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec chmod A0+everyone@:read_acl/write_acl:deny $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy A0+group:$ZFS_ACL_OTHER_GROUP:read_acl/write_acl:allow $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # The specified group can read and write acl
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_must read_ACL $node $ZFS_ACL_OTHER1 $ZFS_ACL_OTHER2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_must write_ACL $node $ZFS_ACL_OTHER1 $ZFS_ACL_OTHER2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # All the other user can't read and write acl
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_mustnot read_ACL $node $ZFS_ACL_ADMIN $ZFS_ACL_STAFF2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_mustnot write_ACL $node $ZFS_ACL_ADMIN $ZFS_ACL_STAFF2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy A0+group:$ZFS_ACL_OTHER_GROUP:read_acl/write_acl:deny $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy A0+user:$ZFS_ACL_OTHER1:read_acl/write_acl:allow $node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_mustnot read_ACL $node $ZFS_ACL_OTHER2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_mustnot write_ACL $node $ZFS_ACL_OTHER2
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec rm -rf $testfile $testdir
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_pass "Verify chmod A[number]{+|-|=} read_acl/write_acl passed."