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_pos002
35 #
36 # DESCRIPTION:
37 # Verify that '$TAR' command with -p@ option supports to archive NFSv4 ACLs
38 # & xattrs
39 #
40 # STRATEGY:
41 # 1. Create file and directory in nfs filesystem
42 # 2. Add new ACE in ACL of file and directory
43 # 3. Create xattr of the file and directory
44 # 4. Use $TAR cf@ to archive file and directory
45 # 5. Use $TAR xf@ to extract the archive file
46 # 6. Verify that the restored ACLs & xttrs of file and directory identify
47 # with the origional ones.
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 '$TAR' command supports to archive NFSv4 ACLs & xattrs."
61
62 set -A ops " A+everyone@:execute:allow" "a-x" "777"
63 MYTESTFILE=$STF_SUITE/STF.INFO
64
65 testfile=testfile.$$
66 testdir=testdir.$$
67 TARFILE=tarfile.$$.tar
68 cwd=$PWD
69
70 # Create second directory to restore the tar archive.
71 if [[ ! -d $TESTDIR1 ]]; then
72 RUN_CHECK $MKDIR -p $TESTDIR1 || cleanup $STF_FAIL
73 fi
74
75 # Create a file: $testfile, and directory: $testdir, in nfs filesystem
76 # And prepare for there xattr files.
77
78 for user in root $ACL_STAFF1; do
79 # Set the current user
80 RUN_CHECK set_cur_usr $user || cleanup $STF_FAIL
81
82 # Create source object and target directroy
83 cd $TESTDIR
84 RUN_CHECK usr_exec $TOUCH $testfile || cleanup $STF_FAIL
85 RUN_CHECK usr_exec $MKDIR $testdir || cleanup $STF_FAIL
86
87 RUN_CHECK usr_exec $RUNAT $testfile $CP $MYTESTFILE attr.0 \
88 || cleanup $STF_FAIL
89 RUN_CHECK usr_exec $RUNAT $testdir $CP $MYTESTFILE attr.0 \
90 || cleanup $STF_FAIL
91
92 # Add the new ACE on the head.
93 # Change the ACLs of file and directory with '$CHMOD ${ops[0]}'.
94 RUN_CHECK usr_exec $CHMOD ${ops[0]} $testfile || cleanup $STF_FAIL
95 RUN_CHECK usr_exec $CHMOD ${ops[0]} $testdir || cleanup $STF_FAIL
96
97 # Archive the file and directory.
98 RUN_CHECK $TAR cpf@ $TARFILE ${testfile#$TESTDIR/} ${testdir#$TESTDIR/} \
99 || cleanup $STF_FAIL
100
101 # Restore the tar archive.
102 cd $MNTDIR/$TESTDIR1
103 RUN_CHECK $TAR xpf@ $MNTDIR/$TESTDIR/$TARFILE || cleanup $STF_FAIL
104
105 cd $MNTDIR
106 # Verify the ACLs of restored file/directory have no changes.
107 for obj in $testfile $testdir; do
108 RUN_CHECK compare_modes $TESTDIR/$obj $TESTDIR1/${obj##*/} \
109 || cleanup $STF_FAIL
110 RUN_CHECK compare_acls $TESTDIR/$obj $TESTDIR1/${obj##*/} \
111 || cleanup $STF_FAIL
112 RUN_CHECK compare_xattrs $TESTDIR/$obj $TESTDIR1/${obj##*/} \
113 || cleanup $STF_FAIL
114 done
115
116 RUN_CHECK $RM -rf $TESTDIR/* $TESTDIR1/* || cleanup $STF_FAIL
117 done
118
119 # '$TAR' command succeeds to support NFSv4 ACLs.
120 cleanup $STF_PASS