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 # Verifies ability to find files with attribute with -xattr flag and using
38 # "-exec runat ls".
39 #
40 # STRATEGY:
41 # 1. In directory A, create several files and add attribute files for them
42 # 2. Verify all the specified files can be found with '-xattr',
43 # 3. Verify all the attribute files can be found with '-exec runat ls'
44 #
45 # TESTABILITY: explicit
46 #
47 # TEST_AUTOMATION_LEVEL: automated
48 #
49 # __stc_assertion_end
50 #
51 ################################################################################
52
53 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
54 && set -x
55
56 echo "ASSERTION: Verifies ability to find files with attribute with" \
57 "-xattr flag and using '-exec runat ls'"
58
59 for user in root $ACL_STAFF1; do
60 # In TX env, we can't create files with xattr as a regular user
61 if [[ $user != root ]] && [[ ! -z $ZONE_PATH ]]; then
62 continue
63 fi
64
65 RUN_CHECK set_cur_usr $user || cleanup $STF_FAIL
66
67 RUN_CHECK create_files $TESTDIR || cleanup $STF_FAIL
68 initfiles=$($LS -R $INI_DIR/*)
69
70 typeset -i i=0
71 while (( i < NUM_FILE )); do
72 f=$(getitem $i $initfiles)
73 ff=$(usr_exec $FIND $INI_DIR -type f -name ${f##*/} \
74 -xattr -print)
75 if [[ $ff != $f ]]; then
76 echo "find file containing attribute fail."
77 cleanup $STF_FAIL
78 fi
79
80 # find $f by '-xattr'.
81
82 typeset -i j=0
83 while (( j < NUM_ATTR )); do
84 typeset af=attribute.$j
85 fa=$(usr_exec $FIND $INI_DIR -type f -name ${f##*/} \
86 -xattr -exec runat {} ls $af \\\;)
87 if [[ $fa != $af ]]; then
88 echo "find file attribute fail"
89 cleanup $STF_FAIL
90 fi
91 (( j += 1 ))
92 done
93 (( i += 1 ))
94 # find all attribute files of $f
95 done
96
97 cleanup
98 done
99
100 cleanup $STF_PASS