da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER START
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Common Development and Distribution License (the "License").
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# You may not use this file except in compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# DESCRIPTION:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# chmod A{+|-|=} could set compact ACL correctly.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# STRATEGY:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# 1. Loop root and non-root user.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# 2. Get the random compact ACL string.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# 4. Separately chmod +|-|=
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# 5. Check compact ACL display as expected
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinlog_assert "chmod A{+|=} should set compact ACL correctly."
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypeset a_access=('r' 'w' 'x' 'p' 'd' 'D' 'a' 'A' 'R' 'W' 'c' 'C' 'o' 's')
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Get a random item from an array.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# $1 the base set
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin typeset -i ind
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin eval print \${${arr_name}[$ind]}
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# Create a random string according to array name, the item number and
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# separated tag.
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz# $1 array name where the function get the elements
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# $2 the items number which you want to form the random string
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz# $3 the separated tag
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz typeset -i count=${2:-1}
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz# According to the input ACE access,ACE type, and inherit flags, return the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# expect compact ACE that could be used by chmod A0{+|=}'.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# $1 ACE flag which is owner, group, or everyone
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# $2 ACE access generated by the element of a_access
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# $3 ACE inherit_object generated by the element of a_inherit_object
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# $4 ACE inherit_strategy generated by the element of a_inherit_strategy
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# $5 ACE type which is allow or deny
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for element in ${a_access[@]} ; do
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for element in ${a_inherit_object[@]} ; do
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for element in ${a_inherit_strategy[@]} ; do
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Check if chmod set the compact ACE correctly.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin typeset node=$1
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin typeset expect_ace=$(cal_ace "$acl_flag" "$acl_access" \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin "$acl_inherit_object" "$acl_inherit_strategy" "$acl_type")
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if [[ $cur_ace != $expect_ace ]]; then
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin expected ace($expect_ace)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin typeset node=$1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin typeset acl_flag acl_access acl_inherit_object acl_inherit_strategy \
typeset -i cnt
acl_access=${acl_access%/}
acl_spec=${acl_flag}@:${acl_access}
if [[ -d $node ]]; then
for user in root $ZFS_ACL_STAFF1; do
typeset -i loop_cnt=2