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 files with different mode using
28 # 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 file with RW-perm for all bits, expect OK
43 set expcode "OK"
44 set ASSERTION "Access a file w/RW-perm for all bits, expect $expcode"
45 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
46 set res [compound {Putfh $bfh; Lookup $env(RWFILE); Getfh;
47 Access rlmtdx; Getfh}]
48 set cont [ckres "Access" $status $expcode $res $FAIL]
49 # verify the access bits returned are expected="rmt"
50 set acl [lindex [lindex [lindex [lindex $res 3] 2] 1] 1]
51 set cont [ckaccess $acl "rmt" $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 file with RO-perm for all bits, expect OK
59 set expcode "OK"
60 set ASSERTION "Access a file w/RO-perm for all bits, expect $expcode"
61 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
62 set res [compound {Putfh $bfh; Lookup $env(ROFILE); Getfh;
63 Access rlmtdx; Getfh}]
64 set cont [ckres "Access" $status $expcode $res $FAIL]
65 # verify the access bits returned are expected="r"
66 set acl [lindex [lindex [lindex [lindex $res 3] 2] 1] 1]
67 set cont [ckaccess $acl "r" $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 file with no-perm for all bits, expect OK
75 set expcode "OK"
76 set ASSERTION "Access a file w/no-perm for all bits, expect $expcode"
77 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
78 set res [compound {Putfh $bfh; Lookup $env(FNOPERM); 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 }
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 # d: Access to symlink with RWX-perm for 'rl' bits, expect OK
96 set expcode "OK"
97 set ASSERTION "Access symlink w/RWX-perm for 'rl' bits, expect $expcode"
98 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
99 set res [compound {Putfh $bfh; Lookup $env(SYMLFILE); Getfh;
100 Access rl; Getfh}]
101 set cont [ckres "Access" $status $expcode $res $FAIL]
102 # verify the access bits returned are expected="r"
103 set acl [lindex [lindex [lindex [lindex $res 3] 2] 1] 1]
104 set cont [ckaccess $acl "r" $cont $FAIL]
105 # verify FH is not changed after successful Access op
106 set fh1 [lindex [lindex $res 2] 2]
107 set fh2 [lindex [lindex $res 4] 2]
108 fh_equal $fh1 $fh2 $cont $PASS
109
110
111 # e: Access to a file with LOOKUP,DELETE, expect OK
112 set expcode "OK"
113 set ASSERTION "Access a file w/LOOKUP,DELETE (no meaning), expect $expcode"
114 putmsg stdout 0 "$TNAME{e}: $ASSERTION"
115 set res [compound {Putfh $bfh; Lookup $env(TEXTFILE); Getfh;
116 Access ld; Getfh}]
117 set cont [ckres "Access" $status $expcode $res $FAIL]
118 # verify the access bits returned are expected=""
119 set acl [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
120 if {"$acl" != ""} {
121 putmsg stderr 0 "\t Test FAIL: expected not supported, got($acl)"
122 putmsg stderr 1 "\t res=($res)"
123 putmsg stderr 1 "\t exp=( )"
124 putmsg stderr 1 " "
125 }
126 # verify FH is not changed after successful Access op
127 set fh1 [lindex [lindex $res 2] 2]
128 set fh2 [lindex [lindex $res 4] 2]
129 fh_equal $fh1 $fh2 $cont $PASS
130
131
132 # --------------------------------------------------------------
133 # disconnect and exit
134 Disconnect
135 exit $PASS