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