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_cp_pos002
  35 #
  36 # DESCRIPTION:
  37 #       Verify that '/usr/bin/cp [-p@]' supports ACL & xattrs
  38 #
  39 # STRATEGY:
  40 #       1. Create file and  directory in nfs filesystem
  41 #       2. Set special ACE to the file and directory
  42 #       3. Create xattr of the file and directory
  43 #       4. Copy the file/directory to another directory.
  44 #       5. Verify that the ACL & xattrs of the file/directroy is not changed, 
  45 #          when you are inserting an ACL with user: or group: entry on the top.
  46 #          (abstractions entry are treated special, since they represent the 
  47 #          traditional permission bit mapping.)
  48 #
  49 # TESTABILITY: explicit
  50 #
  51 # TEST_AUTOMATION_LEVEL: automated
  52 #
  53 # __stc_assertion_end
  54 #
  55 ################################################################################
  56 
  57 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
  58         && set -x
  59 
  60 echo "ASSERTION: Verify that '$CP [-p]' supports ACLs."
  61 
  62 # Create the second directory
  63 RUN_CHECK $MKDIR -p $TESTDIR1 || cleanup $STF_FAIL
  64 RUN_CHECK $CHMOD 777 $TESTDIR1 || cleanup $STF_FAIL
  65 
  66 # Define target directory.
  67 dstdir=$TESTDIR1/dstdir.$$
  68 MYTESTFILE=$STF_SUITE/STF.INFO
  69 
  70 # XXX: if user set to $ACL_STAFF1, then the test fails ??
  71 # for user in root $ACL_STAFF1; do
  72 for user in root; do
  73         # Set the current user
  74         RUN_CHECK set_cur_usr $user || cleanup $STF_FAIL
  75 
  76         for obj in $testfile $testdir; do
  77                 # Create source object and target directroy
  78                 RUN_CHECK usr_exec $TOUCH $testfile || cleanup $STF_FAIL
  79                 RUN_CHECK usr_exec $MKDIR $testdir $dstdir || cleanup $STF_FAIL
  80 
  81                 RUN_CHECK usr_exec $RUNAT $testfile $CP $MYTESTFILE attr.0 \
  82                         || cleanup $STF_FAIL
  83                 RUN_CHECK usr_exec $RUNAT $testdir $CP $MYTESTFILE attr.0 \
  84                         || cleanup $STF_FAIL
  85 
  86                 # Add the new ACE on the head.
  87                 RUN_CHECK usr_exec $CHMOD \
  88                         A0+user:$ACL_OTHER1:read_acl:deny $obj \
  89                         || cleanup $STF_FAIL
  90 
  91                 cmd_str="$CP -p@"
  92                 [[ -d $obj ]] && cmd_str="$CP -rp@"
  93                 RUN_CHECK usr_exec $cmd_str $obj $dstdir || cleanup $STF_FAIL
  94                 RUN_CHECK usr_exec $cmd_str $obj $TESTDIR1 || cleanup $STF_FAIL
  95 
  96                 for dir in $dstdir $TESTDIR1; do 
  97                         RUN_CHECK compare_modes $obj $dir/${obj##*/} \
  98                                 || cleanup $STF_FAIL
  99                         RUN_CHECK compare_acls $obj $dir/${obj##*/} \
 100                                 || cleanup $STF_FAIL
 101                         RUN_CHECK compare_xattrs $obj $dir/${obj##*/} \
 102                                 || cleanup $STF_FAIL
 103                 done
 104 
 105                 # Delete all the test file and directory
 106                 RUN_CHECK usr_exec $RM -rf $TESTDIR/* $TESTDIR1/* \
 107                         || cleanup $STF_FAIL
 108         done
 109 done
 110 
 111 # '$CP [-p@]' succeeds to support ACLs.
 112 cleanup $STF_PASS