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_004
29 #
30 # DESCRIPTION:
31 # Verify we can modify an ACL (add $TUSER1)
32 #
33 # STRATEGY:
34 # 1. run "mount -F smbfs //$TUSER@..." $TMNT
35 # 2. run "mount -F smbfs //$TUSER1@..." $TMNT2
36 # 3. create a file, as $TUSER
37 # 4. create file2, as $TUSER1 and get owner UID
38 # 5. chmod A+user:$TUSER1@:rxaRcs::allow file
39 # 6. verify $TUSER1 ACE is there
40 #
41
42 . $STF_SUITE/include/libtest.ksh
43
44 tc_id="acl004"
45 tc_desc="Verify we can modify an ACL (add user ACE)"
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 smbmount_clean $TMNT
56 smbmount_clean $TMNT2
57
58 smbmount_init $TMNT
59 smbmount_init $TMNT2
60
61 # 1. run "mount -F smbfs //$TUSER@..." $TMNT
62
63 cmd="mount -F smbfs -oacl //$TUSER:$TPASS@$server/public $TMNT"
64 cti_execute -i '' FAIL $cmd
65 if [[ $? != 0 ]]; then
66 cti_fail "FAIL: $cmd"
67 return
68 else
69 cti_report "PASS: $cmd"
70 fi
71
72 # Require that the mount supports ACLs
73 smbmount_getmntopts $TMNT |grep /acl/ >/dev/null
74 if [[ $? != 0 ]]; then
75 smbmount_clean $TMNT
76 cti_unsupported "UNSUPPORTED (no ACLs in this mount)"
77 return
78 fi
79
80 # 2. run "mount -F smbfs //$TUSER1@..." $TMNT2
81
82 cmd="mount -F smbfs -oacl //$TUSER1:$TPASS@$server/public $TMNT2"
83 cti_execute -i '' FAIL $cmd
84 if [[ $? != 0 ]]; then
85 cti_fail "FAIL: $cmd"
86 smbmount_clean $TMNT
87 return
88 else
89 cti_report "PASS: $cmd"
90 fi
91
92 # 3. create a file, as $TUSER
93
94 cmd="cp /etc/passwd $TMNT/$tc_id"
95 cti_execute_cmd $cmd
96 if [[ $? != 0 ]]; then
97 cti_fail "FAIL: $cmd"
98 smbmount_clean $TMNT
99 smbmount_clean $TMNT2
100 return
101 fi
102 cmd="ls -V $TMNT/$tc_id"
103 cti_execute_cmd $cmd
104 if [[ $? != 0 ]]; then
105 cti_fail "FAIL: $cmd"
106 smbmount_clean $TMNT
107 smbmount_clean $TMNT2
108 return
109 fi
110 tail +2 cti_stdout > acl_save
111
112 # 4. create a file, as $TUSER1 and get owner UID
113
114 cmd="touch $TMNT2/${tc_id}B"
115 cti_execute_cmd $cmd
116 if [[ $? != 0 ]]; then
117 cti_fail "FAIL: $cmd"
118 smbmount_clean $TMNT
119 smbmount_clean $TMNT2
120 return
121 fi
122 cmd="ls -V $TMNT/${tc_id}B"
123 cti_execute_cmd $cmd
124 if [[ $? != 0 ]]; then
125 cti_fail "FAIL: $cmd"
126 smbmount_clean $TMNT
127 smbmount_clean $TMNT2
128 return
129 fi
130 # Get the ephemereal UID and GID for $TUSER1
131 read mode cnt uid gid junk < cti_stdout
132 cti_execute_cmd "rm $TMNT2/${tc_id}B"
133
134 # 5. chmod A+user:$TUSER1@:rxaRcs::allow file
135
136 cmd="chmod A+user:${uid}:rxaRcs::allow $TMNT/$tc_id"
137 cti_execute_cmd $cmd
138 if [[ $? != 0 ]]; then
139 cti_fail "FAIL: $cmd"
140 smbmount_clean $TMNT
141 smbmount_clean $TMNT2
142 return
143 fi
144
145 # 6. verify $TUSER1 ACE is there
146
147 cmd="ls -V $TMNT/$tc_id"
148 cti_execute_cmd $cmd
149 if [[ $? != 0 ]]; then
150 cti_fail "FAIL: $cmd"
151 smbmount_clean $TMNT
152 smbmount_clean $TMNT2
153 return
154 fi
155 tail +2 cti_stdout > acl_test
156
157 # The new ACL should be different...
158 cmd="diff acl_save acl_test"
159 cti_execute_cmd $cmd
160 if [[ $? == 0 ]]; then
161 cti_fail "FAIL: ACL should have changed"
162 smbmount_clean $TMNT
163 smbmount_clean $TMNT2
164 return
165 fi
166
167 # The new ACL should contain $uid
168 grep " user:${uid}:" acl_test >/dev/null
169 if [[ $? != 0 ]]; then
170 cti_fail "FAIL: did not find new ACE"
171 smbmount_clean $TMNT
172 smbmount_clean $TMNT2
173 return
174 fi
175
176 cti_execute_cmd "rm $TMNT/$tc_id"
177 smbmount_clean $TMNT
178 smbmount_clean $TMNT2
179
180 cti_pass "${tc_id}: PASS"