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