xref: /illumos-gate/usr/src/test/smbclient-tests/tests/sharectl/tp_sharectl_005.ksh (revision bde334a8dbd66dfa70ce4d7fc9dcad6e1ae45fe4)
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: sharectl_005
29#
30# DESCRIPTION:
31#        Verify user and domain work in sharctl "default" section
32#
33# STRATEGY:
34#       1. run "sharectl set -p section=default -p password=$pass smbfs"
35#       2. run "sharectl set -p section=default -p user=$TUSER smbfs"
36#       3. run "sharectl set -p section=default -p domain=mydomain smbf"
37#       2. run "mount -F smbfs //$server/public $TMNT"
38#       3. sharectl and mount can get right message
39#
40
41. $STF_SUITE/include/libtest.ksh
42
43tc_id="sharectl005"
44tc_desc="Test user and domain in sharctl [default] section."
45print_test_case $tc_id - $tc_desc
46
47if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
48	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
49    set -x
50fi
51
52server=$(server_name) || return
53
54smbmount_clean $TMNT
55smbmount_init $TMNT
56
57pass=$(smbutil crypt $TPASS)
58cmd="sharectl set -p section=default -p password=\$pass smbfs"
59cti_execute_cmd $cmd
60if [[ $? != 0 ]]; then
61	cti_fail "FAIL: sharectl set password in default section failed"
62	return
63else
64	cti_report "PASS: sharectl set password in default section succeeded"
65fi
66cmd="sharectl set -p section=default -p user=$TUSER smbfs"
67cti_execute_cmd $cmd
68if [[ $? != 0 ]]; then
69	cti_fail "sharectl set user in default section failed"
70	sharectl delsect default smbfs
71	return
72else
73	cti_report "PASS: sharectl set user in default section succeeded"
74fi
75cmd="sharectl set -p section=default -p domain=mydomain smbfs"
76cti_execute_cmd $cmd
77if [[ $? != 0 ]]; then
78	cti_fail "sharectl set domain in default section failed"
79	sharectl delsect default smbfs
80	return
81else
82	cti_report "PASS sharectl set domain in default section succeeded"
83fi
84
85cmd="smbutil view //$server"
86cti_execute -i '' FAIL $cmd
87if [[ $? != 0 ]]; then
88	cti_fail "FAIL: smbutil view failed for user and domain properity"
89	sharectl delsect default smbfs
90	return
91else
92	cti_report "PASS: smbutil view suceeded for user and domain properity"
93fi
94
95cmd="mount -F smbfs //$server/public $TMNT"
96cti_execute -i '' FAIL $cmd
97if [[ $? != 0 ]]; then
98	cti_fail "FAIL: smbmount can't mount the public share"
99	sharectl delsect default smbfs
100	return
101else
102	cti_report "PASS: smbmount can mount the public share"
103fi
104
105smbmount_check $TMNT
106if [[ $? != 0 ]]; then
107	sharectl delsect default smbfs
108	smbmount_clean $TMNT
109	return
110fi
111
112smbmount_clean $TMNT
113sharectl delsect default smbfs
114
115cti_pass "${tc_id}: PASS"
116