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 
  40 tc_id="smbutil014"
  41 tc_desc="Verify smbutil logoutall can work"
  42 print_test_case $tc_id - $tc_desc
  43 
  44 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
  45         [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
  46     set -x
  47 fi
  48 
  49 # initialize
  50 sudo -n smbutil logoutall
  51 
  52 cmd="$EXPECT $SMBUTILEXP $TUSER \$TPASS"
  53 cti_execute_cmd $cmd
  54 if [[ $? != 0 ]]; then
  55         cti_fail "FAIL: smbutil login failed to set passwd to $TUSER"
  56         return
  57 else
  58         cti_report "PASS: smbutil login failed to set passwd to $TUSER"
  59 fi
  60 
  61 cmd="smbutil login -c $TUSER | grep exists"
  62 cti_execute_cmd $cmd
  63 if [[ $? != 0 ]]; then
  64         cti_fail "FAIL: '$TUSER' keychain doesn't exist"
  65         return
  66 else
  67         cti_report "PASS: '$TUSER' keychain exists"
  68 fi
  69 
  70 cmd="$EXPECT $SMBUTILEXP $AUSER \$APASS"
  71 cti_execute_cmd sudo -n -u $AUSER $cmd
  72 if [[ $? != 0 ]]; then
  73         cti_fail "FAIL: smbutil login failed to set passwd to $TUSER"
  74         return
  75 else
  76         cti_report "PASS: smbutil login failed to set passwd to $TUSER"
  77 fi
  78 
  79 cmd="smbutil login -c $AUSER | grep exists"
  80 cti_execute_cmd sudo -n -u $AUSER $cmd
  81 if [[ $? != 0 ]]; then
  82         cti_fail "FAIL: the keychain doesn't exist"
  83         return
  84 else
  85         cti_report "PASS: the keychain exists"
  86 fi
  87 
  88 cmd="sudo -n smbutil logoutall"
  89 cti_execute_cmd $cmd
  90 if [[ $? != 0 ]]; then
  91         cti_fail "FAIL: smbutil logoutut can't work"
  92         return
  93 else
  94         cti_report "PASS: smbutil logoutut can work"
  95 fi
  96 
  97 cmd="smbutil login -c $TUSER | grep exists"
  98 cti_execute_cmd $cmd
  99 if [[ $? == 0 ]]; then
 100         cti_fail "FAIL: the $TUSER keychain exists"
 101         return
 102 else
 103         cti_report "PASS: the $TUSER keychain doesn't exist"
 104 fi
 105 
 106 cmd="smbutil login -c $AUSER | grep exists"
 107 cti_execute_cmd sudo -n -u $AUSER $cmd
 108 if [[ $? == 0 ]]; then
 109         cti_fail "FAIL: the $AUSER keychain exists"
 110         return
 111 else
 112         cti_report "PASS: the $AUSER keychain doesn't exist"
 113 fi
 114 
 115 cti_pass "${tc_id}: PASS"