1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # NFSv4 SECINFO operation test - positive tests
  27 #   This test assumes system/user has correct KRB5 pricipal setup.
  28 
  29 # include all test enironment
  30 source SECINFO.env
  31 
  32 # connect to the test server
  33 Connect
  34 
  35 # setting local variables
  36 set TNAME $argv0
  37 set bfh [get_fh "$BASEDIRS"]
  38 
  39 # Start testing
  40 # --------------------------------------------------------------
  41 # a: Secinfo of a regular dir under exported FS, expect OK
  42 set expcode "OK"
  43 set ASSERTION "Secinfo of a regular dir under exported FS, expect $expcode"
  44 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  45 set res [compound {Putfh $bfh; Secinfo $env(DIR0777)}]
  46 set cont [ckres "Secinfo" $status $expcode $res $FAIL]
  47 # verify the sec-list returned
  48   if {! [string equal $cont "false"]} {
  49         set slist [lindex [lindex $res 1] 2]
  50         if {[lsearch -regexp $slist "AUTH_"] == -1} {
  51             putmsg stderr 0 "\t Test FAIL: did not get expected SEC."
  52             putmsg stderr 0 "\t            expected=(AUTH_*), got=($slist)"
  53             putmsg stderr 1 "\t   res=($res)"
  54             putmsg stderr 1 " "
  55         } else {
  56             logres PASS
  57         }
  58   }
  59 
  60 
  61 # b: Secinfo of a regular file under exported FS, expect OK
  62 set expcode "OK"
  63 set ASSERTION "Secinfo of a regular file under exported FS, expect $expcode"
  64 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  65 set res [compound {Putfh $bfh; Getfh; Secinfo $env(RWFILE); Getfh}]
  66 set cont [ckres "Secinfo" $status $expcode $res $FAIL]
  67 # verify the sec-list returned
  68   if {! [string equal $cont "false"]} {
  69         set slist [lindex [lindex $res 2] 2]
  70         if {[lsearch -regexp $slist "AUTH_"] == -1} {
  71             putmsg stderr 0 "\t Test FAIL: did not get expected SEC."
  72             putmsg stderr 0 "\t            expected=(AUTH_*), got=($slist)"
  73             putmsg stderr 1 "\t   res=($res)"
  74             putmsg stderr 1 " "
  75         } else {
  76             # verify FH retains its value
  77             set fh1 [lindex [lindex $res 1] 2]
  78             fh_equal $fh1 $bfh $cont $PASS
  79         }
  80   }
  81 
  82 
  83 # c: Secinfo of a regular exported dir, expect OK
  84 set expcode "OK"
  85 set ASSERTION "Secinfo of a regular exported dir, expect $expcode"
  86 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
  87 set tdir [path2comp $env(SSPCDIR) $env(DELM)]
  88 set bd [lrange $tdir 0 end-1]
  89 set cm [lrange $tdir [llength $bd] end]
  90 set res [compound {Putrootfh; foreach c $bd {Lookup $c}; Secinfo $cm}]
  91 set cont [ckres "Secinfo" $status $expcode $res $FAIL]
  92 # verify the sec-list returned
  93   if {! [string equal $cont "false"]} {
  94         set slist [lindex [lindex $res end] 2]
  95         if {[lsearch -regexp $slist "AUTH_"] == -1} {
  96             putmsg stderr 0 "\t Test FAIL: did not get expected SEC."
  97             putmsg stderr 0 "\t            expected=(AUTH_*), got=($slist)"
  98             putmsg stderr 1 "\t   res=($res)"
  99             putmsg stderr 1 " "
 100         } else {
 101             logres PASS
 102         }
 103   }
 104 
 105 
 106 # e: Secinfo of parent dir '..', expect OK
 107 set expcode "OK"
 108 set ASSERTION "Secinfo of parent dir '..', expect $expcode"
 109 putmsg stdout 0 "$TNAME{e}: $ASSERTION"
 110 set res [compound {Putfh $bfh; Lookup "$env(DIR0777)";
 111         Secinfo ".."}]
 112 set cont [ckres "Secinfo" $status $expcode $res $FAIL]
 113 # verify the sec-list returned
 114   if {! [string equal $cont "false"]} {
 115         set slist [lindex [lindex $res end] 2]
 116         if {[lsearch -regexp $slist "AUTH_"] == -1} {
 117             putmsg stderr 0 "\t Test FAIL: did not get expected SEC."
 118             putmsg stderr 0 "\t            expected=(AUTH_*), got=($slist)"
 119             putmsg stderr 1 "\t   res=($res)"
 120             putmsg stderr 1 " "
 121         } else {
 122             logres PASS
 123         }
 124   }
 125 
 126 
 127 # g: Secinfo of a KRB5 exported dir, expect OK
 128 set expcode "OK"
 129 set ASSERTION "Secinfo of a KRB5 exported dir, expect $expcode"
 130 putmsg stdout 0 "$TNAME{g}: $ASSERTION"
 131 set k5dir [path2comp $env(KRB5DIR) $env(DELM)]
 132 set bd [lrange $k5dir 0 end-1]
 133 set cm [lrange $k5dir [llength $bd] end]
 134 set res [compound {Putrootfh; foreach c $bd {Lookup $c}; Secinfo $cm}]
 135 set cont [ckres "Secinfo" $status $expcode $res $FAIL]
 136 # verify the sec-list returned
 137   if {! [string equal $cont "false"]} {
 138         set slist [lindex [lindex $res end] 2]
 139         if {[lsearch -regexp $slist "KRB5"] == -1} {
 140             putmsg stderr 0 \
 141                 "\t Test NOTINUSE: $SERVER did not setup KRB5 w/($env(KRB5DIR))"
 142             putmsg stderr 0 "\t            got-SEC=($slist)"
 143             putmsg stderr 1 "\t   res=($res)"
 144             putmsg stderr 1 " "
 145         } else {
 146             logres PASS
 147         }
 148   }
 149 
 150 
 151 # --------------------------------------------------------------
 152 # disconnect and exit
 153 Disconnect
 154 exit $PASS