1#!/usr/local/bin/ksh93 -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/tests/acl/acl_common.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: zfs_acl_chmod_001_neg 34# 35# DESCRIPTION: 36# Verify 1) Illegal options to chmod should fail. 37# 2) Delete all the ACE will lead to fail. 38# 3) Add ACE exceed 1024 will cause to fail. 39# 40# STRATEGY: 41# 1. Loop root and non-root users 42# 2. Verify all kinds of illegal option will lead to chmod failed. 43# 3. Verify 'chmod A0-' will fail when try to delete all the ACE. 44# 4. Verify 'chmod A+' will succeed when the ACE number exceed 1024. 45# 46# TESTABILITY: explicit 47# 48# TEST_AUTOMATION_LEVEL: automated 49# 50# CODING_STATUS: COMPLETED (2005-10-14) 51# 52# __stc_assertion_end 53# 54################################################################################ 55 56verify_runnable "both" 57 58log_assert "Verify illegal operating to ACL, it will fail." 59log_onexit cleanup 60 61test_requires ZFS_ACL 62 63function err_opts #node 64{ 65 typeset A_opts="+A@ -A#- +A% =A^ =A# =A@ +A#\ asd \ 66 A+@ A-#- A+% A=^ A=# A=@ A+#" 67 68 log_note "Illegal option to chmod should fail." 69 for A in ${A_opts[@]}; do 70 log_mustnot usr_exec $CHMOD ${A}owner@:read_data:allow $node 71 log_mustnot usr_exec $CHMOD A+ asd owner@:execute:deny $node 72 done 73 74 typeset type_opts="everyone groups owner user@ users" 75 for tp in ${type_opts[@]}; do 76 log_mustnot usr_exec $CHMOD A+$tp:read_data:deny $node 77 done 78 79 return 0 80} 81 82function del_all_ACE #node 83{ 84 typeset node=$1 85 typeset -i cnt 86 87 cnt=$(count_ACE $node) 88 while (( cnt > 0 )); do 89 if (( cnt == 1 )); then 90 log_mustnot $CHMOD A0- $node 91 else 92 log_must $CHMOD A0- $node 93 fi 94 95 (( cnt -= 1 )) 96 done 97 98 return 0 99} 100 101function exceed_max_ACE #node 102{ 103 typeset node=$1 104 typeset -i max=1024 105 typeset -i cnt 106 107 cnt=$(count_ACE $node) 108 109 # One more ACE exceed the max limitation. 110 (( max = max - cnt + 1 )) 111 while (( max > 0 )); do 112 if (( max == 1 )); then 113 log_mustnot $CHMOD A+owner@:read_data:allow $node 114 else 115 $CHMOD A+owner@:read_data:allow $node 116 if (($? != 0)); then 117 ((cnt = 1024 - max)) 118 log_fail "Add No.$cnt ACL item failed." 119 fi 120 fi 121 122 (( max -= 1 )) 123 done 124 125 return 0 126} 127 128typeset node 129typeset func_name="err_opts del_all_ACE exceed_max_ACE" 130 131for usr in "root" "$ZFS_ACL_STAFF1"; do 132 log_must set_cur_usr $usr 133 134 for node in $testfile $testdir; do 135 log_must usr_exec $TOUCH $testfile 136 log_must usr_exec $MKDIR $testdir 137 138 for func in $func_name; do 139 log_must eval "$func $node" 140 done 141 142 log_must usr_exec $RM -rf $testfile $testdir 143 done 144done 145 146log_pass "Verify illegal operating to ACL passed." 147