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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/tests/acl/acl_common.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: zfs_acl_mv_001_pos 33# 34# DESCRIPTION: 35# Verify that '/bin/mv' supports ZFS ACL 36# 37# STRATEGY: 38# 1. Create file and directory in zfs filesystem 39# 2. Set special ACE to the file and directory 40# 3. Copy the file/directory within and across zfs file system 41# 4. Verify that the ACL of file/directroy is not changed 42# 43# TESTABILITY: explicit 44# 45# TEST_AUTOMATION_LEVEL: automated 46# 47# CODING_STATUS: COMPLETED (2005-10-11) 48# 49# __stc_assertion_end 50# 51################################################################################ 52 53verify_runnable "both" 54 55function cleanup 56{ 57 (( ${#cwd} != 0 )) && cd $cwd 58 [[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/* 59 [[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1 60 (( ${#mask} != 0 )) && log_must $UMASK $mask 61} 62 63function testing_mv #<flag for file|dir> <file1|dir1> <file2|dir2> 64{ 65 typeset flag=$1 66 set -A obj $2 $3 67 typeset -i i=0 68 typeset orig_acl="" 69 typeset orig_mode="" 70 typeset dst_acl="" 71 typeset dst_mode="" 72 73 if [[ $flag == "f" ]]; then 74 while (( i < ${#obj[*]} )) 75 do 76 orig_acl="$(get_acl ${obj[i]})" 77 orig_mode="$(get_mode ${obj[i]})" 78 if (( i < 1 )); then 79 log_must $MV ${obj[i]} $dst_file 80 dst_acl=$(get_acl $dst_file) 81 dst_mode=$(get_mode $dst_file) 82 else 83 log_must $MV ${obj[i]} $TESTDIR1 84 dst_acl=$(get_acl $TESTDIR1/${obj[i]}) 85 dst_mode=$(get_mode $TESTDIR1/${obj[i]}) 86 fi 87 88 if [[ "$dst_mode" != "$orig_mode" ]] || \ 89 [[ "$dst_acl" != "$orig_acl" ]]; then 90 log_fail "$MV fails to keep the acl for file." 91 fi 92 93 (( i = i + 1 )) 94 done 95 else 96 while (( i < ${#obj[*]} )) 97 do 98 typeset orig_nested_acl="" 99 typeset orig_nested_mode="" 100 typeset dst_nested_acl="" 101 typeset dst_nested_mode="" 102 103 orig_acl=$(get_acl ${obj[i]}) 104 orig_mode=$(get_mode ${obj[i]}) 105 orig_nested_acl=$(get_acl ${obj[i]}/$nestedfile) 106 orig_nested_mode=$(get_mode ${obj[i]}/$nestedfile) 107 if (( i < 1 )); then 108 log_must $MV ${obj[i]} $dst_dir 109 dst_acl=$(get_acl $dst_dir) 110 dst_mode=$(get_mode $dst_dir) 111 dst_nested_acl=$(get_acl $dst_dir/$nestedfile) 112 dst_nested_mode=$(get_mode $dst_dir/$nestedfile) 113 else 114 log_must $MV ${obj[i]} $TESTDIR1 115 dst_acl=$(get_acl $TESTDIR1/${obj[i]}) 116 dst_mode=$(get_mode $TESTDIR1/${obj[i]}) 117 dst_nested_acl=$(get_acl \ 118 $TESTDIR1/${obj[i]}/$nestedfile) 119 dst_nested_mode=$(get_mode \ 120 $TESTDIR1/${obj[i]}/$nestedfile) 121 fi 122 123 if [[ "$orig_mode" != "$dst_mode" ]] || \ 124 [[ "$orig_acl" != "$dst_acl" ]] || \ 125 [[ "$dst_nested_mode" != "$orig_nested_mode" ]] || \ 126 [[ "$dst_nested_acl" != "$orig_nested_acl" ]]; then 127 log_fail "$MV fails to recursively keep the acl for " \ 128 "directory." 129 fi 130 131 (( i = i + 1 )) 132 done 133 fi 134} 135 136log_assert "Verify that '$MV' supports ZFS ACLs." 137log_onexit cleanup 138 139test_requires ZFS_ACL 140 141spec_ace="everyone@:execute:allow" 142set -A orig_file "origfile1.${TESTCASE_ID}" "origfile2.${TESTCASE_ID}" 143set -A orig_dir "origdir1.${TESTCASE_ID}" "origdir2.${TESTCASE_ID}" 144nestedfile="nestedfile.${TESTCASE_ID}" 145dst_file=dstfile.${TESTCASE_ID} 146dst_dir=dstdir.${TESTCASE_ID} 147cwd=$PWD 148mask=`$UMASK` 149$UMASK 0022 150 151# 152# This assertion should only test 'mv' within the same filesystem 153# 154TESTDIR1=$TESTDIR/testdir1${TESTCASE_ID} 155 156[[ ! -d $TESTDIR1 ]] && \ 157 log_must $MKDIR -p $TESTDIR1 158 159log_note "Create files and directories and set special ace on them for testing. " 160cd $TESTDIR 161typeset -i i=0 162while (( i < ${#orig_file[*]} )) 163do 164 log_must $TOUCH ${orig_file[i]} 165 log_must $CHMOD A0+$spec_ace ${orig_file[i]} 166 167 (( i = i + 1 )) 168done 169i=0 170while (( i < ${#orig_dir[*]} )) 171do 172 log_must $MKDIR ${orig_dir[i]} 173 log_must $TOUCH ${orig_dir[i]}/$nestedfile 174 175 for obj in ${orig_dir[i]} ${orig_dir[i]}/$nestedfile; do 176 log_must $CHMOD A0+$spec_ace $obj 177 done 178 179 (( i = i + 1 )) 180done 181 182testing_mv "f" ${orig_file[0]} ${orig_file[1]} 183testing_mv "d" ${orig_dir[0]} ${orig_dir[1]} 184 185log_pass "'$MV' succeeds to support ZFS ACLs." 186