xref: /illumos-gate/usr/src/test/smbclient-tests/tests/sharectl/tp_sharectl_006.ksh (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
1#!/bin/ksh -p
2
3#
4# CDDL HEADER START
5#
6# The contents of this file are subject to the terms of the
7# Common Development and Distribution License (the "License").
8# You may not use this file except in compliance with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23
24#
25# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
26#
27
28#
29# ID: sharectl_006
30#
31# DESCRIPTION:
32#        Verify user and domain can work in sharectl "$SERVER" section
33#
34# STRATEGY:
35#       1. run "sharectl set -p section=$SERVER -p password=$pass smbfs"
36#       2. run "sharectl set -p section=$SERVER -p user=$TUSER smbfs"
37#       3. run "sharectl set -p section=$SERVER -p domain=mydomain smbfs"
38#       4. run "smbutil view //$server"
39#       5. run "mount -F smbfs //$server/public $TMNT"
40#       3. sharectl, smbutil and mount can get right message
41#
42
43. $STF_SUITE/include/libtest.ksh
44
45tc_id="sharectl006"
46tc_desc="Test user and domain in sharectl [server] section."
47print_test_case $tc_id - $tc_desc
48
49if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
50	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
51    set -x
52fi
53
54server=$(server_name) || return
55
56smbmount_clean $TMNT
57smbmount_init $TMNT
58
59pass=$(smbutil crypt $TPASS)
60SERVER=$(echo $server|tr "[:lower:]" "[:upper:]")
61
62cmd="sharectl set -p section=$SERVER -p password=\$pass smbfs"
63cti_execute_cmd $cmd
64if [[ $? != 0 ]]; then
65	cti_fail "FAIL: sharectl set password in SERVER section failed"
66	sharectl delsect $SERVER smbfs
67	return
68else
69	cti_report "PASS: sharectl set password in SERVER section succeeded"
70fi
71
72cmd="sharectl set -p section=$SERVER -p user=$TUSER smbfs"
73cti_execute_cmd $cmd
74if [[ $? != 0 ]]; then
75	cti_fail "FAIL: sharectl set user in SERVER section failed"
76	sharectl delsect $SERVER smbfs
77	return
78else
79	cti_report "PASS: sharectl set user in SERVER section succeeded"
80fi
81
82cmd="sharectl set -p section=$SERVER -p domain=mydomain smbfs"
83cti_execute_cmd $cmd
84if [[ $? != 0 ]]; then
85	cti_fail "FAIL: sharectl set user in SERVER section failed"
86	sharectl delsect $SERVER smbfs
87	return
88else
89	cti_report "PASS: sharectl set user in SERVER section succeeded"
90fi
91
92cmd="smbutil view //$server"
93cti_execute -i '' FAIL $cmd
94if [[ $? != 0 ]]; then
95	cti_fail "FAIL: smbutil view failed for user and domain properity"
96	sharectl delsect $SERVER smbfs
97	return
98else
99	cti_report "PASS: smbutil view succeeded for user and domain properity"
100fi
101
102cmd="mount -F smbfs //$server/public $TMNT"
103cti_execute -i '' FAIL $cmd
104if [[ $? != 0 ]]; then
105	cti_fail "FAIL: smbmount can't mount the public share"
106	sharectl delsect $SERVER smbfs
107	return
108else
109	cti_report "PASS: smbmount can mount the public share"
110fi
111
112smbmount_check $TMNT
113if [[ $? != 0 ]]; then
114	smbmount_clean $TMNT
115	sharectl delsect $SERVER smbfs
116	return
117fi
118
119smbmount_clean $TMNT
120sharectl delsect $SERVER smbfs
121
122cti_pass "${tc_id}: PASS"
123