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 user and domain can work
  33 #
  34 # STRATEGY:
  35 #       1. create a .nsmbrc file
  36 #       2. run "smbutil view //$server"
  37 #       3. run "mount -F smbfs //$server/public $TMNT"
  38 #       4. smbutil and mount can get the right message
  39 #
  40 
  41 . $STF_SUITE/include/libtest.ksh
  42 
  43 tc_id="nsmbrc005"
  44 tc_desc=" Verify user and domain in user section 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 server=$(server_name) || return
  53 
  54 cti_execute_cmd "rm -f ~/.nsmbrc"
  55 smbmount_clean $TMNT
  56 smbmount_init $TMNT
  57 
  58 pass=$(smbutil crypt $TPASS)
  59 echo "[default]" > ~/.nsmbrc
  60 echo "password=$pass" >> ~/.nsmbrc
  61 echo "user=$TUSER" >> ~/.nsmbrc
  62 echo "domain=mydomain" >> ~/.nsmbrc
  63 cti_execute_cmd chmod 600 ~/.nsmbrc
  64 
  65 cmd="smbutil view //$server"
  66 cti_execute -i '' FAIL $cmd
  67 if [[ $? != 0 ]]; then
  68         cti_fail "FAIL: user and domain property in default section doesn't work"
  69         return
  70 else
  71         cti_report "PASS: user and domain property in default section works"
  72 
  73 fi
  74 
  75 cmd="mount -F smbfs //$server/public $TMNT"
  76 cti_execute -i '' FAIL $cmd
  77 if [[ $? != 0 ]]; then
  78         cti_fail "FAIL: user and domain property in default section doesn't work" \
  79             "for smb mount"
  80         return
  81 else
  82         cti_report "PASS: user and domain properity in default section works for" \
  83            "smbmount"
  84 fi
  85 
  86 smbmount_check $TMNT
  87 if [[ $? != 0 ]]; then
  88         smbmount_clean $TMNT
  89         return
  90 fi
  91 
  92 cti_execute_cmd "rm -f ~/.nsmbrc"
  93 smbmount_clean $TMNT
  94 
  95 cti_pass "${tc_id}: PASS"