1 #!/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 2010 Sun Microsystems, Inc. All rights reserved.
25 #
26
27 #
28 # ID: acl_002
29 #
30 # DESCRIPTION:
31 # Copy ACLs to/from and smbfs mount with cpio
32 #
33 # STRATEGY:
34 # 1. run "mount -F smbfs //server/public /export/mnt"
35 # 2. create a file, make sure it has an ACL
36 # 3. cpio -oP -O archive.cpio
37 # 4. remove the file
38 # 5. cpio -iP -I archive.cpio
39 # 6. verify extracted ACL matches original
40 #
41
42 . $STF_SUITE/include/libtest.ksh
43
44 tc_id="acl002"
45 tc_desc="Verify we can save/restore ACLs with cpio"
46 print_test_case $tc_id - $tc_desc
47
48 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
49 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
50 set -x
51 fi
52
53 server=$(server_name) || return
54
55 testdir_init $TDIR
56 smbmount_clean $TMNT
57 smbmount_init $TMNT
58
59 cmd="mount -F smbfs -oacl //$TUSER:$TPASS@$server/public $TMNT"
60 cti_execute -i '' FAIL $cmd
61 if [[ $? != 0 ]]; then
62 cti_fail "FAIL: $cmd"
63 return
64 else
65 cti_report "PASS: $cmd"
66 fi
67
68 # Require that the mount supports ACLs
69 smbmount_getmntopts $TMNT |grep /acl/ >/dev/null
70 if [[ $? != 0 ]]; then
71 smbmount_clean $TMNT
72 cti_unsupported "UNSUPPORTED (no ACLs in this mount)"
73 return
74 fi
75
76 # create a file, make sure it has an ACL
77 cmd="cp /etc/passwd $TMNT/$tc_id"
78 cti_execute_cmd $cmd
79 if [[ $? != 0 ]]; then
80 cti_fail "FAIL: $cmd"
81 smbmount_clean $TMNT
82 return
83 fi
84 cmd="ls -V $TMNT/$tc_id"
85 cti_execute_cmd $cmd
86 if [[ $? != 0 ]]; then
87 cti_fail "FAIL: $cmd"
88 smbmount_clean $TMNT
89 return
90 fi
91 tail +2 cti_stdout > acl_save
92
93 # 3. cpio -oP -O archive.cpio
94 cmd="echo $tc_id | \
95 ( cd $TMNT ; cpio -ocP -O $TDIR/$tc_id.cpio )"
96 cti_execute_cmd $cmd
97 if [[ $? != 0 ]]; then
98 cti_fail "FAIL: $cmd"
99 smbmount_clean $TMNT
100 return
101 fi
102
103 # 4. remove the file
104 cti_execute_cmd "rm -f $TMNT/$tc_id"
105
106 # 5. cpio -iP -I archive.cpio
107 cmd="( cd $TMNT ; cpio -icP -I $TDIR/$tc_id.cpio )"
108 cti_execute_cmd $cmd
109 if [[ $? != 0 ]]; then
110 cti_fail "FAIL: $cmd"
111 smbmount_clean $TMNT
112 return
113 fi
114
115 # 6. verify extracted ACL matches original
116 cmd="ls -V $TMNT/$tc_id"
117 cti_execute_cmd $cmd
118 if [[ $? != 0 ]]; then
119 cti_fail "FAIL: $cmd"
120 smbmount_clean $TMNT
121 return
122 fi
123 tail +2 cti_stdout > acl_test
124
125 cmd="diff acl_save acl_test"
126 cti_execute_cmd $cmd
127 if [[ $? != 0 ]]; then
128 cti_fail "FAIL: $cmd"
129 smbmount_clean $TMNT
130 return
131 fi
132
133 cti_execute_cmd "rm $TDIR/$tc_id.cpio"
134 cti_execute_cmd "rm $TMNT/$tc_id"
135 smbmount_clean $TMNT
136
137 cti_pass "${tc_id}: PASS"