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# $FreeBSD$ 24 25# 26# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_acl_find_001_pos.ksh 1.2 07/01/09 SMI" 30# 31 32. $STF_SUITE/tests/acl/acl_common.kshlib 33 34################################################################################ 35# 36# __stc_assertion_start 37# 38# ID: zfs_acl_find_001_pos 39# 40# DESCRIPTION: 41# Verify that '$FIND' command with '-ls' and '-acl' options supports ZFS ACL 42# 43# STRATEGY: 44# 1. Create 5 files and 5 directories in zfs filesystem 45# 2. Select a file or directory and add a few ACEs to it 46# 3. Use $FIND -ls to check the "+" existen only with the selected file or 47# directory 48# 4. Use $FIND -acl to check only the selected file/directory in the list 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2005-09-26) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60verify_runnable "both" 61 62function cleanup 63{ 64 [[ -d $TESTDIR ]] && $RM -rf $TESTDIR/* 65 (( ${#cwd} != 0 )) && cd $cwd 66 (( ${#mask} != 0 )) && $UMASK $mask 67} 68 69function find_ls_acl #<opt> <obj> 70{ 71 typeset opt=$1 # -ls or -acl 72 typeset obj=$2 73 typeset rst_str="" 74 75 if [[ $opt == "ls" ]]; then 76 rst_str=`$FIND . -ls | $GREP "+" | $AWK '{print $11}'` 77 else 78 rst_str=`$FIND . -acl` 79 fi 80 81 if [[ $rst_str == "./$obj" ]]; then 82 return 0 83 else 84 return 1 85 fi 86} 87 88log_assert "Verify that '$FIND' command supports ZFS ACLs." 89log_onexit cleanup 90 91test_requires ZFS_ACL 92 93set -A ops " A+everyone@:read_data:allow" \ 94 " A+owner@:write_data:allow" 95 96f_base=testfile.${TESTCASE_ID} # Base file name for tested files 97d_base=testdir.${TESTCASE_ID} # Base directory name for tested directory 98cwd=$PWD 99mask=`$UMASK` 100 101log_note "Create five files and directories in the zfs filesystem. " 102cd $TESTDIR 103$UMASK 0777 104typeset -i i=0 105while (( i < 5 )) 106do 107 log_must $TOUCH ${f_base}.$i 108 log_must $MKDIR ${d_base}.$i 109 110 (( i = i + 1 )) 111done 112 113for obj in ${f_base}.3 ${d_base}.3 114do 115 i=0 116 while (( i < ${#ops[*]} )) 117 do 118 log_must $CHMOD ${ops[i]} $obj 119 120 (( i = i + 1 )) 121 done 122 123 for opt in "ls" "acl" 124 do 125 log_must find_ls_acl $opt $obj 126 done 127 128 log_note "Check the file access permission according to the added ACEs" 129 if [[ ! -r $obj || ! -w $obj ]]; then 130 log_fail "The added ACEs for $obj cannot be represented in " \ 131 "mode." 132 fi 133 134 log_note "Remove the added ACEs from ACL." 135 i=0 136 while (( i < ${#ops[*]} )) 137 do 138 log_must $CHMOD A0- $obj 139 140 (( i = i + 1 )) 141 done 142done 143 144log_pass "'$FIND' command succeeds to support ZFS ACLs." 145