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_find_pos001
35 #
36 # DESCRIPTION:
37 # Verify that '$FIND' command with '-ls' and '-acl' options supports NFSv4 ACL
38 #
39 # STRATEGY:
40 # 1. Create 5 files and 5 directories in nfs filesystem
41 # 2. Select a file or directory and add a few ACEs to it
42 # 3. Use $FIND -ls to check the "+" existen only with the selected file or
43 # directory
44 # 4. Use $FIND -acl to check only the selected file/directory in the list
45 #
46 # TESTABILITY: explicit
47 #
48 # TEST_AUTOMATION_LEVEL: automated
49 #
50 # __stc_assertion_end
51 #
52 ################################################################################
53
54 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
55 && set -x
56
57 function case_cleanup
58 {
59 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
60 && set -x
61
62 [[ -d $TESTDIR ]] && $RM -rf $TESTDIR/*
63 (( ${#cmd} != 0 )) && cd $cwd
64 (( ${#mask} != 0 )) && $UMASK $mask
65 cleanup $1
66 }
67
68 function find_ls_acl #<opt> <obj>
69 {
70 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
71 && set -x
72
73 typeset opt=$1 # -ls or -acl
74 typeset obj=$2
75 typeset rst_str=""
76
77 if [[ $opt == "ls" ]]; then
78 rst_str=`$FIND . -ls | $GREP "+" | $AWK '{print $11}'`
79 else
80 rst_str=`$FIND . -acl`
81 fi
82
83 if [[ $rst_str == "./$obj" ]]; then
84 return 0
85 else
86 return 1
87 fi
88 }
89
90 echo "ASSERTION: Verify that '$FIND' command supports NFSv4 ACLs."
91
92 set -A ops " A+everyone@:read_data:allow" \
93 " A+owner@:write_data:allow"
94
95 f_base=testfile.$$ # Base file name for tested files
96 d_base=testdir.$$ # Base directory name for tested directory
97 cwd=$PWD
98 mask=`$UMASK`
99
100 # Create five files and directories in the nfs filesystem.
101 cd $TESTDIR
102 $UMASK 0777
103 typeset -i i=0
104 while (( i < 5 ))
105 do
106 RUN_CHECK $TOUCH ${f_base}.$i || case_cleanup $STF_FAIL
107 RUN_CHECK $MKDIR ${d_base}.$i || case_cleanup $STF_FAIL
108
109 (( i = i + 1 ))
110 done
111
112 for obj in ${f_base}.3 ${d_base}.3
113 do
114 i=0
115 while (( i < ${#ops[*]} ))
116 do
117 RUN_CHECK $CHMOD ${ops[i]} $obj || case_cleanup $STF_FAIL
118
119 (( i = i + 1 ))
120 done
121
122 for opt in "ls" "acl"
123 do
124 RUN_CHECK find_ls_acl $opt $obj || case_cleanup $STF_FAIL
125 done
126
127 # Check the file access permission according to the added ACEs
128 if [[ ! -r $obj || ! -w $obj ]]; then
129 echo "The added ACEs for $obj cannot be represented in " \
130 "mode."
131 case_cleanup $STF_FAIL
132 fi
133
134 # Remove the added ACEs from ACL.
135 i=0
136 while (( i < ${#ops[*]} ))
137 do
138 RUN_CHECK $CHMOD A0- $obj || case_cleanup $STF_FAIL
139 (( i = i + 1 ))
140 done
141 done
142
143 # '$FIND' command succeeds to support NFSv4 ACLs.
144 case_cleanup $STF_PASS