#
# 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 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
#
# DESCRIPTION:
# chmod A{+|-|=} could set compact ACL correctly.
#
# STRATEGY:
# 1. Loop root and non-root user.
# 2. Get the random compact ACL string.
# 4. Separately chmod +|-|=
# 5. Check compact ACL display as expected
#
verify_runnable "both"
log_assert "chmod A{+|=} should set compact ACL correctly."
#
# Get a random item from an array.
#
# $1 the base set
#
function random_select
{
typeset arr_name=$1
typeset -i ind
eval typeset -i cnt=\${#${arr_name}[@]}
}
#
# Create a random string according to array name, the item number and
# separated tag.
#
# $1 array name where the function get the elements
# $2 the items number which you want to form the random string
# $3 the separated tag
#
function form_random_str
{
typeset arr_name=$1
typeset -i count=${2:-1}
typeset str=""
done
print $str
}
#
# According to the input ACE access,ACE type, and inherit flags, return the
# expect compact ACE that could be used by chmod A0{+|=}'.
#
# $1 ACE flag which is owner, group, or everyone
# $2 ACE access generated by the element of a_access
# $3 ACE inherit_object generated by the element of a_inherit_object
# $4 ACE inherit_strategy generated by the element of a_inherit_strategy
# $5 ACE type which is allow or deny
#
function cal_ace
{
typeset acl_flag=$1
typeset acl_access=$2
typeset acl_inherit_object=$3
typeset acl_inherit_strategy=$4
typeset acl_type=$5
tmp_ace="${tmp_ace}${element}"
else
tmp_ace="${tmp_ace}-"
fi
done
for element in ${a_inherit_object[@]} ; do
tmp_ace="${tmp_ace}${element}"
else
tmp_ace="${tmp_ace}-"
fi
done
for element in ${a_inherit_strategy[@]} ; do
tmp_ace="${tmp_ace}${element}"
else
tmp_ace="${tmp_ace}-"
fi
done
echo "${tmp_ace}"
}
#
# Check if chmod set the compact ACE correctly.
#
function check_test_result
{
typeset node=$1
typeset acl_flag=$2
typeset acl_access=$3
typeset acl_inherit_object=$4
typeset acl_inherit_strategy=$5
typeset acl_type=$6
if [[ $cur_ace != $expect_ace ]]; then
expected ace($expect_ace)"
fi
}
function test_chmod_map
{
typeset node=$1
typeset -i cnt
if ((${#node} == 0)); then
log_fail "FAIL: file name or directroy name is not defined."
fi
# Get ACL flag, access & type
acl_access=${acl_access%/}
acl_spec=${acl_flag}@:${acl_access}
if [[ -d $node ]]; then
# Get ACL inherit_object & inherit_strategy
fi
# Set the initial map and back the initial ACEs
# To "A=", firstly add one ACE which can't modify map
fi
# Check "chmod A-"
done
}
for user in root $ZFS_ACL_STAFF1; do
typeset -i loop_cnt=2
done
done
log_pass "chmod A{+|=} set compact ACL correctly."