Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / test / smbclient-tests / tests / smbfs / acl / tp_acl_005.ksh
blobc9c68121f8dd966df022d429d0cbc02ce0bde745
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
24 # Copyright 2010 Sun Microsystems, Inc. All rights reserved.
28 # ID: acl_005
30 # DESCRIPTION:
31 # Verify we can take ownership (chown)
33 # STRATEGY:
34 # 1. run "mount -F smbfs //$TUSER@..." $TMNT
35 # 2. run "mount -F smbfs //$TUSER1@..." $TMNT2
36 # 3. create file2, as $TUSER1 and get owner UID
37 # 4. create a file as $TUSER
38 # 5. give $TUSER1 full control
39 # 6. chown UID $TMNT2/file
40 # 7. verify $TUSER1 owns it
43 . $STF_SUITE/include/libtest.ksh
45 tc_id="acl005"
46 tc_desc="Verify we can take ownership (chown)"
47 print_test_case $tc_id - $tc_desc
49 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
50 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
51 set -x
54 server=$(server_name) || return
56 smbmount_clean $TMNT
57 smbmount_clean $TMNT2
59 smbmount_init $TMNT
60 smbmount_init $TMNT2
62 # 1. run "mount -F smbfs //$TUSER@..." $TMNT
64 cmd="mount -F smbfs -oacl //$TUSER:$TPASS@$server/public $TMNT"
65 cti_execute -i '' FAIL $cmd
66 if [[ $? != 0 ]]; then
67 cti_fail "FAIL: $cmd"
68 return
69 else
70 cti_report "PASS: $cmd"
73 # Require that the mount supports ACLs
74 smbmount_getmntopts $TMNT |grep /acl/ >/dev/null
75 if [[ $? != 0 ]]; then
76 smbmount_clean $TMNT
77 cti_unsupported "UNSUPPORTED (no ACLs in this mount)"
78 return
81 # 2. run "mount -F smbfs //$TUSER1@..." $TMNT2
83 cmd="mount -F smbfs -oacl //$TUSER1:$TPASS@$server/public $TMNT2"
84 cti_execute -i '' FAIL $cmd
85 if [[ $? != 0 ]]; then
86 cti_fail "FAIL: $cmd"
87 smbmount_clean $TMNT
88 return
89 else
90 cti_report "PASS: $cmd"
93 # 3. create a file2 as $TUSER1 and get owner UID
95 cmd="touch $TMNT2/${tc_id}B"
96 cti_execute_cmd $cmd
97 if [[ $? != 0 ]]; then
98 cti_fail "FAIL: $cmd"
99 smbmount_clean $TMNT
100 smbmount_clean $TMNT2
101 return
103 cmd="ls -l $TMNT/${tc_id}B"
104 cti_execute_cmd $cmd
105 if [[ $? != 0 ]]; then
106 cti_fail "FAIL: $cmd"
107 smbmount_clean $TMNT
108 smbmount_clean $TMNT2
109 return
111 # Get the ephemereal UID and GID for $TUSER1
112 read mode cnt uid gid junk < cti_stdout
113 cti_execute_cmd "rm $TMNT2/${tc_id}B"
115 # 4. create a file, as $TUSER
117 cmd="cp /etc/passwd $TMNT/$tc_id"
118 cti_execute_cmd $cmd
119 if [[ $? != 0 ]]; then
120 cti_fail "FAIL: $cmd"
121 smbmount_clean $TMNT
122 smbmount_clean $TMNT2
123 return
125 cmd="ls -l $TMNT/$tc_id"
126 cti_execute_cmd $cmd
127 if [[ $? != 0 ]]; then
128 cti_fail "FAIL: $cmd"
129 smbmount_clean $TMNT
130 smbmount_clean $TMNT2
131 return
133 cp cti_stdout out_save
135 # 5. give $TUSER1 full control
136 cmd="chmod A+user:${uid}:rwxpdDaARWcCos::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
145 # 6. chown UID $TMNT2/file
147 cmd="sudo -n chown ${uid} $TMNT2/$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
156 # 6. verify $TUSER1 owns it
158 cmd="ls -l $TMNT2/$tc_id"
159 cti_execute_cmd $cmd
160 if [[ $? != 0 ]]; then
161 cti_fail "FAIL: $cmd"
162 smbmount_clean $TMNT
163 smbmount_clean $TMNT2
164 return
166 cp cti_stdout out_test
168 # The new owner should be different...
169 cmd="diff out_save out_test"
170 cti_execute_cmd $cmd
171 if [[ $? == 0 ]]; then
172 cti_fail "FAIL: owner should have changed"
173 smbmount_clean $TMNT
174 smbmount_clean $TMNT2
175 return
178 # The new owner should contain $uid
179 grep " $uid " out_test >/dev/null
180 if [[ $? != 0 ]]; then
181 cti_fail "FAIL: did not find $uid"
182 smbmount_clean $TMNT
183 smbmount_clean $TMNT2
184 return
187 cti_execute_cmd "rm $TMNT/$tc_id"
188 smbmount_clean $TMNT
189 smbmount_clean $TMNT2
191 cti_pass "${tc_id}: PASS"