xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbutil/tp_smbutil_014.ksh (revision 6e6545bfaed3bab9ce836ee82d1abd8f2edba89a)
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_014
29#
30# DESCRIPTION:
31#        Verify smbutil logoutall can work
32#
33# STRATEGY:
34#	1. run "smbutil logoutall"
35#	2. smbutil logoutall and smbutil login -c can get right message
36#
37
38. $STF_SUITE/include/libtest.ksh
39
40tc_id="smbutil014"
41tc_desc="Verify smbutil logoutall can work"
42print_test_case $tc_id - $tc_desc
43
44if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
45	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
46    set -x
47fi
48
49# initialize
50sudo -n smbutil logoutall
51
52cmd="$EXPECT $SMBUTILEXP $TUSER \$TPASS"
53cti_execute_cmd $cmd
54if [[ $? != 0 ]]; then
55	cti_fail "FAIL: smbutil login failed to set passwd to $TUSER"
56	return
57else
58	cti_report "PASS: smbutil login failed to set passwd to $TUSER"
59fi
60
61cmd="smbutil login -c $TUSER | grep exists"
62cti_execute_cmd $cmd
63if [[ $? != 0 ]]; then
64	cti_fail "FAIL: '$TUSER' keychain doesn't exist"
65	return
66else
67	cti_report "PASS: '$TUSER' keychain exists"
68fi
69
70cmd="$EXPECT $SMBUTILEXP $AUSER \$APASS"
71cti_execute_cmd sudo -n -u $AUSER $cmd
72if [[ $? != 0 ]]; then
73	cti_fail "FAIL: smbutil login failed to set passwd to $TUSER"
74	return
75else
76	cti_report "PASS: smbutil login failed to set passwd to $TUSER"
77fi
78
79cmd="smbutil login -c $AUSER | grep exists"
80cti_execute_cmd sudo -n -u $AUSER $cmd
81if [[ $? != 0 ]]; then
82	cti_fail "FAIL: the keychain doesn't exist"
83	return
84else
85	cti_report "PASS: the keychain exists"
86fi
87
88cmd="sudo -n smbutil logoutall"
89cti_execute_cmd $cmd
90if [[ $? != 0 ]]; then
91	cti_fail "FAIL: smbutil logoutut can't work"
92	return
93else
94	cti_report "PASS: smbutil logoutut can work"
95fi
96
97cmd="smbutil login -c $TUSER | grep exists"
98cti_execute_cmd $cmd
99if [[ $? == 0 ]]; then
100	cti_fail "FAIL: the $TUSER keychain exists"
101	return
102else
103	cti_report "PASS: the $TUSER keychain doesn't exist"
104fi
105
106cmd="smbutil login -c $AUSER | grep exists"
107cti_execute_cmd sudo -n -u $AUSER $cmd
108if [[ $? == 0 ]]; then
109	cti_fail "FAIL: the $AUSER keychain exists"
110	return
111else
112	cti_report "PASS: the $AUSER keychain doesn't exist"
113fi
114
115cti_pass "${tc_id}: PASS"
116