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 # Setup server test files/directories, export them, and check
  28 # that NFSv4 is registered.
  29 
  30 [[ -n $DEBUG ]] && [[ $DEBUG != 0 ]] && set -x
  31 
  32 NAME=$(basename $0)
  33 CDIR=$(dirname $0)
  34 NSPC=$(echo $NAME | sed 's/./ /g')
  35 TMPDIR=${TMPDIR:-"/var/tmp"}
  36 DEBUG=${DEBUG:-"0"}; export DEBUG       # export it for tcl.init
  37 
  38 # ================================ include =================================== #
  39 # sourcing framework global environment variables
  40 ENVFILE="./nfs4test.env"
  41 if [[ ! -f $ENVFILE ]]; then
  42         echo "$NAME: ENVFILE[$ENVFILE] not found;"
  43         echo "\texit UNINITIATED."
  44         exit 6
  45 fi
  46 . $ENVFILE
  47 
  48 # sourcing support functions
  49 LIBFILE="./testsh"
  50 if [[ ! -f $LIBFILE ]]; then
  51         echo "$NAME: LIBFILE[$LIBFILE] not found;"
  52         echo "\texit UNINITIATED."
  53         exit $UNINITIATED
  54 fi
  55 . $LIBFILE
  56 
  57 # check v4config file
  58 V4CFGFILE="./v4test.cfg"
  59 if [[ ! -f $V4CFGFILE ]]; then
  60         echo "$NAME: V4CFGFILE[$V4CFGFILE] not found;"
  61         echo "\texit UNINITIATED."
  62         exit $UNINITIATED
  63 fi
  64 . $V4CFGFILE
  65 
  66 # =============================== functions ================================== #
  67 function cleanup { # ensure umount MNTPTR & exit
  68         [[ -n $DEBUG && $DEBUG != 0 ]] && set -x
  69 
  70         mount -p | grep -w "$MNTPTR" > /dev/null 2>&1
  71         if (( $? != 0 )); then
  72                 rm -f $TMPDIR/*.$$
  73                 exit $1
  74         fi
  75 
  76         # Need to unmount the test directory
  77         umount $MNTPTR > $TMPDIR/$NAME.umount.$$ 2>&1
  78         if (( $? != 0 )); then
  79                 echo "$NAME: cleanup - umount $MNTPTR failed"
  80                 cat $TMPDIR/$NAME.umount.$$
  81         fi
  82 
  83         rm -f $TMPDIR/*.$$
  84         exit $1
  85 }
  86 
  87 # get full name of machine
  88 function get_fullname {
  89         [[ -n $DEBUG && $DEBUG != 0 ]] && set -x
  90 
  91         typeset mach=$1
  92         typeset res=$(get_domain $mach "FQDN")
  93 
  94         # if get_domain give no results, use the orginal value.
  95         [[ -z $res ]] && res=$mach
  96         echo $res
  97 
  98         ping $res > /dev/null 2>&1
  99         return $?
 100 }
 101 
 102 # ================================= main ===================================== #
 103 # must be root to run
 104 id | grep "0(root)" > /dev/null 2>&1
 105 if (( $? != 0 )); then
 106         echo "$NAME: Must be root to run this script."
 107         echo "\texit UNINITIATED."
 108         exit $UNINITIATED 
 109 fi
 110 
 111 # create config dir and config file
 112 CONFIGDIR=$(dirname $CONFIGFILE)
 113 [[ ! -d $CONFIGDIR ]] && mkdir -p $CONFIGDIR
 114 cat > $CONFIGFILE << __EOF__
 115 # Do NOT modify this file directly,
 116 # as it is created and only maintained by $NAME.
 117 #
 118 PATH=/usr/bin:/usr/sbin:/usr/lib/nfs:\$PATH; export PATH
 119 DEBUG=$DEBUG; export DEBUG
 120 CONFIGDIR=$CONFIGDIR; export CONFIGDIR
 121 __EOF__
 122 cat $V4CFGFILE | grep -v "^#" | sed '/^$/d' >> $CONFIGFILE
 123 cat $ENVFILE | grep -v "^#" | sed -e '/^$/d' \
 124         -e '/^BASEDIR=/d' -e '/^ROOTDIR=/d' -e '/^ROFSDIR=/d' \
 125         -e '/^NSPCDIR=/d' -e '/^QUOTADIR=/d' -e '/^PUBTDIR=/d' \
 126         -e '/^KRB5DIR=/d' -e '/^SSPCDIR=/d' -e '/^SSPCDIR2=/d' \
 127         -e '/^SSPCDIR3=/d' -e '/^NOTSHDIR=/d' >> $CONFIGFILE
 128 cat >> $CONFIGFILE << __EOF__
 129 BASEDIR=$BASEDIR; export BASEDIR
 130 ROOTDIR=$ROOTDIR; export ROOTDIR
 131 ROFSDIR=$ROFSDIR; export ROFSDIR
 132 NSPCDIR=$NSPCDIR; export NSPCDIR
 133 QUOTADIR=$QUOTADIR; export QUOTADIR
 134 PUBTDIR=$PUBTDIR; export PUBTDIR
 135 KRB5DIR=$KRB5DIR; export KRB5DIR
 136 SSPCDIR=$SSPCDIR; export SSPCDIR
 137 SSPCDIR2=$SSPCDIR2; export SSPCDIR2
 138 SSPCDIR3=$SSPCDIR3; export SSPCDIR3
 139 NOTSHDIR=$NOTSHDIR; export NOTSHDIR
 140 __EOF__
 141 
 142 # create the tmp directory if it doesn't exist.
 143 DATETAG=$(date +"%y-%m-%d-%H-%M-%S" | sed 's/-//'g)
 144 TMPDIR=$TMPDIR/TMPDIR-nfsv4-$DATETAG 
 145 [[ ! -d $TMPDIR ]] && mkdir -p $TMPDIR
 146 TMPDIR=$TMPDIR; export TMPDIR # export it for tcl.init
 147 echo "TMPDIR=$TMPDIR; export TMPDIR" >> $CONFIGFILE
 148 
 149 # create name of LOGDIR, JOURNAL_SETUP, JOURNAL_CLEANUP
 150 #LOGDIR=$LOGDIR/journal.$DATETAG.$(uname -p)
 151 echo "LOGDIR=$LOGDIR; export LOGDIR" >> $CONFIGFILE
 152 JOURNAL_SETUP=$LOGDIR/journal.setup
 153 echo "JOURNAL_SETUP=$JOURNAL_SETUP; export JOURNAL_SETUP"  >> $CONFIGFILE
 154 JOURNAL_CLEANUP=$LOGDIR/journal.cleanup
 155 echo "JOURNAL_CLEANUP=$JOURNAL_CLEANUP; export JOURNAL_CLEANUP" >> $CONFIGFILE
 156 
 157 # check the basic env variables - SERVER CLIENT
 158 if [[ -z $SERVER ]]; then
 159         echo "$NAME: SERVER must be defined."
 160         echo "\texit UNINITIATED."
 161         cleanup $UNINITIATED
 162 fi
 163 ping $SERVER > $TMPDIR/ping.out.$$ 2>&1
 164 if (( $? != 0 )); then
 165         echo "$NAME: SERVER=<$SERVER> not responding."
 166         echo "\texit UNINITIATED."
 167         cleanup $UNINITIATED
 168 fi
 169 SERVER=$(get_fullname $SERVER)
 170 if (( $? != 0 )); then
 171         echo "$NAME: get_fullname for SERVER<$SERVER> failed."
 172         echo "\texit UNINITIATED."
 173         cleanup $UNINITIATED
 174 fi
 175 SERVER=$SERVER; export SERVER # export it for tcl.init
 176 echo "SERVER=$SERVER; export SERVER" >> $CONFIGFILE
 177 
 178 CLIENT=$(get_fullname $(uname -n))
 179 if (( $? != 0 )); then
 180         echo "$NAME: get_fullname for CLIENT<$CLIENT> failed."
 181         echo "\texit UNINITIATED."
 182         exit $UNINITIATED
 183 fi
 184 echo "CLIENT=$CLIENT; export CLIENT" >> $CONFIGFILE
 185 
 186 tUDP=udp
 187 tTCP=tcp
 188 [[ $TRANSPORT == *6 ]] && tUDP=udp6 && tTCP=tcp6
 189 
 190 # Solaris NFS server does not support UDP
 191 if [[ $SRVOS == Solaris && $TRANSPORT = @(udp|udp6) ]]; then
 192         echo "$NAME: SRVOS<$SRVOS> does not support TRANSPORT<$TRANSPORT>\c"
 193         echo "for NFSv4;"
 194         echo "\tTesting is terminated."
 195         cleanup $UNSUPPORTED
 196 fi
 197 
 198 # check to support TX
 199 [[ -z $NFSMOPT ]] && TMPNFSMOPT="vers=4" || TMPNFSMOPT=$NFSMOPT
 200 iscipso=0
 201 is_cipso "$TMPNFSMOPT" $SERVER
 202 ret=$?
 203 if (( ret == CIPSO_NFSV2 )); then
 204         echo "$NAME: CIPSO NFSv2 not supported under Trusted Extensions"
 205         echo "\texit UNSUPPORTED."
 206         cleanup $UNSUPPORTED
 207 fi
 208 
 209 if (( ret == CIPSO_NFSV4 || ret == CIPSO_NFSV3 )); then
 210         cipso_check_mntpaths $BASEDIR $MNTPTR
 211         if (( $? != 0 )); then
 212                 echo "$NAME: UNSUPPORTED"
 213                 echo "$NAME: CIPSO NFSv4/v3 requires non-global zone mount dirs."
 214                 echo "$NSPC  The server's BASEDIR and client's MNTPTR"
 215                 echo "$NSPC  must contain path legs with matching"
 216                 echo "$NSPC  non-global zone paths."
 217                 echo "$NSPC: Please try again ..."
 218                 cleanup $UNSUPPORTED
 219         fi
 220         iscipso=1
 221 fi
 222 
 223 # Get the nfsv4shell program over if we do not have it yet
 224 if [[ ! -x $TESTROOT/nfsh || ! -f $TESTROOT/tclprocs ]]; then
 225         echo "$NAME: ERROR - Can't find nfsv4shell programs from $TESTROOT."
 226         echo "\tPlease check if <nfsh> and <tclprocs> are installed properly"
 227         cleanup $UNINITIATED
 228 fi
 229 
 230 if (( iscipso == 1 )); then
 231         ZONENAME=$(echo "$ZONE_PATH" | sed -e 's/\// /g' | awk '{print $2}')
 232         echo "ZONENAME=$ZONENAME; export ZONENAME" >> $CONFIGFILE
 233         cp $TESTROOT/nfsh $ZONE_PATH/root/
 234         cp $TESTROOT/tclprocs $ZONE_PATH/root/
 235 fi
 236 
 237 # Create a wrapper to start programs as root
 238 echo '#!/bin/sh -p\nexec $*' > /suexec
 239 chmod 7555 /suexec
 240 
 241 # setup the server ... add environment variables to srv_setup script:
 242 rm -f $TMPDIR/setserver
 243 sed -e "s%Tmpdir_from_client%$TMPDIR%" \
 244         -e "s%ENV_from_client%$(basename $CONFIGFILE)%" \
 245         -e "s%CONFIGDIR_from_client%$CONFIGDIR%" \
 246         -e "s%ZONE_PATH_from_client%$ZONE_PATH%" \
 247         -e "s%SETDEBUG%$SETD%" srv_setup > $TMPDIR/setserver
 248 if (( $? != 0 )); then
 249         echo "$NAME: can't setup [setserver] file."
 250         cleanup $UNINITIATED
 251 fi
 252 
 253 execute $SERVER root "mkdir -m 0777 -p $TMPDIR $CONFIGDIR" > /dev/null 2>&1
 254 
 255 # get test filesystem type from server
 256 scp getTestFSType root@$SERVER:$CONFIGDIR> $TMPDIR/$NAME.rcp.$$ 2>&1
 257 if (( $? != 0 )); then
 258         echo "$NAME: copying file<getTestFSType> to $SERVER failed:"
 259         cat $TMPDIR/$NAME.rcp.$$
 260         cleanup $UNINITIATED
 261 fi
 262 
 263 execute $SERVER root \
 264         "export DEBUG=$DEBUG; \
 265         /usr/bin/ksh $CONFIGDIR/getTestFSType $BASEDIR" \
 266         > $TMPDIR/$NAME.rsh.out.$$ 2> $TMPDIR/$NAME.rsh.err.$$
 267 ret=$?
 268 [[ -n $DEBUG && $DEBUG != 0 ]] && cat $TMPDIR/$NAME.rsh.err.$$
 269 grep "^OKAY " $TMPDIR/$NAME.rsh.out.$$ > /dev/null 2>&1
 270 if (( $? != 0 || ret != 0 )); then
 271         echo "$NAME: execute <getTestFSType> failed on <$SERVER>"
 272         cat $TMPDIR/$NAME.rsh.out.$$
 273         cat $TMPDIR/$NAME.rsh.err.$$
 274         cleanup $UNINITIATED
 275 fi
 276 
 277 strfs=$(cat $TMPDIR/$NAME.rsh.out.$$)
 278 fs_type=$(echo $strfs | awk '{print $2}')
 279 if [[ $fs_type == "ufs" ]]; then
 280         TestZFS=0
 281 elif [[ $fs_type == "zfs" ]]; then
 282         TestZFS=1
 283 else
 284         TestZFS=2
 285 fi
 286 if [[ $TestZFS == 2 ]]; then # fs is neither zfs nor ufs
 287         echo "$NAME: BASEDIR<$BASEDIR> on server<$SERVER> is based $fs_type,"
 288         echo "\t this test suite only supports UFS and ZFS!"
 289         cleanup $UNSUPPORTED
 290 fi
 291 if [[ $TestZFS == 1 ]]; then # fs is zfs
 292         zpool_name=$(echo $strfs | awk '{print $3}')
 293         ZFSDISK=$zpool_name
 294         echo "ZFSDISK=$ZFSDISK; export ZFSDISK" >> $CONFIGFILE
 295         zpool_stat=$(echo $strfs | awk '{print $4}')
 296         if [[ $zpool_stat != "ONLINE" ]]; then
 297                 echo "$NAME: BASEDIR<$BASEDIR> on server<$SERVER> is based ZFS,"
 298                 echo "\t but zpool<$zpool_name> is not online: $zpool_stat"
 299                 cat $TMPDIR/rsh.out.$$
 300                 cleanup $UNTESTED
 301         fi
 302 fi
 303 TestZFS=$TestZFS; export TestZFS # export it for tcl.init 
 304 echo "# What type of filesystem will run over: 0-UFS 1-ZFS" >> $CONFIGFILE
 305 echo "TestZFS=$TestZFS; export TestZFS=$TestZFS" >> $CONFIGFILE
 306 
 307 # ... now setup the $SERVER
 308 echo "Setting up server [$SERVER] now:"
 309 echo "\ttest filesystem is based <$BASEDIR> and whose fs is <$fs_type>"
 310 echo "\tthis will take a while. Please be patient ..."
 311 # copy server programs over to $SERVER for setup
 312 scp $TMPDIR/setserver ./mk_srvdir ./fillDisk ./setupFS \
 313         ./get_tunable ./set_nfstunable $CONFIGFILE ./libsmf.shlib \
 314         ./operate_dir root@$SERVER:$CONFIGDIR > $TMPDIR/rcp.out.$$ 2>&1
 315 if (( $? != 0 )); then
 316         echo "$NAME: copying files to $SERVER failed:"
 317         cat $TMPDIR/rcp.out.$$
 318         cleanup $OTHER
 319 fi
 320 
 321 execute $SERVER root "/usr/bin/ksh $CONFIGDIR/setserver -s" \
 322         > $TMPDIR/rsh.out.$$ 2>&1
 323 ret=$?
 324 grep "OKAY" $TMPDIR/rsh.out.$$ > /dev/null 2>&1
 325 if (( $? == 0 && ret == 0 )); then
 326         # If server returned some warning, print it out
 327         grep "WARNING" $TMPDIR/rsh.out.$$ > /dev/null 2>&1
 328         if (( $? == 0 )); then
 329                 echo "$NAME: setup $SERVER have warnings:"
 330                 grep WARNING $TMPDIR/rsh.out.$$
 331         fi
 332         [[ $DEBUG != 0 ]] && cat $TMPDIR/rsh.out.$$
 333 else
 334         grep "ERROR" $TMPDIR/rsh.out.$$ > /dev/null 2>&1
 335         if (( $? == 0 )); then
 336                 echo "$NAME: setup $SERVER had errors:"
 337         else
 338                 echo "$NAME: setup $SERVER failed:"
 339         fi
 340         cat $TMPDIR/rsh.out.$$
 341         cleanup $OTHER
 342 fi
 343 
 344 # Record shared information in journal file for debugging
 345 grep "^SHARE" $TMPDIR/rsh.out.$$
 346 
 347 # Save the server's NFS mapid domain
 348 NFSmapid_domain=$(grep "^SERVER_NFSmapid_Domain=" $TMPDIR/rsh.out.$$ |\
 349         awk -F\= '{print $2}')
 350 if [[ $? != 0 || -z $NFSmapid_domain ]]; then
 351         echo "$NAME: setup failed:"
 352         echo "ERROR: could not get SERVER<$SERVER>'s NFS mapid domain"
 353         grep "^SERVER"  $TMPDIR/rsh.out.$$
 354         cleanup $OTHER
 355 fi
 356 
 357 # check if the nfs tunable values meet the requirement, if not,
 358 # set the new values and save the old values to .nfs.flg file
 359 if [[ ! -f $CONFIGDIR/$CLIENT.nfs.flg ]]; then
 360     res=$(./set_nfstunable CLIENT_VERSMIN=2 CLIENT_VERSMAX=4 \
 361         NFSMAPID_DOMAIN=$NFSmapid_domain 2> $TMPDIR/svars.out.$$)
 362     if (( $? != 0 )); then
 363         echo "ERROR: cannot set the specific nfs tunable on $CLIENT"
 364         cat $TMPDIR/svars.out.$$
 365         echo "\texit UNINITIATED."
 366         cleanup $UNINITIATED
 367     else
 368         [[ -n $res ]] && echo $res > $CONFIGDIR/$CLIENT.nfs.flg
 369     fi
 370 fi
 371 
 372 # Now setup the client
 373 echo "Setting up client [$CLIENT] now."
 374 cp -p /etc/passwd /etc/passwd.orig
 375 cp -p /etc/group /etc/group.orig
 376 # remove users left from setups not cleaned
 377 /usr/xpg4/bin/egrep -v "2345678." /etc/passwd.orig > /etc/passwd 2>&1
 378 /usr/xpg4/bin/egrep -v "2345678." /etc/group.orig > /etc/group 2>&1
 379 # add test users ... should be same as in $SERVER
 380 echo "$TUSER1:x:23456787:10:NFSv4 Test User 1:$TMPDIR:/usr/bin/ksh" \
 381         >> /etc/passwd
 382 echo "$TUSER2:x:23456788:10:NFSv4 Test User 2:$TMPDIR:/usr/bin/ksh" \
 383         >> /etc/passwd
 384 echo "$TUSER3:x:23456789:1:NFSv4 Test User 3:$TMPDIR:/usr/bin/ksh" \
 385         >> /etc/passwd
 386 #except this entry
 387 echo "$TUSERC:x:$TUSERCID:10:NFSv4 Test User Client:$TMPDIR:/usr/bin/ksh" \
 388         >> /etc/passwd
 389 echo "$TUSERC2:x:$TUSERID:10:NFSv4 Test User Client 2:$TMPDIR:/usr/bin/ksh" \
 390         >> /etc/passwd
 391 echo "$TUSERC3:x:$TUSERCID3:10:NFSv4 Test User Client 3:$TMPDIR:/usr/bin/ksh" \
 392         >> /etc/passwd
 393 echo "$UTF8_USR:x:$TUSERUTF8:$TUSERUTF8:uts8 USER 1:$TMPDIR:/sbin/sh" \
 394         >> /etc/passwd
 395 echo "$UTF8_USR::$TUSERUTF8:" >> /etc/group
 396 
 397 pwconv  # make sure shadow file match
 398 N=1
 399 n=$(/usr/xpg4/bin/egrep "2345678." /etc/group | wc -l | nawk '{print $1}')
 400 if (( n != N )); then
 401         echo "ERROR: "\
 402         "$NAME: adding test groups failed, groups file shows n=$n not $N"
 403         cleanup $OTHER
 404 fi
 405 N=6
 406 n=$(/usr/xpg4/bin/egrep \
 407         "^$TUSER1|^$TUSER2|^$TUSER3|^$TUSERC|^$TUSERC2|^$TUSERC3" \
 408         /etc/shadow | wc -l | nawk '{print $1}')
 409 if (( n != N )); then
 410         echo "ERROR: "\
 411         "$NAME: adding normal test users failed, shadow file shows n=$n not $N"
 412         cleanup $OTHER
 413 fi
 414 
 415 res=$(locale | awk -F= '{print $2}' | grep -v "^$" | grep -v -w "C")
 416 if (( $? == 0 )); then
 417         echo "WARNING: locale not set to C. Some utf8 tests may fail."
 418         [[ $DEBUG != 0 ]] && echo "locale = $(locale)\n"
 419 else
 420         # this test is broken with some locales, so execute only with lang=C
 421         N=1
 422         n=$(/usr/xpg4/bin/egrep "^$(echo $UTF8_USR)" /etc/shadow | wc -l | \
 423                 nawk '{print $1}')
 424         if (( n != N )); then
 425                 echo "ERROR: $NAME: adding UTF8 test users failed, \
 426                         shadow file shows n=$n not $N"
 427                 [[ $DEBUG != 0 ]] && echo "locale = $(locale)\n"
 428                 cleanup $OTHER
 429         fi
 430 fi
 431 
 432 # NULL $TUSER2's passwd for QUOTA testing:
 433 sed "s/^$TUSER2:x:/$TUSER2::/" /etc/shadow > $TMPDIR/shadow.out.$$
 434 mv $TMPDIR/shadow.out.$$ /etc/shadow
 435 chmod 0400 /etc/shadow
 436 
 437 # get server lease time period
 438 $TESTROOT/nfsh $TESTROOT/getleasetm > $TMPDIR/getls.out1.$$ 2>&1
 439 LEASE_TIME=$(egrep "^[0-9]+" $TMPDIR/getls.out1.$$ 2>$TMPDIR/getls.err.$$)
 440 if (( $? != 0 )); then
 441         # get a default
 442         LEASE_TIME=90
 443         grep "ld.so.1: nfsh:" $TMPDIR/getls.out1.$$ \
 444                 grep "No such file" > /dev/null 2>&1
 445         if (( $? != 0 )); then
 446                 echo "$NAME: UNINITIATED - \c"
 447                 echo "TCL library is NOT installed in client <$CLIENT>"
 448                 echo "nfsv4shell<nfsh> failed to run:"
 449                 echo "  \c"
 450                 cat $TMPDIR/getls.out1.$$
 451                 echo ""
 452                 cleanup $UNINITIATED
 453         else
 454                 echo "Warning: could not get lease time from server $SERVER:"
 455                 echo "stderr = <$(cat $TMPDIR/getls.err.$$)>"
 456         fi
 457 fi
 458 rm -f $TMPDIR/getls.*.$$ > /dev/null 2>&1
 459 # check if grace period is different from the lease period
 460 grace=$(grep "^SERVER_GRACE_PERIOD=" $TMPDIR/rsh.out.$$ | awk -F\= '{print $2}')
 461 if [[ $? != 0 || -z $grace ]]; then
 462         echo "WARNING: could not get $SERVER's grace period"
 463         echo
 464         # use same default for grace as for LEASE_TIME (90 seconds)
 465         grace=90
 466 else
 467         # use upper case
 468         typeset -u grace
 469         # convert from hex to dec
 470         grace=$(echo "ibase=16\n$grace\n" | bc)
 471 fi
 472 if (( LEASE_TIME != grace )); then
 473         echo "IMPORTANT WARNING: server $SERVER internal variables modified:"
 474         echo "\tlease time ($LEASE_TIME) != grace time ($grace)"
 475         echo "\tit is recommended to set them to the same value,"
 476         echo "\totherwise some tests may fail. Assuming the largest value"
 477         (( LEASE_TIME < grace )) && LEASE_TIME=$grace
 478         echo "\ttrying to prevent failures ($LEASE_TIME seconds)"
 479 fi
 480 echo "LEASE_TIME=$LEASE_TIME; export LEASE_TIME" >> $CONFIGFILE
 481 
 482 # mount the server testdir in /mnt;
 483 [[ ! -d $MNTPTR ]] && mkdir -m 777 $MNTPTR > /dev/null 2>&1
 484 
 485 # check $SERVER support both tcp and udp
 486 # Trusted Extensions doesn't support CIPSO NFSv4 UDP
 487 is_cipso "vers=4" $SERVER
 488 if (( $? == CIPSO_NOT )); then
 489         umount -f $MNTPTR >/dev/null 2>&1
 490         mount -o proto=$tUDP $SERVER:$BASEDIR $MNTPTR \
 491             > $TMPDIR/$NAME.mnt.$$ 2>&1
 492         if (( $? != 0 )); then
 493                 echo "$NAME: UNINITIATED - \c"
 494                 echo "[mount -o proto=$tUDP $SERVER:$BASEDIR $MNTPTR] failed"
 495                 cat $TMPDIR/$NAME.mnt.$$
 496                 cleanup $UNINITIATED
 497         fi
 498 fi
 499 
 500 #Trusted Extensions support CIPSO NFSv3 UDP
 501 is_cipso "vers=3" $SERVER
 502 if (( $? == CIPSO_NFSV3 )); then
 503         umount -f $MNTPTR >/dev/null 2>&1
 504         mount -o proto=$tUDP,vers=3 $SERVER:$BASEDIR $MNTPTR \
 505             > $TMPDIR/$NAME.mnt.$$ 2>&1
 506         if (( $? != 0 )); then
 507                 echo "$NAME: UNINITIATED - \c"
 508                 echo "[mount -o proto=$tUDP,vers=3 $SERVER:$BASEDIR $MNTPTR]" \
 509                     "failed"
 510                 cat $TMPDIR/$NAME.mnt.$$
 511                 cleanup $UNINITIATED
 512         fi
 513 fi
 514 
 515 umount -f $MNTPTR >/dev/null 2>&1
 516 mount -o proto=$tTCP $SERVER:$BASEDIR $MNTPTR \
 517         > $TMPDIR/$NAME.mnt.$$ 2>&1
 518 if (( $? != 0 )); then
 519         echo "$NAME: UNINITIATED - \c"
 520         echo "[mount -o proto=$tTCP $SERVER:$BASEDIR $MNTPTR] failed"
 521         cat $TMPDIR/$NAME.mnt.$$
 522         cleanup $UNINITIATED
 523 fi
 524 
 525 umount -f $MNTPTR >/dev/null 2>&1
 526 mount -F nfs -o $NFSMOPT $SERVER:$BASEDIR $MNTPTR \
 527         > $TMPDIR/$NAME.mnt.$$ 2>&1
 528 if (( $? != 0 )); then
 529         echo "$NAME: UNINITIATED - can't mount [$SERVER:$BASEDIR] on [$MNTPTR]"
 530         cat $TMPDIR/$NAME.mnt.$$
 531         cleanup $UNINITIATED
 532 fi
 533 [[ -z $NFSMOPT ]] && NFSMOPT="default"
 534 echo "mount [NFSMOPT:$NFSMOPT] [$SERVER:$BASEDIR] on [$MNTPTR] OK"
 535 
 536 # Check the grace period as well, just in case
 537 echo "xxx" > $MNTPTR/wait_for_grace
 538 rm -f $MNTPTR/wait_for_grace > /dev/null 2>&1
 539 
 540 echo "$NAME: SERVER=$SERVER setup OK!!"
 541 echo "$NAME: CLIENT=$CLIENT ready for testing!!"
 542 
 543 # print client and server information
 544 echo "====================== TEST SUITE VERSION =====================" 
 545 grep "^STC_VERSION" ./STC.INFO
 546 echo "====================== CLIENT INFO ============================" 
 547 uname -a; isainfo; domainname; zonename
 548 echo "NFSmapid_domain=$NFSmapid_domain"
 549 echo "====================== MOUNT  INFO ============================" 
 550 nfsstat -m $MNTPTR
 551 
 552 echo "====================== SERVER INFO ============================" 
 553 execute $SERVER root "uname -a; isainfo; domainname; zonename"
 554 if [[ $TestZFS == "1" ]]; then
 555 echo "====================== ZFS    INFO ============================" 
 556         execute $SERVER root "df -lhF zfs"      
 557 else
 558 echo "====================== UFS    INFO ============================" 
 559         execute $SERVER root "df -lhF ufs"
 560 fi
 561 echo "====================== SHARE  INFO ============================" 
 562 execute $SERVER root "share"
 563 
 564 echo "$NAME: PASS"
 565 cleanup $PASS