xref: /illumos-gate/usr/src/test/smbclient-tests/tests/nsmbrc/tp_nsmbrc_001.ksh (revision 96c8483a3fb53529bbf410957b0ad69cfb5d9229)
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:nsmbrc001
30#
31# DESCRIPTION:
32#        Verify minauth can work in default
33#
34# STRATEGY:
35#	1. create a .nsmbrc file include default section
36#	   minauth=kerberos
37#	2. run "smbutil view user@server and get the failure"
38#	3. create a .nsmbrc file include server section minauth=kerberos
39#	4. run "smbutil view user@server and get the failure"
40#
41
42. $STF_SUITE/include/libtest.ksh
43
44set -x
45
46tc_id="nsmbrc001"
47tc_desc="Verify minauth can work in default"
48print_test_case $tc_id" - "$tc_desc
49
50if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
51	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
52    set -x
53fi
54
55server=$(server_name) || return
56
57cti_execute_cmd "rm -f ~/.nsmbrc"
58echo "[default]
59minauth=kerberos" > ~/.nsmbrc
60
61# kill any existing session first
62cti_execute_cmd "smbutil discon //$TUSER@$server"
63sleep 1
64
65# this should fail
66cmd="smbutil view -N //$TUSER:$TPASS@$server"
67cti_execute -i '' PASS $cmd
68if [[ $? == 0 ]]; then
69	cti_execute_cmd "echo '::nsmb_vc' |sudo -n mdb -k"
70	cti_fail "FAIL: can pass authentication by minauth=kerberos"
71	return
72else
73	cti_report "PASS: can't pass authentication by minauth=kerberos"
74fi
75
76cti_execute_cmd "rm -f ~/.nsmbrc"
77
78cti_pass "${tc_id}: PASS"
79