xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbutil/tp_smbutil_005.ksh (revision 4db555a5389470c6f15aa8b50a38ca5d533d0641)
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: smbutil_005
29#
30# DESCRIPTION:
31#        Verify smbutil logoutall could work
32#
33# STRATEGY:
34#	1. set up smb server on a test machine
35#	2. run "smbutil logoutall"
36#	3. smbutil logout and smbutil login can get the right message
37#
38
39. $STF_SUITE/include/libtest.ksh
40
41tc_id="smbutil005"
42tc_desc="Verify smbutil logout could work"
43print_test_case $tc_id - $tc_desc
44
45if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
46	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
47    set -x
48fi
49
50server=$(server_name) || return
51
52# initialize
53sudo -n smbutil logoutall
54
55cmd="$EXPECT $SMBUTILEXP $TUSER $TPASS"
56cti_execute_cmd $cmd
57if [[ $? != 0 ]]; then
58	cti_fail "FAIL: smbutil login failed to set passwd"
59	return
60else
61	cti_report "PASS: smbutil login succeeded to set passwd"
62fi
63
64cmd="smbutil login -c $TUSER | grep exists"
65cti_execute_cmd $cmd
66if [[ $? != 0 ]]; then
67	cti_fail "FAIL: keychain doesn't exist"
68	return
69else
70	cti_report "PASS: keychain exists"
71fi
72
73cmd="smbutil view //$TUSER@$server"
74cti_execute -i '' FAIL $cmd
75if [[ $? != 0 ]]; then
76	cti_fail "FAIL: smbutil can't view shares"
77	return
78else
79	cti_report "PASS: smbutil can view shares"
80fi
81
82parse_view_output public cti_stdout
83if [[ $? != 0 ]]; then
84	cti_fail "FAIL: smbutil view can't get the public share"
85	return
86else
87	cti_report "PASS: smbutil view can get the public share"
88fi
89
90cmd="smbutil logout $TUSER"
91cti_execute_cmd $cmd
92if [[ $? != 0 ]]; then
93	cti_fail "FAIL: smbutil logout failed"
94	return
95else
96	cti_report "PASS: smbutil logout succeeded"
97fi
98
99cmd="smbutil login -c $TUSER | grep exists"
100cti_execute_cmd $cmd
101if [[ $? == 0 ]]; then
102	cti_fail "FAIL: keychain exists"
103	return
104else
105	cti_report "PASS: keychain doesn't exist"
106fi
107
108# get rid of our connection first
109cti_execute_cmd "smbutil discon //$TUSER@$server"
110sleep 1
111
112cti_report "expect failure next"
113cmd="smbutil view -N //$TUSER@$server"
114cti_execute -i '' PASS $cmd
115if [[ $? == 0 ]]; then
116	cti_execute_cmd "echo ::nsmb_vc|mdb -k"
117	cti_fail "FAIL: smbutil can view shares"
118	return
119else
120	cti_report "PASS: smbutil can't view shares"
121fi
122
123cti_pass "${tc_id}: PASS"
124