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_003
  29 #
  30 # DESCRIPTION:
  31 #        Verify password can work
  32 #
  33 # STRATEGY:
  34 #       1. run "sharectl set -p section=$SERVER:$TUSER -p password=$pass smbfs"
  35 #       2. run "sharectl set -p section=$SERVER:$TUSER -p addr=$server smbfs"
  36 #       3. run "smbutil view //$TUSER1@$server"
  37 #       4. run "mount -F smbfs //$TUSER@$server/public $TMNT"
  38 #       3. sharectl, smbutil and mount can get right message
  39 #
  40 
  41 . $STF_SUITE/include/libtest.ksh
  42 
  43 tc_id="sharectl003"
  44 tc_desc="Verify password can work"
  45 print_test_case $tc_id - $tc_desc
  46 
  47 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
  48         [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
  49     set -x
  50 fi
  51 
  52 smbmount_clean $TMNT
  53 smbmount_init $TMNT
  54 
  55 rm -rf ~root/.nsmbrc
  56 
  57 server=$(server_name) || return
  58 
  59 pass=$(smbutil crypt $TPASS)
  60 SERVER=$(echo $server|tr "[:lower:]" "[:upper:]")
  61 
  62 cmd="sharectl set -p section=$SERVER:$TUSER -p password=\$pass smbfs"
  63 cti_execute_cmd $cmd
  64 if [[ $? != 0 ]]; then
  65         cti_fail "FAIL: sharectl set password in $SERVER section failed"
  66         return
  67 else
  68         cti_report "PASS: sharectl set password in $SERVER section succeeded"
  69 fi
  70 
  71 cmd="sharectl set -p section=$SERVER:$TUSER -p addr=$server smbfs"
  72 cti_execute_cmd $cmd
  73 if [[ $? != 0 ]]; then
  74         cti_fail "FAIL: sharectl set addr in $SERVER section failed"
  75         sharectl delsect  $SERVER:$TUSER smbfs
  76         return
  77 else
  78         cti_report "PASS: sharectl set addr in $SERVER section succeeded"
  79 fi
  80 
  81 smbutil logout -a
  82 
  83 # get rid of our connection first
  84 cti_execute_cmd "smbutil discon //$TUSER1@$server"
  85 sleep 1
  86 
  87 cti_report "expect failure next"
  88 cmd="smbutil view -N //$TUSER1@$server"
  89 cti_execute -i '' PASS $cmd
  90 if [[ $? == 0 ]]; then
  91         cti_fail "FAIL: smbutil view succeeded for SERVER password by $TUSER1"
  92         sharectl delsect  $SERVER:$TUSER smbfs
  93         return
  94 else
  95         cti_report "PASS: smbutil view ffailed for SERVER password by $TUSER1"
  96 fi
  97 
  98 cmd="mount -F smbfs //$TUSER@$server/public $TMNT"
  99 cti_execute -i '' FAIL $cmd
 100 if [[ $? != 0 ]]; then
 101         cti_fail "FAIL: smbmount can't mount the public share by $TUSER"
 102         sharectl delsect  $SERVER:$TUSER smbfs
 103         return
 104 else
 105         cti_report "PASS: smbmount can mount the public share by $TUSER"
 106 fi
 107 
 108 smbmount_check $TMNT
 109 if [[ $? != 0 ]]; then
 110         smbmount_clean $TMNT
 111         sharectl delsect  $SERVER:$TUSER smbfs
 112         return
 113 fi
 114 
 115 smbmount_clean $TMNT
 116 sharectl delsect  $SERVER:$TUSER smbfs
 117 
 118 cti_pass "${tc_id}: PASS"