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