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 chmod have correct behaviour to directory and file when setting
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# different inherit strategy to them.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Loop super user and non-super user to run the test case.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Create basedir and a set of subdirectores and files within it.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Separately chmod basedir with different inherite options.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 4. Then create nested directories and files like the following.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# chmod --> basedir -|
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 5. Verify each directories and files have the correct access control
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -f $basefile ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -d $basedir ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Verify chmod have correct behaviour to directory and file when " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "setting different inherit strategies to them."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Define inherit flag
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyset -A object_flag file_inherit dir_inherit file_inherit/dir_inherit
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyset -A strategy_flag "" inherit_only no_propagate inherit_only/no_propagate
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Defile the based directory and file
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedybasedir=$TESTDIR/basedir; basefile=$TESTDIR/basefile
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Define the existed files and directories before chmod
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyodir1=$basedir/odir1; odir2=$odir1/odir2; odir3=$odir2/odir3
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyofile1=$basedir/ofile1; ofile2=$odir1/ofile2; ofile3=$odir2/ofile3
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Define the files and directories will be created after chmod
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyndir1=$basedir/ndir1; ndir2=$ndir1/ndir2; ndir3=$ndir2/ndir3
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedynfile1=$basedir/nfile1; nfile2=$ndir1/nfile2; nfile3=$ndir2/nfile3
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Verify all the node have expected correct access control
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyallnodes="$basedir $ndir1 $ndir2 $ndir3 $nfile1 $nfile2 $nfile3"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyallnodes="$allnodes $odir1 $odir2 $odir3 $ofile1 $ofile2 $ofile3"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# According to inherited flag, verify subdirectories and files within it has
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# correct inherited access control.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfunction verify_inherit #<object> [strategy]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Define the nodes which will be affected by inherit.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec touch $nfile1 $nfile2 $nfile3
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Except for inherit_only, the basedir was affected always.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy inherit_nodes="$inherit_nodes $nfile2 $nfile3"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy inherit_nodes="$inherit_nodes $ndir2 $ndir3"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ " $inherit_nodes " == *" $node "* ]]; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_mustnot chgusr_exec $ZFS_ACL_OTHER1 ls -vd $node \
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must chgusr_exec $ZFS_ACL_OTHER1 ls -vd $node \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy (( ${#str} != 0 )) && inh_opt=$inh_opt/$str
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy aclspec="A+user:$ZFS_ACL_OTHER1:read_acl:$inh_opt:deny"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec touch $ofile1 $ofile2 $ofile3
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Inherit flag can only be placed on a directory,
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec chmod $aclspec $basefile
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must usr_exec rm -rf $basefile $basedir
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_pass "Verify chmod inherit behaviour passed."