zfs_acl_chmod_inherit_002_pos.ksh revision 1d32ba663e202c24a5a1f2e5aef83fffb447cb7f
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
#
# DESCRIPTION:
# Verify chmod have correct behaviour to directory and file when
# filesystem has the different aclinherit setting
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Separately chmod basedir with different inherite options,
# combine with the variable setting of aclinherit:
# "discard", "noallow", "restricted" or "passthrough".
# 4. Then create nested directories and files like the following.
#
# ofile
# odir
# chmod --> basedir -|
# |_ nfile1
# |_ ndir1 _
# |_ nfile2
# |_ ndir2 _
# |_ nfile3
# |_ ndir3
#
# 5. Verify each directories and files have the correct access control
# capability.
#
verify_runnable "both"
function cleanup
{
typeset dir
# Cleanup basedir, compared file and dir.
if [[ -f $ofile ]]; then
fi
if [[ -d $dir ]]; then
fi
done
}
log_assert "Verify chmod have correct behaviour to directory and file when " \
"filesystem has the different aclinherit setting."
# Define inherit flag
typeset aclinherit_flag=(discard noallow restricted passthrough)
typeset ace_prefix1="user:$ZFS_ACL_OTHER1"
typeset ace_prefix2="user:$ZFS_ACL_OTHER2"
# Defile the based directory and file
# Define the files and directories will be created after chmod
# Verify all the node have expected correct access control
#
# According to inherited flag, verify subdirectories and files within it has
# correct inherited access control.
#
function verify_inherit #<aclinherit> <object> [strategy]
{
# Define the nodes which will be affected by inherit.
typeset inherit_nodes
typeset inherit=$1
typeset obj=$2
typeset str=$3
typeset str1="/inherited:"
# count: the ACE item to fetch
# pass: to mark if the current ACE should apply to the target
# maxnumber: predefine as 4
# passcnt: counter, if it achieves to maxnumber,
# then no additional ACE should apply.
# isinherit: indicate if the current target is in the inherit list.
# Get the files which inherited ACE.
fi
fi
# Get the directores which inherited ACE.
fi
fi
else
fi
i=0
count=0
passcnt=0
pass=0
#
# aclinherit=passthrough,
# inherit all inheritable ACL entries without any
# modifications made to the ACL entries when they
# are inherited.
#
# aclinherit=restricted,
# any inheritable ACL entries will remove
# write_acl and write_owner permissions when the ACL entry is
# inherited.
#
# aclinherit=noallow,
# only inherit inheritable ACE that specify "deny" permissions
#
# aclinherit=discard
# will not inherit any ACL entries
#
;;
;;
pass=1
fi
;;
break
;;
esac
# verify ACE's only for inherited nodes
# strip strategy flags from the expect
# value
fi
if [[ -d $node ]]; then
&& $propagate == 0 ]]; then
# prepare expect value for
# "inherit_only" nodes
acltemp_subdir=${expect1%/*}
expect1=${acltemp_subdir}${str1}
elif [[ $propagate == 1 ]]; then
# prepare expect value for
# "propagate" nodes
else
# prepare expect value for nodes
# with no starategy flags
fi
elif [[ -f $node ]]; then
fi
# Get the first ACE to do comparison
"$expect1"
fi
fi
((i = i + 1))
done
#
# If there's no any ACE be checked, it should be identify as
#
if [[ -d $node ]]; then
elif [[ -f $node ]]; then
fi
if [[ $? -ne 0 ]]; then
fi
fi
done
}
typeset -i i=0
#
# Set aclmode=passthrough to make sure
# the acl will not change during chmod.
# A general testing should verify the combination of
# aclmode/aclinherit works well,
# here we just simple test them separately.
#
#
# Set different value of aclinherit
#
((${#str} != 0)) && inh_opt=$inh_opt/$str
#
# Prepare 4 ACES, which should include :
# deny -> to verify "noallow"
# write_acl/write_owner -> to verify "restricted"
#
acl1=${ace_prefix2}":read_xattr/write_acl/"
acl2="$ace_prefix1:read_xattr:$inh_opt:deny"
acl3="$ace_prefix2:read_xattr:$inh_opt:allow"
#
# The ACE filtered by write_acl/write_owner
#
acls0="$ace_prefix1:read_xattr:$inh_opt:deny"
acls1="$ace_prefix2:read_xattr:$inh_opt:allow"
#
# for comparison.
#
i=3
while ((i >= 0)); do
#
# Place on a directory should succeed.
#
((i = i - 1))
done
done
done
done
done
log_pass "Verify chmod inherit behaviour co-op with aclinherit setting passed."