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 ACCESS operation test - positive tests
  27 #       verify access checking of directories with different mode 
  28 #       using different bit masks
  29 
  30 # include all test enironment
  31 source ACCESS.env
  32 
  33 # connect to the test server
  34 Connect
  35 
  36 # setting local variables
  37 set TNAME $argv0
  38 set bfh [get_fh "$BASEDIRS"]
  39 
  40 # Start testing
  41 # --------------------------------------------------------------
  42 # a: Access to a dir with RW-perm for all bits, expect OK
  43 set expcode "OK"
  44 set ASSERTION "Access a dir w/RW-perm for all bits, expect $expcode"
  45 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
  46 set res [compound {Putfh $bfh; Lookup $env(DIR0777); Getfh;
  47         Access rlmtdx; Getfh}]
  48 set cont [ckres "Access" $status $expcode $res $FAIL]
  49 # verify the access bits returned are expected="rlmtd"
  50   set acl [lindex [lindex [lindex [lindex $res 3] 2] 1] 1]
  51   set cont [ckaccess $acl "rlmtd" $cont $FAIL]
  52 # verify FH is not changed after successful Access op
  53   set fh1 [lindex [lindex $res 2] 2]
  54   set fh2 [lindex [lindex $res 4] 2]
  55   fh_equal $fh1 $fh2 $cont $PASS
  56 
  57 
  58 # b: Access to a dir with RX-perm for all bits, expect OK
  59 set expcode "OK"
  60 set ASSERTION "Access a dir w/RX-perm for all bits, expect $expcode"
  61 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
  62 set res [compound {Putfh $bfh; Lookup $env(DIR0755); Getfh;
  63         Access rlmtdx; Getfh}]
  64 set cont [ckres "Access" $status $expcode $res $FAIL]
  65 # verify the access bits returned are expected="rlx"
  66   set acl [lindex [lindex [lindex [lindex $res 3] 2] 1] 1]
  67   set cont [ckaccess $acl "rl" $cont $FAIL]
  68 # verify FH is not changed after successful Access op
  69   set fh1 [lindex [lindex $res 2] 2]
  70   set fh2 [lindex [lindex $res 4] 2]
  71   fh_equal $fh1 $fh2 $cont $PASS
  72 
  73 
  74 # c: Access to a dir with no-perm for all bits, expect OK
  75 set expcode "OK"
  76 set ASSERTION "Access a dir w/no-perm for all bits, expect $expcode"
  77 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
  78 set res [compound {Putfh $bfh; Lookup $env(DNOPERM); Getfh;
  79         Access rlmtdx; Getfh}]
  80 set cont [ckres "Access" $status $expcode $res $FAIL]
  81 # verify the access bits returned are expected=""
  82   set acl [lindex [lindex [lindex [lindex $res 3] 2] 1] 1]
  83   if {"$acl" != ""} {
  84         putmsg stderr 0 "\t Test FAIL: expected no access, got($acl)"
  85         putmsg stderr 1 "\t   res=($res)"
  86         putmsg stderr 1 "\t   exp=( )"
  87         putmsg stderr 1 " "
  88   } else {
  89         # verify FH is not changed after successful Access op
  90         set fh1 [lindex [lindex $res 2] 2]
  91         set fh2 [lindex [lindex $res 4] 2]
  92         fh_equal $fh1 $fh2 $cont $PASS
  93   }
  94 
  95 
  96 # d: Access to a symlink with R-X perm for 'rtx' bits, expect OK
  97 set expcode "OK"
  98 set ASSERTION "Access symlink w/R-X perm for 'rtx' bits, expect $expcode"
  99 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
 100 set res [compound {Putfh $bfh; Lookup $env(SYMLFILE); Getfh;
 101         Access rtx; Getfh}]
 102 set cont [ckres "Access" $status $expcode $res $FAIL]
 103 # verify the access bits returned are expected="rtx"
 104   set acl [lindex [lindex [lindex [lindex $res 3] 2] 1] 1]
 105   set cont [ckaccess $acl "rtx" $cont $FAIL]
 106 # verify FH is not changed after successful Access op
 107   set fh1 [lindex [lindex $res 2] 2]
 108   set fh2 [lindex [lindex $res 4] 2]
 109   fh_equal $fh1 $fh2 $cont $PASS
 110 
 111 
 112 # e: Access to a dir with EXECUTE (no meaning), expect OK
 113 set expcode "OK"
 114 set ASSERTION "Access a dir w/EXECUTE (no meaning), expect $expcode"
 115 putmsg stdout 0 "$TNAME{e}: $ASSERTION"
 116 set res [compound {Putfh $bfh; Lookup $env(DIR0755); Getfh;
 117         Access x; Getfh}]
 118 set cont [ckres "Access" $status $expcode $res $FAIL]
 119 # verify the access bits returned are expected=""
 120   set acl [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
 121   if {"$acl" != ""} {
 122         putmsg stderr 0 "\t Test FAIL: expected not supported, got($acl)"
 123         putmsg stderr 1 "\t   res=($res)"
 124         putmsg stderr 1 "\t   exp=( )"
 125         putmsg stderr 1 " "
 126   } else {
 127         # verify FH is not changed after successful Access op
 128         set fh1 [lindex [lindex $res 2] 2]
 129         set fh2 [lindex [lindex $res 4] 2]
 130         fh_equal $fh1 $fh2 $cont $PASS
 131   }
 132 
 133 
 134 # --------------------------------------------------------------
 135 # disconnect and exit
 136 Disconnect
 137 exit $PASS