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# ident "@(#)zfs_acl_chmod_001_pos.ksh 1.5 09/01/13 SMI" 28# 29 30. $STF_SUITE/tests/acl/acl_common.kshlib 31 32################################################################################# 33# 34# __stc_assertion_start 35# 36# ID: zfs_acl_chmod_001_pos 37# 38# DESCRIPTION: 39# Verify chmod permission settings on files and directories, as both root 40# and non-root users. 41# 42# STRATEGY: 43# 1. Loop root and $ZFS_ACL_STAFF1 as root and non-root users. 44# 2. Create test file and directory in zfs filesystem. 45# 3. Execute 'chmod' with specified options. 46# 4. Check 'ls -l' output and compare with expect results. 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2005-09-27) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "both" 59 60# "init_map" "options" "expect_map" 61set -A argv \ 62 "000" "a+rw" "rw-rw-rw-" "000" "a+rwx" "rwxrwxrwx" \ 63 "000" "u+xr" "r-x------" "000" "gu-xw" "---------" \ 64 "644" "a-r" "-w-------" "644" "augo-x" "rw-r--r--" \ 65 "644" "=x" "--x--x--x" "644" "u-rw" "---r--r--" \ 66 "644" "uo+x" "rwxr--r-x" "644" "ga-wr" "---------" \ 67 "777" "augo+x" "rwxrwxrwx" "777" "go-xr" "rwx-w--w-" \ 68 "777" "o-wx" "rwxrwxr--" "777" "ou-rx" "-w-rwx-w-" \ 69 "777" "a+rwx" "rwxrwxrwx" "777" "u=rw" "rw-rwxrwx" \ 70 "000" "123" "--x-w--wx" "000" "412" "r----x-w-" \ 71 "231" "562" "r-xrw--w-" "712" "000" "---------" \ 72 "777" "121" "--x-w---x" "123" "775" "rwxrwxr-x" 73 74log_assert " Verify chmod permission settings on files and directories" 75log_onexit cleanup 76 77# 78# Verify file or directory have correct map after chmod 79# 80# $1 file or directory 81# 82function test_chmod_mapping #<file-dir> 83{ 84 typeset node=$1 85 typeset -i i=0 86 87 while (( i < ${#argv[@]} )); do 88 usr_exec $CHMOD ${argv[i]} $node 89 if (($? != 0)); then 90 log_note "usr_exec $CHMOD ${argv[i]} $node" 91 return 1 92 fi 93 94 usr_exec $CHMOD ${argv[((i + 1))]} $node 95 if (($? != 0)); then 96 log_note "usr_exec $CHMOD ${argv[((i + 1))]} $node" 97 return 1 98 fi 99 100 typeset mode 101 mode=$(get_mode ${node}) 102 103 if [[ $mode != "-${argv[((i + 2))]}"* && \ 104 $mode != "d${argv[((i + 2))]}"* ]] 105 then 106 log_fail "FAIL: '${argv[i]}' '${argv[((i + 1))]}' \ 107 '${argv[((i + 2))]}'" 108 fi 109 110 (( i += 3 )) 111 done 112 113 return 0 114} 115 116for user in root $ZFS_ACL_STAFF1; do 117 log_must set_cur_usr $user 118 119 # Test file 120 log_must usr_exec $TOUCH $testfile 121 log_must test_chmod_mapping $testfile 122 123 if [ "$ZFS_ACL" != "" ] ; then 124 log_must $CHMOD A+user:$ZFS_ACL_STAFF2:write_acl:allow $testfile 125 fi 126 log_must set_cur_usr $ZFS_ACL_STAFF2 127 128 # Test directory 129 log_must usr_exec $MKDIR $testdir 130 log_must test_chmod_mapping $testdir 131 132 if [ "$ZFS_ACL" != "" ] ; then 133 # Grant privileges of write_acl and retest the chmod commands. 134 acl="user:$ZFS_ACL_STAFF2:write_acl:allow" 135 log_must usr_exec $CHMOD A+${acl} $testfile 136 log_must usr_exec $CHMOD A+${acl} $testdir 137 138 log_must set_cur_usr $ZFS_ACL_STAFF2 139 log_must test_chmod_mapping $testfile 140 log_must test_chmod_mapping $testdir 141 fi 142 143 log_must set_cur_usr $user 144 145 log_must usr_exec $RM $testfile 146 log_must usr_exec $RM -rf $testdir 147done 148 149log_pass "Setting permissions using 'chmod' completed successfully." 150