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 # Copyright 2018 Nexenta Systems, Inc. All rights reserved.
26 #
27
28 #
29 # ID:nsmbrc003
30 #
31 # DESCRIPTION:
32 # Verify password can work
33 #
34 # STRATEGY:
35 # 1. create a .nsmbrc file
36 # 2. run "smbutil logoutall"
37 # 3. run "mount -F smbfs //$TUSER@$server/public $TMNT"
38 # 4. smbutil and mount can get right message
39 #
40
41 . $STF_SUITE/include/libtest.ksh
42
43 tc_id="nsmbrc003"
44 tc_desc=" Verify password can work"
45 print_test_case $tc_id - $tc_desc
46
47 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
48 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
49 set -x
50 fi
51
52 smbmount_clean $TMNT
53 smbmount_init $TMNT
54
55 server=$(server_name) || return
56
57 cti_execute_cmd "rm -f ~/.nsmbrc"
58 pass=$(smbutil crypt $TPASS)
59 SERVER=$(echo $server | tr "[:lower:]" "[:upper:]")
60 echo "[$SERVER:$TUSER]" > ~/.nsmbrc
61 echo "addr=$server" >> ~/.nsmbrc
62 echo "password=$pass" >> ~/.nsmbrc
63 cti_execute_cmd "chmod 600 ~/.nsmbrc"
64
65 smbutil logout -a
66
67 # get rid of our connections
68 cti_execute_cmd "smbutil discon //$TUSER@$server"
69 cti_execute_cmd "smbutil discon //$TUSER1@$server"
70 sleep 1
71
72 cti_report "expect failure with $TUSER1"
73 cmd="smbutil view -N //$TUSER1@$server"
74 cti_execute -i '' PASS $cmd
75 if [[ $? == 0 ]]; then
76 cti_fail "FAIL: $SERVER:$TUSER works for $TUSER1"
77 return
78 else
79 cti_report "PASS: $SERVER:$TUSER does't work for $TUSER1"
80 fi
81
82 cti_report "expect success with $TUSER"
83 cmd="truss -f -o smbutil.to smbutil view -N //$TUSER@$server"
84 cti_execute -i '' PASS $cmd
85 if [[ $? == 0 ]]; then
86 cti_pass "PASS: $SERVER:$TUSER works for $TUSER"
87 else
88 cti_fail "FAIL: $SERVER:$TUSER does't work for $TUSER"
89 return
90 fi
91
92 cmd="mount -F smbfs //$TUSER@$server/public $TMNT"
93 cti_execute -i '' FAIL $cmd
94 if [[ $? != 0 ]]; then
95 cti_fail "FAIL: $SERVER:$TUSER does't work for $TUSER"
96 return
97 else
98 cti_report "PASS: $SERVER:$TUSER works for $TUSER"
99 fi
100
101 smbmount_check $TMNT
102 if [[ $? != 0 ]]; then
103 smbmount_clean $TMNT
104 return
105 fi
106
107 cti_execute_cmd "rm -f ~/.nsmbrc"
108 smbmount_clean $TMNT
109
110 cti_pass "${tc_id}: PASS"