xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbmount/tp_smbmount_007.ksh (revision 2aeafac3612e19716bf8164f89c3c9196342979c)
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: smbmount_007
29#
30# DESCRIPTION:
31#        Verify mutil user mount success with -O
32#
33# STRATEGY:
34#	1. create users "$AUSER", "$BUSER" and their passwords
35#	2. create $AUSER smb private share for user "$AUSER"
36#	3. run "mount -F smbfs //$AUSER:$APASS@server/public /export/mnt"
37#	4. mount successfully
38#	5. run "mount -F smbfs -O //$BUSER:$BPASS@server/public /export/mnt"
39#	6. mount successfully
40#
41
42. $STF_SUITE/include/libtest.ksh
43
44tc_id="smbmount007"
45tc_desc=" Verify mutil user mount success with -o O"
46print_test_case $tc_id - $tc_desc
47
48if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
49	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
50    set -x
51fi
52
53server=$(server_name) || return
54
55# SKIP for now (mount -O needs privs)
56no_tested || return
57
58testdir_init $TDIR
59smbmount_clean $TMNT
60smbmount_init $TMNT
61
62cmd="mount -F smbfs -o noprompt //$AUSER:$APASS@$server/public $TMNT"
63cti_execute -i '' FAIL $cmd
64if [[ $? != 0 ]]; then
65	cti_fail "FAIL: smbmount can't mount the public share"
66	return
67else
68	cti_report "PASS: smbmount mount the public share successfully"
69fi
70
71smbmount_check $TMNT || return
72
73cmd="cp /usr/bin/ls $TMNT/$AUSER"
74cti_execute_cmd $cmd
75if [[ $? != 0 ]]; then
76	cti_fail "FAIL: failed to create the file by $AUSER"
77	return
78else
79	cti_report "PASS: create the file by $AUSER successfully"
80fi
81
82cmd="rm -rf $TMNT/$AUSER"
83cti_execute_cmd $cmd
84
85cmd="mount -F smbfs -O -o noprompt //$BUSER:$BPASS@$server/public $TMNT"
86cti_execute -i '' FAIL $cmd
87if [[ $? != 0 ]]; then
88	cti_fail "FAIL: the second mount with $BUSER failed"
89	return
90else
91	cti_report "PASS: the second mount with $BUSER successfully"
92fi
93
94smbmount_check $TMNT || return
95
96cmd="cp /usr/bin/ls  $TMNT/$BUSER"
97cti_execute_cmd $cmd
98if [[ $? != 0 ]]; then
99	cti_fail "FAIL: failed to create the file by the $BUSER"
100	return
101else
102	cti_report "PASS: create the file by the $BUSER successfully"
103fi
104
105cmd="rm -rf $TMNT/$BUSER"
106cti_execute_cmd $cmd
107
108cmd="umount $TMNT"
109cti_execute_cmd $cmd
110if [[ $? != 0 ]]; then
111	cti_fail "FAIL: failed to umount the $TMNT"
112	return
113else
114	cti_report "PASS: umount the $TMNT successfully"
115fi
116
117cmd="umount $TMNT"
118cti_execute_cmd $cmd
119if [[ $? != 0 ]]; then
120	cti_fail "FAIL: the second umount the $TMNT failed"
121	return
122else
123	cti_report "PASS: the second umount the $TMNT successfully"
124fi
125
126smbmount_clean $TMNT
127cti_pass "${tc_id}: PASS"
128