zfs_acl_mv_001_pos.ksh revision d583b39bfb4e2571d3e41097c5c357ffe353ad45
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#!/bin/ksh -p
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER START
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Common Development and Distribution License (the "License").
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# You may not use this file except in compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# or http://www.opensolaris.org/os/licensing.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin. $STF_SUITE/tests/functional/acl/acl_common.kshlib
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# DESCRIPTION:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Verify that '/usr/bin/mv' supports ZFS ACL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# STRATEGY:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# 1. Create file and directory in zfs filesystem
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# 2. Set special ACE to the file and directory
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# 3. Copy the file/directory within and across zfs file system
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# 4. Verify that the ACL of file/directroy is not changed
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinverify_runnable "both"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinfunction cleanup
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (( ${#cwd} != 0 )) && cd $cwd
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin [[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin [[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (( ${#mask} != 0 )) && log_must $UMASK $mask
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinfunction testing_mv #<flag for file|dir> <file1|dir1> <file2|dir2>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin typeset flag=$1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin set -A obj $2 $3
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin typeset -i i=0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin typeset orig_acl=""
typeset orig_mode=""
typeset dst_acl=""
typeset dst_mode=""
if [[ $flag == "f" ]]; then
while (( i < ${#obj[*]} ))
do
orig_acl="$(get_acl ${obj[i]})"
orig_mode="$(get_mode ${obj[i]})"
if (( i < 1 )); then
log_must $MV ${obj[i]} $dst_file
dst_acl=$(get_acl $dst_file)
dst_mode=$(get_mode $dst_file)
else
log_must $MV ${obj[i]} $TESTDIR1
dst_acl=$(get_acl $TESTDIR1/${obj[i]})
dst_mode=$(get_mode $TESTDIR1/${obj[i]})
fi
if [[ "$dst_mode" != "$orig_mode" ]] || \
[[ "$dst_acl" != "$orig_acl" ]]; then
log_fail "$MV fails to keep the acl for file."
fi
(( i = i + 1 ))
done
else
while (( i < ${#obj[*]} ))
do
typeset orig_nested_acl=""
typeset orig_nested_mode=""
typeset dst_nested_acl=""
typeset dst_nested_mode=""
orig_acl=$(get_acl ${obj[i]})
orig_mode=$(get_mode ${obj[i]})
orig_nested_acl=$(get_acl ${obj[i]}/$nestedfile)
orig_nested_mode=$(get_mode ${obj[i]}/$nestedfile)
if (( i < 1 )); then
log_must $MV ${obj[i]} $dst_dir
dst_acl=$(get_acl $dst_dir)
dst_mode=$(get_mode $dst_dir)
dst_nested_acl=$(get_acl $dst_dir/$nestedfile)
dst_nested_mode=$(get_mode $dst_dir/$nestedfile)
else
log_must $MV ${obj[i]} $TESTDIR1
dst_acl=$(get_acl $TESTDIR1/${obj[i]})
dst_mode=$(get_mode $TESTDIR1/${obj[i]})
dst_nested_acl=$(get_acl \
$TESTDIR1/${obj[i]}/$nestedfile)
dst_nested_mode=$(get_mode \
$TESTDIR1/${obj[i]}/$nestedfile)
fi
if [[ "$orig_mode" != "$dst_mode" ]] || \
[[ "$orig_acl" != "$dst_acl" ]] || \
[[ "$dst_nested_mode" != "$orig_nested_mode" ]] || \
[[ "$dst_nested_acl" != "$orig_nested_acl" ]]; then
log_fail "$MV fails to recursively keep the acl for " \
"directory."
fi
(( i = i + 1 ))
done
fi
}
log_assert "Verify that '$MV' supports ZFS ACLs."
log_onexit cleanup
spec_ace="everyone@:execute:allow"
set -A orig_file "origfile1.$$" "origfile2.$$"
set -A orig_dir "origdir1.$$" "origdir2.$$"
nestedfile="nestedfile.$$"
dst_file=dstfile.$$
dst_dir=dstdir.$$
cwd=$PWD
mask=`$UMASK`
$UMASK 0022
#
# This assertion should only test 'mv' within the same filesystem
#
TESTDIR1=$TESTDIR/testdir1$$
[[ ! -d $TESTDIR1 ]] && \
log_must $MKDIR -p $TESTDIR1
log_note "Create files and directories and set special ace on them for testing. "
cd $TESTDIR
typeset -i i=0
while (( i < ${#orig_file[*]} ))
do
log_must $TOUCH ${orig_file[i]}
log_must $CHMOD A0+$spec_ace ${orig_file[i]}
(( i = i + 1 ))
done
i=0
while (( i < ${#orig_dir[*]} ))
do
log_must $MKDIR ${orig_dir[i]}
log_must $TOUCH ${orig_dir[i]}/$nestedfile
for obj in ${orig_dir[i]} ${orig_dir[i]}/$nestedfile; do
log_must $CHMOD A0+$spec_ace $obj
done
(( i = i + 1 ))
done
testing_mv "f" ${orig_file[0]} ${orig_file[1]}
testing_mv "d" ${orig_dir[0]} ${orig_dir[1]}
log_pass "'$MV' succeeds to support ZFS ACLs."