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_ls_001_pos.ksh 1.3 07/07/31 SMI" 30# 31 32. $STF_SUITE/tests/acl/acl_common.kshlib 33 34################################################################################ 35# 36# __stc_assertion_start 37# 38# ID: zfs_acl_ls_001_pos 39# 40# DESCRIPTION: 41# Verify that '/bin/ls' command option supports ZFS ACL 42# 43# STRATEGY: 44# 1. Create file and directory in zfs filesystem 45# 2. Verify that 'ls [-dv]' can list the ACEs of ACL of 46# file/directroy 47# 3. Change the file/directory's acl 48# 4. Verify that 'ls -l' can use the '+' to indicate the non-trivial 49# acl. 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2005-10-11) 56# 57# __stc_assertion_end 58# 59################################################################################ 60 61verify_runnable "both" 62 63function cleanup 64{ 65 (( ${#cwd} != 0 )) && cd $cwd 66 [[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/* 67 (( ${#mask} != 0 )) && log_must $UMASK $mask 68} 69 70log_assert "Verify that '$LS' command supports ZFS ACLs." 71log_onexit cleanup 72 73test_requires ZFS_ACL 74 75file=$TESTFILE0 76dir=dir.${TESTCASE_ID} 77cwd=$PWD 78mask=`$UMASK` 79spec_ace="everyone@:write_acl:allow" 80 81$UMASK 0022 82 83log_note "Create file and directory in the zfs filesystem. " 84cd $TESTDIR 85log_must $TOUCH $file 86log_must $MKDIR $dir 87 88log_note "Verify that '$LS [-dv]' can list file/directory ACEs of its acl." 89 90typeset -i ace_num=0 91for obj in $file $dir 92do 93 typeset ls_str="" 94 if [[ -f $obj ]]; then 95 ls_str="$LS -v" 96 else 97 ls_str="$LS -dv" 98 fi 99 100 for ace_type in "owner@" "group@" "everyone@" 101 do 102 $ls_str $obj | $GREP $ace_type > /dev/null 2>&1 103 (( $? == 0 )) && (( ace_num += 1 )) 104 done 105 106 (( ace_num < 1 )) && \ 107 log_fail "'$LS [-dv] fails to list file/directroy acls." 108done 109 110log_note "Verify that '$LS [-dl] [-dv]' can output '+' to indicate " \ 111 "the acl existent." 112 113for obj in $file $dir 114do 115 $CHMOD A0+$spec_ace $obj 116 117 log_must eval "$LS -ld -vd $obj | $GREP "+" > /dev/null" 118 log_must plus_sign_check_v $obj 119 120 log_must eval "$LS -ld -vd $obj | $GREP $spec_ace > /dev/null" 121 log_must plus_sign_check_l $obj 122done 123 124log_pass "'$LS' command succeeds to support ZFS ACLs." 125