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 # Verify that '$TAR' command with -p option supports to archive NFSv4 ACLs
38 #
39 # STRATEGY:
40 # 1. Create file and directory in nfs filesystem
41 # 2. Add new ACE in ACL of file and directory
42 # 3. Use $TAR to archive file and directory
43 # 4. Extract the archive file
44 # 5. Verify that the restored ACLs of file and directory identify
45 # with the origional ones.
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: Verify that '$TAR' command supports to archive NFSv4 ACLs."
59
60 set -A ops " A+everyone@:execute:allow" "a-x" "777"
61
62 TARFILE=tarfile.$$.tar
63 file=$TESTFILE0
64 dir=dir.$$
65 cwd=$PWD
66
67 # use absolute path
68 TESTDIR=$MNTDIR/$TESTDIR
69 TESTDIR1=$MNTDIR/$TESTDIR1
70
71 # Create second directory to restore the tar archive.
72 if [[ ! -d $TESTDIR1 ]]; then
73 RUN_CHECK $MKDIR -p $TESTDIR1 || cleanup $STF_FAIL
74 fi
75
76 # Create a file: $file, and directory: $dir, in nfs filesystem.
77 cd $TESTDIR
78 RUN_CHECK $TOUCH $file || cleanup $STF_FAIL
79 RUN_CHECK $MKDIR $dir || cleanup $STF_FAIL
80
81 typeset -i i=0
82 while (( i < ${#ops[*]} ))
83 do
84 # Change the ACLs of file and directory with '$CHMOD ${ops[i]}'.
85 cd $TESTDIR
86 for obj in $file $dir; do
87 RUN_CHECK $CHMOD ${ops[i]} $obj || cleanup $STF_FAIL
88 done
89 # Archive the file and directory.
90 RUN_CHECK $TAR cpf $TARFILE $file $dir || cleanup $STF_FAIL
91
92 # Restore the tar archive.
93 RUN_CHECK $MV $TARFILE $TESTDIR1 || cleanup $STF_FAIL
94 cd $TESTDIR1
95 RUN_CHECK $TAR xpf $TARFILE || cleanup $STF_FAIL
96
97 # Verify the ACLs of restored file/directory have no changes.
98 for obj in $file $dir; do
99 RUN_CHECK compare_modes $TESTDIR/$obj $TESTDIR1/$obj \
100 || cleanup $STF_FAIL
101 RUN_CHECK compare_acls $TESTDIR/$obj $TESTDIR1/$obj \
102 || cleanup $STF_FAIL
103 done
104
105 RUN_CHECK $RM -rf $TESTDIR1/* || cleanup $STF_FAIL
106
107 (( i = i + 1 ))
108 done
109
110 # '$TAR' command succeeds to support NFSv4 ACLs.
111 cleanup $STF_PASS