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_cpio_pos001
35 #
36 # DESCRIPTION:
37 # Verify that '$CPIO' command with -P option supports to archive ZFS ACLs
38 #
39 # STRATEGY:
40 # 1. Create file and directory in nfs filesystem
41 # 2. Add new ACE in ACL or change mode of file and directory
42 # 3. Use $CPIO 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 '$CPIO' command supports to archive NFSv4 ACLs."
59
60 set -A ops "A+everyone@:execute:allow" \
61 "A3+user:$ACL_OTHER1:write_data:deny" \
62 "A5+group:$ACL_OTHER_GROUP:read_data:deny" \
63 "A0+user:$ACL_OTHER1:write_data:deny" \
64 "A1=user:$ACL_STAFF1:write_data:deny" \
65 "A5=group:$ACL_STAFF_GROUP:write_data:deny"
66
67 # Create second directory to restore the cpio archive.
68 RUN_CHECK $MKDIR -p $TESTDIR1 || cleanup $STF_FAIL
69 RUN_CHECK $CHMOD 777 $TESTDIR1 || cleanup $STF_FAIL
70
71 # Define test fine and record the original directory.
72 CPIOFILE=cpiofile.$$
73 file=$TESTFILE0
74 dir=dir.$$
75 orig_dir=$PWD
76
77 typeset user
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 typeset -i i=0
83 while (( i < ${#ops[*]} )); do
84 # Create file $file and directory $dir in nfs filesystem.
85 cd $TESTDIR
86 RUN_CHECK usr_exec $TOUCH $file || cleanup $STF_FAIL
87 RUN_CHECK usr_exec $MKDIR $dir || cleanup $STF_FAIL
88
89 # Change the ACLs of file and directory with '$CHMOD ${ops[i]}'
90 for obj in $file $dir; do
91 RUN_CHECK usr_exec $CHMOD ${ops[i]} $obj \
92 || cleanup $STF_FAIL
93 done
94
95 # Archive the file and directory.
96 RUN_CHECK usr_exec $LS | $CPIO -ocP -O $CPIOFILE \
97 > $STF_TMPDIR/cpio.$$ 2>&1 \
98 || cleanup $STF_FAIL $STF_TMPDIR/cpio.$$
99
100 # Restore the cpio archive.
101 cd $MNTDIR
102 RUN_CHECK usr_exec $MV $TESTDIR/$CPIOFILE $TESTDIR1 || cleanup $STF_FAIL
103 cd $TESTDIR1
104 RUN_CHECK usr_exec $CAT $CPIOFILE | $CPIO -icP \
105 > $STF_TMPDIR/cpio.$$ 2>&1 \
106 || cleanup $STF_FAIL $STF_TMPDIR/cpio.$$
107
108 # Verify that the ACLs of restored file/directory have no change
109 cd $MNTDIR
110 for obj in $file $dir; do
111 RUN_CHECK compare_modes $TESTDIR/$obj $TESTDIR1/$obj \
112 || cleanup $STF_FAIL
113 RUN_CHECK compare_acls $TESTDIR/$obj $TESTDIR1/$obj \
114 || cleanup $STF_FAIL
115 done
116
117 RUN_CHECK usr_exec $RM -rf $TESTDIR/* $TESTDIR1/* \
118 || cleanup $STF_FAIL
119
120 (( i = i + 1 ))
121 done
122 done
123
124 # '$CPIO' command succeeds to support NFSv4 ACLs.
125 cleanup $STF_PASS