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 # UID Mapping testing.
  27 
  28 # TESTROOT directory; must be set in the environment already
  29 set TESTROOT $env(TESTROOT)
  30 
  31 # ROOTDIR directory; must be set in the environment already
  32 set ROOTDIR $env(ROOTDIR)
  33 
  34 source [file join ${TESTROOT} tcl.init]
  35 source [file join ${TESTROOT} testproc]
  36 source [file join ${TESTROOT} lcltools]
  37 
  38 # setting local variables
  39 set TNAME $argv0
  40 
  41 if {[info exists env(DNS_SERVER)] == 1} {
  42         set domain [get_domain $env(SERVER) $env(DNS_SERVER)]
  43 } else {
  44         set domain [get_domain $env(SERVER)]
  45 }
  46 if {$domain == $NULL} {
  47         putmsg stderr 0 "\t$TNAME: unable to determine the domain."
  48         putmsg stderr 0 "\tAssertions won't be executed."
  49         exit $UNINITIATED
  50 }
  51 
  52 # connect to the test server
  53 Connect
  54 
  55 
  56 set attrs {owner owner_group}
  57 
  58 # get file file handle, ROOTDIR is mounted with option root=<this host>
  59 set tag $TNAME
  60 set TESTFILE [file join $ROOTDIR "$TNAME"]
  61 set clientid ""
  62 set stateid ""
  63 set seqid ""
  64 set fh [openv4 $TESTFILE clientid stateid seqid]
  65 if { $fh == $NULL } {
  66         putmsg stderr 0 "\t$TNAME: unable to create temp file."
  67         exit $UNINITIATED
  68 }
  69 
  70 
  71 # Start testing
  72 # --------------------------------------------------------------
  73 
  74 # d1: known user
  75 set tag $TNAME{d1}
  76 set expct "OK"
  77 set ASSERTION "known user, expect $expct"
  78 putmsg stdout 0 "$tag: $ASSERTION"
  79 set owner "uucp@$domain"
  80 set group ""
  81 set st [uid_map $fh $stateid owner group res]
  82 ckres "uid_mapping" $st $expct $res $PASS
  83 
  84 
  85 # d2: known mapable user id
  86 set tag $TNAME{d2}
  87 set expct "OK"
  88 set ASSERTION "known mapable user id, expect $expct"
  89 putmsg stdout 0 "$tag: $ASSERTION"
  90 set owner 4
  91 set group ""
  92 set st [uid_map $fh $stateid owner group res "adm@$domain" ""]
  93 ckres "uid_mapping" $st $expct $res $PASS
  94 
  95 
  96 # e1: known group
  97 set tag $TNAME{e1}
  98 set expct "OK"
  99 set ASSERTION "known group, expect $expct"
 100 putmsg stdout 0 "$tag: $ASSERTION"
 101 set owner ""
 102 set group "staff@$domain"
 103 set st [uid_map $fh $stateid owner group res]
 104 ckres "uid_mapping" $st $expct $res $PASS
 105 
 106 
 107 # e2: known mapable group id
 108 set tag $TNAME{e2}
 109 set expct "OK"
 110 set ASSERTION "known mapable group id, expect $expct"
 111 putmsg stdout 0 "$tag: $ASSERTION"
 112 set owner ""
 113 set group 4
 114 set st [uid_map $fh $stateid owner group res "" "adm@$domain"]
 115 ckres "uid_mapping" $st $expct $res $PASS
 116 
 117 
 118 # f: known user and group
 119 set tag $TNAME{f}
 120 set expct "OK"
 121 set ASSERTION "known user and group, expect $expct"
 122 putmsg stdout 0 "$tag: $ASSERTION"
 123 set owner "nuucp@$domain"
 124 set group "nuucp@$domain"
 125 set st [uid_map $fh $stateid owner group res]
 126 ckres "uid_mapping" $st $expct $res $PASS
 127 
 128 
 129 # g: unmapped user id
 130 set tag $TNAME{g}
 131 set expct "OK"
 132 set ASSERTION "unmapped user id, expect $expct"
 133 putmsg stdout 0 "$tag: $ASSERTION"
 134 set owner 5000000
 135 set group ""
 136 set st [uid_map $fh $stateid owner group res]
 137 ckres "uid_mapping" $st $expct $res $PASS
 138 
 139 
 140 # h: unmapped group id
 141 set tag $TNAME{h}
 142 set expct "OK"
 143 set ASSERTION "unmapped group id, expect $expct"
 144 putmsg stdout 0 "$tag: $ASSERTION"
 145 set owner ""
 146 set group 5000000
 147 set st [uid_map $fh $stateid owner group res]
 148 ckres "uid_mapping" $st $expct $res $PASS
 149 
 150 
 151 # p1: owner root
 152 set tag $TNAME{p1}
 153 set expct "OK"
 154 set ASSERTION "owner root, expect $expct"
 155 putmsg stdout 0 "$tag: $ASSERTION"
 156 set owner "root@$domain"
 157 set group ""
 158 set st [uid_map $fh $stateid owner group res]
 159 ckres "uid_mapping" $st $expct $res $PASS
 160 # change owner to be different for next assertion
 161 set owner "nobody@$domain"
 162 set group ""
 163 set st [uid_map $fh $stateid owner group res]
 164 
 165 
 166 # p2: owner id 0
 167 set tag $TNAME{p2}
 168 set expct "OK"
 169 set ASSERTION "owner id 0, expect $expct"
 170 putmsg stdout 0 "$tag: $ASSERTION"
 171 set owner 0
 172 set group ""
 173 set st [uid_map $fh $stateid owner group res "root@$domain" ""]
 174 ckres "uid_mapping" $st $expct $res $PASS
 175 
 176 
 177 # r1: group root
 178 set tag $TNAME{r1}
 179 set expct "OK"
 180 set ASSERTION "group root, expect $expct"
 181 putmsg stdout 0 "$tag: $ASSERTION"
 182 set owner ""
 183 set group "root@$domain"
 184 set st [uid_map $fh $stateid owner group res]
 185 ckres "uid_mapping" $st $expct $res $PASS
 186 # change group to be different for next assertion
 187 set owner ""
 188 set group "nobody@$domain"
 189 set st [uid_map $fh $stateid owner group res]
 190 
 191 
 192 # r2: group id 0
 193 set tag $TNAME{r2}
 194 set expct "OK"
 195 set ASSERTION "group id 0, expect $expct"
 196 putmsg stdout 0 "$tag: $ASSERTION"
 197 set owner ""
 198 set group 0
 199 set st [uid_map $fh $stateid owner group res "" "root@$domain"]
 200 ckres "uid_mapping" $st $expct $res $PASS
 201 
 202 
 203 # t: valid UTF8 in owner
 204 set tag $TNAME{t}
 205 set expct "OK"
 206 set ASSERTION "valid UTF8 in owner, expect $expct"
 207 putmsg stdout 0 "$tag: $ASSERTION"
 208 # values in hex: 
 209 #       7e df 80 ef 80 80 f7 80 80 80 fb 80 80 80 80 fd 80 80 80 80 80 
 210 set enc [encoding system]
 211 set res [encoding system identity]
 212 set owner [exec echo $::env(UTF8_USR)]
 213 append owner "@$domain"
 214 set group ""
 215 set res [encoding system $enc]
 216 set st [uid_map $fh $stateid owner group res]
 217 ckres "uid_mapping" $st $expct $res $PASS
 218 
 219 
 220 # u: valid UTF8 in group
 221 set tag $TNAME{u}
 222 set expct "OK"
 223 set ASSERTION "valid UTF8 in group, expect $expct"
 224 putmsg stdout 0 "$tag: $ASSERTION"
 225 # values in hex: 
 226 #       7e df 80 ef 80 80 f7 80 80 80 fb 80 80 80 80 fd 80 80 80 80 80 
 227 set enc [encoding system]
 228 set res [encoding system identity]
 229 set owner ""
 230 set group [exec echo $::env(UTF8_USR)] 
 231 append group "@$domain"
 232 set res [encoding system $enc]
 233 set st [uid_map $fh $stateid owner group res]
 234 ckres "uid_mapping" $st $expct $res $PASS
 235 
 236 
 237 # v: user id known only to client
 238 set tag $TNAME{v}
 239 set expct "OK"
 240 set ASSERTION "user id known only to client, expect $expct"
 241 putmsg stdout 0 "$tag: $ASSERTION"
 242 set owner "$::env(TUSERCID)"
 243 set group ""
 244 set st [uid_map $fh $stateid owner group res]
 245 ckres "uid_mapping" $st $expct $res $PASS
 246 
 247 
 248 # w1: user known only to server
 249 set tag $TNAME{w1}
 250 set expct "OK"
 251 set ASSERTION "user known only to server, expect $expct"
 252 putmsg stdout 0 "$tag: $ASSERTION"
 253 set owner "$::env(TUSERS)@$domain"
 254 set group ""
 255 set st [uid_map $fh $stateid owner group res]
 256 ckres "uid_mapping" $st $expct $res $PASS
 257 # change owner to be different for next assertion
 258 set owner "nobody@$domain"
 259 set group ""
 260 set st [uid_map $fh $stateid owner group res]
 261 
 262 
 263 # w2: user id known only to server
 264 set tag $TNAME{w2}
 265 set expct "OK"
 266 set ASSERTION "user id known only to server, expect $expct"
 267 putmsg stdout 0 "$tag: $ASSERTION"
 268 set owner "$::env(TUSERSID)"
 269 set group ""
 270 set st [uid_map $fh $stateid owner group res "$::env(TUSERS)@$domain" ""]
 271 ckres "uid_mapping" $st $expct $res $PASS
 272 
 273 
 274 # x1: user known only to client with common user id
 275 set tag $TNAME{x1}
 276 set expct "OK"
 277 set ASSERTION "user known only to client with common user id, expect $expct"
 278 putmsg stdout 0 "$tag: $ASSERTION"
 279 set owner "$::env(TUSERS2)@$domain"
 280 set group ""
 281 set st [uid_map $fh $stateid owner group res]
 282 ckres "uid_mapping" $st $expct $res $PASS
 283 # change owner to be different for next assertion
 284 set owner "nobody@$domain"
 285 set group ""
 286 set st [uid_map $fh $stateid owner group res]
 287 
 288 
 289 # x2: common user id with user known only to client
 290 set tag $TNAME{x2}
 291 set expct "OK"
 292 set ASSERTION "common user id with user known only to client, expect $expct"
 293 putmsg stdout 0 "$tag: $ASSERTION"
 294 set owner "$::env(TUSERID)"
 295 set group ""
 296 set st [uid_map $fh $stateid owner group res "$::env(TUSERS2)@$domain" ""]
 297 ckres "uid_mapping" $st $expct $res $PASS
 298 
 299 
 300 # close file to reuse variables in last part of test
 301 set tag $TNAME.cleanup
 302 set fh [closev4 $TESTFILE $fh $stateid $seqid]
 303 if { $fh == $NULL } {
 304     putmsg stderr 0 "\tWARNING: unable to close or delete temp file."
 305 }
 306 
 307 # --------------------------------------------------------------
 308 # disconnect and exit
 309 
 310 disconnect
 311 exit $PASS