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