xref: /illumos-gate/usr/src/test/smbclient-tests/tests/sharectl/tp_sharectl_003.ksh (revision dcdeca0a948b9d3139743db085d193c9db8ff2a3)
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: sharectl_003
29#
30# DESCRIPTION:
31#        Verify password can work
32#
33# STRATEGY:
34#       1. run "sharectl set -p section=$SERVER:$TUSER -p password=$pass smbfs"
35#       2. run "sharectl set -p section=$SERVER:$TUSER -p addr=$server smbfs"
36#       3. run "smbutil view //$TUSER1@$server"
37#       4. run "mount -F smbfs //$TUSER@$server/public $TMNT"
38#       3. sharectl, smbutil and mount can get right message
39#
40
41. $STF_SUITE/include/libtest.ksh
42
43tc_id="sharectl003"
44tc_desc="Verify password can work"
45print_test_case $tc_id - $tc_desc
46
47if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
48	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
49    set -x
50fi
51
52smbmount_clean $TMNT
53smbmount_init $TMNT
54
55rm -rf ~root/.nsmbrc
56
57server=$(server_name) || return
58
59pass=$(smbutil crypt $TPASS)
60SERVER=$(echo $server|tr "[:lower:]" "[:upper:]")
61
62cmd="sharectl set -p section=$SERVER:$TUSER -p password=\$pass smbfs"
63cti_execute_cmd $cmd
64if [[ $? != 0 ]]; then
65	cti_fail "FAIL: sharectl set password in $SERVER section failed"
66	return
67else
68	cti_report "PASS: sharectl set password in $SERVER section succeeded"
69fi
70
71cmd="sharectl set -p section=$SERVER:$TUSER -p addr=$server smbfs"
72cti_execute_cmd $cmd
73if [[ $? != 0 ]]; then
74	cti_fail "FAIL: sharectl set addr in $SERVER section failed"
75	sharectl delsect  $SERVER:$TUSER smbfs
76	return
77else
78	cti_report "PASS: sharectl set addr in $SERVER section succeeded"
79fi
80
81smbutil logout -a
82
83# get rid of our connection first
84cti_execute_cmd "smbutil discon //$TUSER1@$server"
85sleep 1
86
87cti_report "expect failure next"
88cmd="smbutil view -N //$TUSER1@$server"
89cti_execute -i '' PASS $cmd
90if [[ $? == 0 ]]; then
91	cti_fail "FAIL: smbutil view succeeded for SERVER password by $TUSER1"
92	sharectl delsect  $SERVER:$TUSER smbfs
93	return
94else
95	cti_report "PASS: smbutil view ffailed for SERVER password by $TUSER1"
96fi
97
98cmd="mount -F smbfs //$TUSER@$server/public $TMNT"
99cti_execute -i '' FAIL $cmd
100if [[ $? != 0 ]]; then
101	cti_fail "FAIL: smbmount can't mount the public share by $TUSER"
102	sharectl delsect  $SERVER:$TUSER smbfs
103	return
104else
105	cti_report "PASS: smbmount can mount the public share by $TUSER"
106fi
107
108smbmount_check $TMNT
109if [[ $? != 0 ]]; then
110	smbmount_clean $TMNT
111	sharectl delsect  $SERVER:$TUSER smbfs
112	return
113fi
114
115smbmount_clean $TMNT
116sharectl delsect  $SERVER:$TUSER smbfs
117
118cti_pass "${tc_id}: PASS"
119