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