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: smbmount_005
  29 #
  30 # DESCRIPTION:
  31 #        Verify "mount -F smbfs -O" work well
  32 #
  33 # STRATEGY:
  34 #       1. create user "$AUSER" and "$BUSER"
  35 #       2. run "mount -F smbfs //$AUSER:$APASS@$server/a_share $TMNT"
  36 #       3. mount successfully
  37 #       4. run "mount -F smbfs -O //$BUSER:$BPASS@$server/b_share $TMNT"
  38 #       5. mount successfully
  39 #
  40 
  41 . $STF_SUITE/include/libtest.ksh
  42 
  43 tc_id="smbmount005"
  44 tc_desc="-O work well"
  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 testdir_init $TDIR
  55 smbmount_clean $TMNT
  56 smbmount_init $TMNT
  57 
  58 cmd="mount -F smbfs -o noprompt //$AUSER:$APASS@$server/a_share $TMNT"
  59 cti_execute -i '' FAIL $cmd
  60 if [[ $? != 0 ]]; then
  61         cti_fail "FAIL: smbmount can't mount the share a_share with user $AUSER"
  62         return
  63 else
  64         cti_report "PASS: smbmount can mount the share a_share with user $AUSER"
  65 fi
  66 
  67 smbmount_check $TMNT || return
  68 
  69 # cp file
  70 cmd="cp /usr/bin/ls $TMNT/ls_file"
  71 cti_execute_cmd $cmd
  72 if [[ $? != 0 ]]; then
  73         cti_fail "FAIL: failed to cp the /usr/bin/ls file"
  74         return
  75 else
  76         cti_report "PASS: cp the /usr/bin/ls file successfully"
  77 fi
  78 
  79 cmd="diff /usr/bin/ls $TMNT/ls_file"
  80 cti_execute_cmd $cmd
  81 if [[ $? != 0 ]]; then
  82         cti_fail "FAIL: the file /usr/bin/ls is different with file ls_file"
  83         return
  84 else
  85         cti_report "PASS: the file /usr/bin/ls is same to the ls_file file"
  86 fi
  87 
  88 cmd="mount -F smbfs -O -o noprompt //$BUSER:$BPASS@$server/a_share $TMNT"
  89 cti_execute -i '' FAIL sudo -n $cmd
  90 if [[ $? != 0 ]]; then
  91         cti_fail "FAIL: smbmount can't mount the share a_share on the same point twice with -O option"
  92         return
  93 else
  94         cti_report "PASS: smbmount can mount the share a_share on the same point twice with -O option"
  95 fi
  96 
  97 smbmount_check $TMNT || {
  98   cti_execute_cmd sudo -n "umount $TMNT"
  99   return 1
 100 }
 101 
 102 cmd="diff /usr/bin/ls $TMNT/ls_file"
 103 cti_execute_cmd sudo -n $cmd
 104 if [[ $? != 0 ]]; then
 105         cti_fail "FAIL: the second diff file /usr/bin/ls is different with the ls_file file"
 106         return
 107 else
 108         cti_report "PASS: the second diff file /usr/bin/ls is same to the ls_file file"
 109 fi
 110 
 111 # cp file
 112 cmd="cp /usr/bin/rm $TMNT/rm_file"
 113 cti_execute_cmd sudo -n $cmd
 114 if [[ $? != 0 ]]; then
 115         cti_fail "FAIL: failed to cp the /usr/bin/rm file"
 116         return
 117 else
 118         cti_report "PASS: cp the file /usr/bin/rm successfully"
 119 fi
 120 
 121 cmd="diff /usr/bin/rm $TMNT/rm_file"
 122 cti_execute_cmd sudo -n $cmd
 123 if [[ $? != 0 ]]; then
 124         cti_fail "FAIL: the file /usr/bin/rm is different with the rm_file file"
 125         return
 126 else
 127         cti_report "PASS: the file /usr/bin/rm is same to the rm_file file"
 128 fi
 129 
 130 cmd="umount $TMNT"
 131 cti_execute_cmd sudo -n $cmd
 132 if [[ $? != 0 ]]; then
 133         cti_fail "FAIL: the first umount $TMNT is failed "
 134         return
 135 else
 136         cti_report "PASS: the first umount $TMNT is successful"
 137 fi
 138 
 139 cmd="diff /usr/bin/ls $TMNT/ls_file"
 140 cti_execute_cmd sudo -n $cmd
 141 if [[ $? != 0 ]]; then
 142         cti_fail "FAIL:the third diff:file /usr/bin/ls is different with file ls_file"
 143         return
 144 else
 145         cti_report "PASS:the third diff:file /usr/bin/ls is same to file ls_file"
 146 fi
 147 cmd="diff /usr/bin/rm $TMNT/rm_file"
 148 cti_execute_cmd sudo -n $cmd
 149 if [[ $? != 0 ]]; then
 150         cti_fail "FAIL: the fourth diff:file /usr/bin/rm is different with file rm_file"
 151         return
 152 else
 153         cti_report "PASS: the fourth diff:file /usr/bin/rm is same to the rm_file file"
 154 fi
 155 
 156 cmd="umount $TMNT"
 157 cti_execute_cmd sudo -n $cmd
 158 if [[ $? != 0 ]]; then
 159         cti_fail "FAIL: the second umount $TMNT is failed"
 160         return
 161 else
 162         cti_report "PASS: the second umount $TMNT is successful"
 163 fi
 164 
 165 smbmount_clean $TMNT
 166 cti_pass "${tc_id}: PASS"