#
# 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) 2016 by Delphix. All rights reserved.
#
#
# DESCRIPTION:
# chmod A{+|-|=} read_data|write_data|execute for owner@ group@ or
# everyone@ correctly alters mode bits .
#
# STRATEGY:
# 1. Loop root and non-root user.
# 2. Get the random initial map.
# 3. Get the random ACL string.
# 4. Separately chmod +|-|= read_data|write_data|execute
# 5. Check map bits
#
verify_runnable "both"
log_assert "chmod A{+|-|=} read_data|write_data|execute for owner@, group@ " \
"or everyone@ correctly alters mode bits."
#
# Get a random item from an array.
#
# $1 the base set
#
{
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
#
{
typeset arr_name=$1
typeset -i count=${2:-1}
typeset str=""
done
print $str
}
#
# According to the original bits, the input ACE access and ACE type, return the
# expect bits after 'chmod A0{+|=}'.
#
# $1 bits which was make up of three bit 'rwx'
# $2 ACE access which is read_data, write_data or execute
# $3 ACE type which is allow or deny
#
{
typeset bits=$1
typeset acl_access=$2
typeset acl_type=$3
set -A bit r w x
typeset tmpbits=""
typeset -i i=0
while (( i < 3 )); do
tmpbits="${tmpbits}-"
fi
else
fi
(( i += 1 ))
done
echo "$tmpbits"
}
#
# Based on the initial node map before chmod and the ace-spec, check if chmod
# has the correct behaven to map bits.
#
{
typeset init_mode=$1
typeset node=$2
typeset acl_flag=$3
typeset acl_access=$4
typeset acl_type=$5
typeset -L3 u_bits=$init_mode
typeset -R3 o_bits=$init_mode
fi
fi
fi
else
fi
}
{
typeset node=$1
typeset init_mask acl_flag acl_access acl_type
typeset -i cnt
if (( ${#node} == 0 )); then
log_fail "FAIL: file name or directory name is not defined."
fi
# Get the initial map
init_mask=$(form_random_str bits 3)
# Get ACL flag, access & type
acl_access=${acl_access%/}
typeset acl_spec=${acl_flag}@:${acl_access}:${acl_type}
# Set the initial map and back the initial ACEs
# To "A=", firstly add one ACE which can't modify map
fi
# Check "chmod A-"
"original ACEs. 'chmod A-' succeeded."
else
log_fail "FAIL: 'chmod A-' failed."
fi
done
}
for user in root $ZFS_ACL_STAFF1; do
typeset -i loop_cnt=20
done
done
"or everyone@ correctly alters mode bits passed."