1 #! /usr/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 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 . $STF_SUITE/tests/acl/acl_common.kshlib
29
30 ################################################################################
31 #
32 # __stc_assertion_start
33 #
34 # ID: acl_ls_pos001
35 #
36 # DESCRIPTION:
37 # Verify that '/usr/bin/ls' command option supports NFSv4 ACL
38 #
39 # STRATEGY:
40 # 1. Create file and directory in nfs filesystem
41 # 2. Verify that 'ls [-dv]' can list the ACEs of ACL of
42 # file/directroy
43 # 3. Change the file/directory's acl
44 # 4. Verify that 'ls -l' can use the '+' to indicate the non-trivial
45 # acl.
46 #
47 # TESTABILITY: explicit
48 #
49 # TEST_AUTOMATION_LEVEL: automated
50 #
51 # __stc_assertion_end
52 #
53 ################################################################################
54
55 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
56 && set -x
57
58 function case_cleanup
59 {
60 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
61 && set -x
62
63 (( ${#cwd} != 0 )) && cd $cwd
64 (( ${#mask} != 0 )) && RUN_CHECK $UMASK $mask
65 cleanup $1
66 }
67
68 echo "ASSERTION: Verify that '$LS' command supports NFSv4 ACLs."
69
70 file=$TESTFILE0
71 dir=dir.$$
72 cwd=$PWD
73 mask=`$UMASK`
74 spec_ace="everyone@:write_acl:allow"
75
76 $UMASK 0022
77
78 # Create file and directory in the nfs filesystem.
79 cd $TESTDIR
80 RUN_CHECK $TOUCH $file || case_cleanup $STF_FAIL
81 RUN_CHECK $MKDIR $dir || case_cleanup $STF_FAIL
82
83 # Verify that '$LS [-dv]' can list file/directory ACEs of its acl.
84
85 typeset -i ace_num=0
86 for obj in $file $dir
87 do
88 typeset ls_str=""
89 if [[ -f $obj ]]; then
90 ls_str="$LS -v"
91 else
92 ls_str="$LS -dv"
93 fi
94
95 for ace_type in "owner@" "group@" "everyone@"
96 do
97 RUN_CHECK $ls_str $obj | $GREP $ace_type > /dev/null
98 (( $? == 0 )) && (( ace_num += 1 )) || case_cleanup $STF_FAIL
99 done
100
101 if (( ace_num < 1 )); then
102 echo "'$LS [-dv] fails to list file/directroy acls."
103 case_cleanup $STF_FAIL
104 fi
105 done
106
107 # Verify that '$LS [-dl] [-dv]' can output '+' to indicate the acl existent.
108
109 for obj in $file $dir
110 do
111 RUN_CHECK $CHMOD A0+$spec_ace $obj || case_cleanup $STF_FAIL
112
113 RUN_CHECK $LS -ld -vd $obj | $GREP + > /dev/null \
114 || case_cleanup $STF_FAIL
115 RUN_CHECK plus_sign_check_v $obj || case_cleanup $STF_FAIL
116
117 RUN_CHECK $LS -ld -vd $obj | $GREP $spec_ace > /dev/null \
118 || case_cleanup $STF_FAIL
119 RUN_CHECK plus_sign_check_l $obj || case_cleanup $STF_FAIL
120 done
121
122 # '$LS' command succeeds to support NFSv4 ACLs.
123 case_cleanup $STF_PASS