1 #! /usr/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 2009 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 
  28 # the file is designed for "no delegation" tests on multi-clients
  29 # setup. It it called in the following way:
  30 #
  31 #    nodeleg <testfile> <remote_cmd> <local_cmd>
  32 #
  33 # the script will first create $testfile, and execute $remote_cmd,
  34 # and then execute $local_cmd and verify no delegation is granted.
  35 
  36 . ${STF_SUITE}/include/nfsgen.kshlib
  37 . ${STF_SUITE}/tests/delegation/include/delegation.kshlib
  38 
  39 NAME=$(basename $0)
  40 [[ :$NFSGEN_DEBUG: = *:${NAME}:* \
  41         || :${NFSGEN_DEBUG}: = *:all:* ]] && set -x
  42 
  43 local_testfile=$1
  44 remote_cmd=$2
  45 local_cmd=$3
  46 typeset pid
  47 
  48 function cleanup {
  49         retcode=$1
  50         RSH root $CLIENT2 "pkill file_operator"
  51         rm -f $local_testfile $STF_TMPDIR/local.out.$$ $STF_TMPDIR/$NAME.*.$$
  52         exit $retcode
  53 }
  54 
  55 remote_cmdname=$(echo $remote_cmd | cut -d\  -f1)
  56 remote_cmdname=$(basename $remote_cmdname)
  57 
  58 # create test file
  59 RUN_CHECK create_file_nodeleg $local_testfile || cleanup $STF_UNRESOLVED
  60 
  61 # run remote command background on 2nd client
  62 RSH root $CLIENT2 "$remote_cmd > $SRV_TMPDIR/$NAME.remote_cmd.$$" > $STF_TMPDIR/$NAME.err.$$ 2>&1 &
  63 pid=$!
  64 
  65 # make sure remote_cmd is running and ready
  66 wait_now 100 "RSH root $CLIENT2 grep I_am_ready $SRV_TMPDIR/$NAME.remote_cmd.$$" > /dev/null 2>&1
  67 if (( $? != 0 )); then
  68         echo "remote_command failed to be ready within 100 seconds"
  69         cat $STF_TMPDIR/$NAME.err.$$
  70         cleanup $STF_FAIL
  71 fi
  72 
  73 # run local comand, verify no delegation is granted 
  74 eval $local_cmd > $STF_TMPDIR/local.out.$$ 2>&1
  75 deleg_type=$(grep "return_delegation_type" $STF_TMPDIR/local.out.$$ \
  76         | nawk -F\= '{print $2'})
  77 
  78 if [[ $deleg_type -ne $NONE ]]; then
  79         print -u2 "unexpected delegation type($deleg_type)" 
  80         cat $STF_TMPDIR/local.out.$$
  81         cleanup $STF_FAIL
  82 fi
  83 
  84 # clean up 
  85 cleanup $STF_PASS