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_tar_pos001
  35 #
  36 # DESCRIPTION:
  37 #       Verifies that tar will include file attribute when @ flag is present.
  38 #
  39 # STRATEGY:
  40 #       1. Use mktree create a set of directories in directory A.
  41 #       2. Enter into directory A and record all directory information.
  42 #       3. tar all the files to directory B.
  43 #       4. Then tar the tar file to directory C.
  44 #       5. Record all the directories informat in derectory C.
  45 #       6. Verify the two records should be identical.
  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 echo "ASSERTION: Verifies that tar will include file attribute when @ flag is " \
  59         "present."
  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         [[ ! -d $INI_DIR ]] && $MKDIR -m 777 -p $INI_DIR
  70         RUN_CHECK usr_exec $MKTREE -b $INI_DIR -l 5 -d 2 -f 2 \
  71                 || cleanup $STF_FAIL
  72 
  73         #
  74         # Enter into initial directory and record all directory information,
  75         # then tar all the files to $TMP_DIR/files.tar.
  76         #
  77         [[ ! -d $TMP_DIR ]] && usr_exec $MKDIR $TMP_DIR
  78         initout=$TMP_DIR/initout.$$
  79         tarout=$TMP_DIR/files.tar
  80         cd $INI_DIR
  81         RUN_CHECK record_cksum $MNTDIR/$INI_DIR $MNTDIR/$initout || cleanup $STF_FAIL
  82         RUN_CHECK usr_exec $TAR cpf@ $MNTDIR/$tarout * || cleanup $STF_FAIL
  83 
  84         #
  85         # Enter into test directory and tar $TMP_DIR/files.tar to current
  86         # directory. Record all directory information and compare with initial
  87         # directory record.
  88         #
  89         [[ ! -d $MNTDIR/$TST_DIR ]] && $MKDIR -m 777 $MNTDIR/$TST_DIR
  90         testout=$TMP_DIR/testout.$$
  91         cd $MNTDIR/$TST_DIR
  92         RUN_CHECK usr_exec $TAR xpf@ $MNTDIR/$tarout || cleanup $STF_FAIL
  93         RUN_CHECK record_cksum $MNTDIR/$TST_DIR $MNTDIR/$testout || cleanup $STF_FAIL
  94 
  95         RUN_CHECK usr_exec $DIFF $MNTDIR/$initout $MNTDIR/$testout || cleanup $STF_FAIL
  96 
  97         cd $MNTDIR
  98         cleanup
  99 done
 100 
 101 # Verify tar with @ passed.
 102 cleanup $STF_PASS