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:nsmbrc002
30 #
31 # DESCRIPTION:
32 # Verify password can work
33 #
34 # STRATEGY:
35 # 1. create a .nsmbrc file
36 # 2. run "smbutil view //$TUSER@server"
37 # 3. password works fine
38 #
39
40 . $STF_SUITE/include/libtest.ksh
41
42 tc_id="nsmbrc002"
43 tc_desc="Verify password can work in nsmbrc"
44 print_test_case $tc_id" - "$tc_desc
45
46 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
47 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
48 set -x
49 fi
50
51 server=$(server_name) || return
52
53 cti_execute_cmd "rm -f ~/.nsmbrc"
54 pass=$(smbutil crypt $TPASS)
55 echo "[default]" > ~/.nsmbrc
56 echo "password=$pass" >> ~/.nsmbrc
57 cti_execute_cmd chmod 600 ~/.nsmbrc
58
59 # kill any existing session first
60 cti_execute_cmd "smbutil discon //$TUSER@$server"
61 sleep 1
62
63 cmd="smbutil view //$TUSER@$server"
64 cti_execute -i '' FAIL $cmd
65 if [[ $? != 0 ]]; then
66 cti_fail "FAIL: password property in default section doesn't work"
67 return
68 else
69 cti_report "PASS: password property in default section works"
70 fi
71
72
73 SERVER=$(echo $server | tr "[:lower:]" "[:upper:]")
74 echo "[$SERVER]" > ~/.nsmbrc
75 echo "addr=$server" >> ~/.nsmbrc
76 echo "password=$pass" >> ~/.nsmbrc
77 cti_execute_cmd chmod 600 ~/.nsmbrc
78
79 # kill any existing session first
80 cti_execute_cmd "smbutil discon //$TUSER@$server"
81 sleep 1
82
83 cmd="smbutil view //$TUSER@$server"
84 cti_execute -i '' FAIL $cmd
85 if [[ $? != 0 ]]; then
86 cti_fail "FAIL: password property in SERVER section doesn't work"
87 return
88 else
89 cti_report "PASS: password property in SERVER section works"
90 fi
91
92 cti_execute_cmd "rm -f ~/.nsmbrc"
93
94 cti_pass "${tc_id}: PASS"