Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / test / smbclient-tests / tests / sharectl / tp_sharectl_003.ksh
blobcc0944c0fa0968a44674934a46206cac15e76c36
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: sharectl_003
30 # DESCRIPTION:
31 # Verify password can work
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
41 . $STF_SUITE/include/libtest.ksh
43 tc_id="sharectl003"
44 tc_desc="Verify password can work"
45 print_test_case $tc_id - $tc_desc
47 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
48 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
49 set -x
52 smbmount_clean $TMNT
53 smbmount_init $TMNT
55 rm -rf ~root/.nsmbrc
57 server=$(server_name) || return
59 pass=$(smbutil crypt $TPASS)
60 SERVER=$(echo $server|tr "[:lower:]" "[:upper:]")
62 cmd="sharectl set -p section=$SERVER:$TUSER -p password=\$pass smbfs"
63 cti_execute_cmd $cmd
64 if [[ $? != 0 ]]; then
65 cti_fail "FAIL: sharectl set password in $SERVER section failed"
66 return
67 else
68 cti_report "PASS: sharectl set password in $SERVER section succeeded"
71 cmd="sharectl set -p section=$SERVER:$TUSER -p addr=$server smbfs"
72 cti_execute_cmd $cmd
73 if [[ $? != 0 ]]; then
74 cti_fail "FAIL: sharectl set addr in $SERVER section failed"
75 sharectl delsect $SERVER:$TUSER smbfs
76 return
77 else
78 cti_report "PASS: sharectl set addr in $SERVER section succeeded"
81 smbutil logout -a
83 # get rid of our connection first
84 cti_execute_cmd "smbutil discon //$TUSER1@$server"
85 sleep 1
87 cti_report "expect failure next"
88 cmd="smbutil view -N //$TUSER1@$server"
89 cti_execute -i '' PASS $cmd
90 if [[ $? == 0 ]]; then
91 cti_fail "FAIL: smbutil view succeeded for SERVER password by $TUSER1"
92 sharectl delsect $SERVER:$TUSER smbfs
93 return
94 else
95 cti_report "PASS: smbutil view ffailed for SERVER password by $TUSER1"
98 cmd="mount -F smbfs //$TUSER@$server/public $TMNT"
99 cti_execute -i '' FAIL $cmd
100 if [[ $? != 0 ]]; then
101 cti_fail "FAIL: smbmount can't mount the public share by $TUSER"
102 sharectl delsect $SERVER:$TUSER smbfs
103 return
104 else
105 cti_report "PASS: smbmount can mount the public share by $TUSER"
108 smbmount_check $TMNT
109 if [[ $? != 0 ]]; then
110 smbmount_clean $TMNT
111 sharectl delsect $SERVER:$TUSER smbfs
112 return
115 smbmount_clean $TMNT
116 sharectl delsect $SERVER:$TUSER smbfs
118 cti_pass "${tc_id}: PASS"