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 OPEN operation test - negative tests
  27 #       Verify server returns correct BADOWNER errors.
  28 
  29 # include all test enironment
  30 source OPEN.env
  31 source OPEN_proc
  32 
  33 # TESTROOT directory; must be set in the environment already
  34 set TESTROOT $env(TESTROOT)
  35 
  36 # ROOTDIR directory; must be set in the environment already
  37 set ROOTDIR $env(ROOTDIR)
  38 
  39 source [file join ${TESTROOT} lcltools]
  40 
  41 # setting local variables
  42 set TNAME $argv0
  43 
  44 if {[info exists env(DNS_SERVER)] == 1} {
  45         set domain [get_domain $env(SERVER) $env(DNS_SERVER)]
  46 } else {
  47         set domain [get_domain $env(SERVER)]
  48 }
  49 if {$domain == $NULL} {
  50         putmsg stderr 0 "$TNAME{all}:"
  51         putmsg stderr 0 "\tTest UNINITIATED: unable to determine the domain."
  52         putmsg stderr 0 "\tAssertions won't be executed."
  53         exit $UNINITIATED
  54 }
  55 
  56 # connect to the test server
  57 Connect
  58 
  59 set tag $TNAME.setup
  60 set ROOTDIRS [path2comp $ROOTDIR $::DELM]
  61 set fh [get_fh $ROOTDIRS]
  62 
  63 set clientid [getclientid $TNAME.[pid]]
  64 if {$clientid == -1} {
  65         putmsg stdout 0 "$TNAME: test setup - getclientid"
  66         putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
  67         exit $UNRESOLVED
  68 }
  69 
  70 
  71 # Start testing
  72 # --------------------------------------------------------------
  73 
  74 
  75 # a: unknown owner
  76 set tag $TNAME{a}
  77 set expct "BADOWNER"
  78 set ASSERTION "unknown owner, expect $expct"
  79 putmsg stdout 0 "$tag: $ASSERTION"
  80 set filename $tag
  81 set TESTFILE [file join $ROOTDIR "$filename"]
  82 set owner "[ownid j]@$domain"
  83 set group ""
  84 set st [uid_open $fh $filename $clientid owner group res]
  85 ckres "Open" $st $expct $res $PASS
  86 
  87 
  88 # b: unknown group
  89 set tag $TNAME{b}
  90 set expct "BADOWNER"
  91 set ASSERTION "unknown group, expect $expct"
  92 putmsg stdout 0 "$tag: $ASSERTION"
  93 set filename $tag
  94 set TESTFILE [file join $ROOTDIR "$filename"]
  95 set owner ""
  96 set group "[grpid k]@$domain"
  97 set st [uid_open $fh $filename $clientid owner group res]
  98 ckres "Open" $st $expct $res $PASS
  99 
 100 
 101 # c: unknown owner and group
 102 set tag $TNAME{c}
 103 set expct "BADOWNER"
 104 set ASSERTION "unknown owner and group, expect $expct"
 105 putmsg stdout 0 "$tag: $ASSERTION"
 106 set filename $tag
 107 set TESTFILE [file join $ROOTDIR "$filename"]
 108 set owner "[ownid l]@$domain"
 109 set group "[grpid l]@$domain"
 110 set st [uid_open $fh $filename $clientid owner group res]
 111 ckres "Open" $st $expct $res $PASS
 112 
 113 
 114 # d: known user, known group, no domain sent
 115 set tag $TNAME{d}
 116 set expct "BADOWNER|OK"
 117 set ASSERTION "known user, known group, no domain sent, expect $expct"
 118 putmsg stdout 0 "$tag: $ASSERTION"
 119 set filename $tag
 120 set TESTFILE [file join $ROOTDIR "$filename"]
 121 set owner "nuucp"
 122 set group "nuucp"
 123 set st [uid_open $fh $filename $clientid owner group res]
 124 ckres "Open" $st $expct $res $PASS
 125 
 126 
 127 # e: known owner, unknown domain 
 128 set tag $TNAME{e}
 129 set expct "BADOWNER"
 130 set ASSERTION "known owner, unknown domain, expect $expct"
 131 putmsg stdout 0 "$tag: $ASSERTION"
 132 set filename $tag
 133 set TESTFILE [file join $ROOTDIR "$filename"]
 134 set owner "uucp@noexist.sun.com"
 135 set group ""
 136 set st [uid_open $fh $filename $clientid owner group res]
 137 ckres "Open" $st $expct $res $PASS
 138 
 139 
 140 # f: known group, unknown domain
 141 set tag $TNAME{f}
 142 set expct "BADOWNER"
 143 set ASSERTION "known group, unknown domain, expect $expct"
 144 putmsg stdout 0 "$tag: $ASSERTION"
 145 set filename $tag
 146 set TESTFILE [file join $ROOTDIR "$filename"]
 147 set owner ""
 148 set group "staff@noexist.sun.com"
 149 set st [uid_open $fh $filename $clientid owner group res]
 150 ckres "Open" $st $expct $res $PASS
 151 
 152 
 153 # k: user known only to client
 154 set tag $TNAME{k}
 155 set expct "BADOWNER"
 156 set ASSERTION "user known only to client, expect $expct"
 157 putmsg stdout 0 "$tag: $ASSERTION"
 158 set filename $tag
 159 set TESTFILE [file join $ROOTDIR "$filename"]
 160 set owner "$::env(TUSERC)@$domain"
 161 set group ""
 162 set st [uid_open $fh $filename $clientid owner group res]
 163 ckres "Open" $st $expct $res $PASS
 164 
 165 
 166 # m: user known only to client with common user id
 167 set tag $TNAME{m}
 168 set expct "BADOWNER"
 169 set ASSERTION "user known only to client with common user id, expect $expct"
 170 putmsg stdout 0 "$tag: $ASSERTION"
 171 set filename $tag
 172 set TESTFILE [file join $ROOTDIR "$filename"]
 173 set owner "$::env(TUSERC2)@$domain"
 174 set group ""
 175 set st [uid_open $fh $filename $clientid owner group res]
 176 ckres "Open" $st $expct $res $PASS
 177 
 178 
 179 # --------------------------------------------------------------
 180 # disconnect and exit
 181 
 182 Disconnect
 183 exit $PASS