xref: /illumos-gate/usr/src/test/smbclient-tests/tests/nsmbrc/tp_nsmbrc_002.ksh (revision 8a2b682e57a046b828f37bcde1776f131ef4629f)
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
42tc_id="nsmbrc002"
43tc_desc="Verify password can work in nsmbrc"
44print_test_case $tc_id" - "$tc_desc
45
46if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
47	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
48    set -x
49fi
50
51server=$(server_name) || return
52
53cti_execute_cmd "rm -f ~/.nsmbrc"
54pass=$(smbutil crypt $TPASS)
55echo "[default]" > ~/.nsmbrc
56echo "password=$pass" >> ~/.nsmbrc
57cti_execute_cmd chmod 600 ~/.nsmbrc
58
59# kill any existing session first
60cti_execute_cmd "smbutil discon //$TUSER@$server"
61sleep 1
62
63cmd="smbutil view //$TUSER@$server"
64cti_execute -i '' FAIL $cmd
65if [[ $? != 0 ]]; then
66	cti_fail "FAIL: password property in default section doesn't work"
67	return
68else
69	cti_report "PASS: password property in default section works"
70fi
71
72
73SERVER=$(echo $server | tr "[:lower:]" "[:upper:]")
74echo "[$SERVER]" > ~/.nsmbrc
75echo "addr=$server" >> ~/.nsmbrc
76echo "password=$pass" >> ~/.nsmbrc
77cti_execute_cmd chmod 600 ~/.nsmbrc
78
79# kill any existing session first
80cti_execute_cmd "smbutil discon //$TUSER@$server"
81sleep 1
82
83cmd="smbutil view //$TUSER@$server"
84cti_execute -i '' FAIL $cmd
85if [[ $? != 0 ]]; then
86	cti_fail "FAIL: password property in SERVER section doesn't work"
87	return
88else
89	cti_report "PASS: password property in SERVER section works"
90fi
91
92cti_execute_cmd "rm -f ~/.nsmbrc"
93
94cti_pass "${tc_id}: PASS"
95