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 CREATE operation test - negative tests
27 # Verify server returns correct BADOWNER errors.
28
29 # include all test enironment
30 source CREATE.env
31 source CREATE_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
64 # Start testing
65 # --------------------------------------------------------------
66
67
68 # a: unknown owner
69 set tag $TNAME{a}
70 set expct "BADOWNER"
71 set ASSERTION "unknown owner, expect $expct"
72 putmsg stdout 0 "$tag: $ASSERTION"
73 set filename $tag
74 set TESTFILE [file join $ROOTDIR "$filename"]
75 set owner "[ownid j]@$domain"
76 set group ""
77 set st [uid_creat $fh $filename owner group res s]
78 ckres "Create" $st $expct $res $PASS
79 if {[get_fh "$ROOTDIRS $filename"] != ""} {
80 set res [removev4 $TESTFILE]
81 }
82
83
84 # b: unknown group
85 set tag $TNAME{b}
86 set expct "BADOWNER"
87 set ASSERTION "unknown group, expect $expct"
88 putmsg stdout 0 "$tag: $ASSERTION"
89 set filename $tag
90 set TESTFILE [file join $ROOTDIR "$filename"]
91 set owner ""
92 set group "[grpid k]@$domain"
93 set st [uid_creat $fh $filename owner group res d]
94 ckres "Create" $st $expct $res $PASS
95 if {[get_fh "$ROOTDIRS $filename"] != ""} {
96 set res [removev4 $TESTFILE]
97 }
98
99
100 # c: unknown owner and group
101 set tag $TNAME{c}
102 set expct "BADOWNER"
103 set ASSERTION "unknown owner and group, expect $expct"
104 putmsg stdout 0 "$tag: $ASSERTION"
105 set filename $tag
106 set TESTFILE [file join $ROOTDIR "$filename"]
107 set owner "[ownid l]@$domain"
108 set group "[grpid l]@$domain"
109 set st [uid_creat $fh $filename owner group res f]
110 ckres "Create" $st $expct $res $PASS
111 if {[get_fh "$ROOTDIRS $filename"] != ""} {
112 set res [removev4 $TESTFILE]
113 }
114
115
116 # d: known user, known group, no domain sent
117 set tag $TNAME{d}
118 set expct "BADOWNER|OK"
119 set ASSERTION "known user, known group, no domain sent, expect $expct"
120 putmsg stdout 0 "$tag: $ASSERTION"
121 set filename $tag
122 set TESTFILE [file join $ROOTDIR "$filename"]
123 set owner "nuucp"
124 set group "nuucp"
125 set st [uid_creat $fh $filename owner group res s]
126 ckres "Create" $st $expct $res $PASS
127 if {[get_fh "$ROOTDIRS $filename"] != ""} {
128 set res [removev4 $TESTFILE]
129 }
130
131
132 # e: known owner, unknown domain
133 set tag $TNAME{e}
134 set expct "BADOWNER"
135 set ASSERTION "known owner, unknown domain, expect $expct"
136 putmsg stdout 0 "$tag: $ASSERTION"
137 set filename $tag
138 set TESTFILE [file join $ROOTDIR "$filename"]
139 set owner "uucp@noexist.sun.com"
140 set group ""
141 set st [uid_creat $fh $filename owner group res d]
142 ckres "Create" $st $expct $res $PASS
143 if {[get_fh "$ROOTDIRS $filename"] != ""} {
144 set res [removev4 $TESTFILE]
145 }
146
147
148 # f: known group, unknown domain
149 set tag $TNAME{f}
150 set expct "BADOWNER"
151 set ASSERTION "known group, unknown domain, expect $expct"
152 putmsg stdout 0 "$tag: $ASSERTION"
153 set filename $tag
154 set TESTFILE [file join $ROOTDIR "$filename"]
155 set owner ""
156 set group "staff@noexist.sun.com"
157 set st [uid_creat $fh $filename owner group res f]
158 ckres "Create" $st $expct $res $PASS
159 if {[get_fh "$ROOTDIRS $filename"] != ""} {
160 set res [removev4 $TESTFILE]
161 }
162
163
164 # k: user known only to client
165 set tag $TNAME{k}
166 set expct "BADOWNER"
167 set ASSERTION "user known only to client, expect $expct"
168 putmsg stdout 0 "$tag: $ASSERTION"
169 set filename $tag
170 set TESTFILE [file join $ROOTDIR "$filename"]
171 set owner "$::env(TUSERC)@$domain"
172 set group ""
173 set st [uid_creat $fh $filename owner group res d]
174 ckres "Create" $st $expct $res $PASS
175 if {[get_fh "$ROOTDIRS $filename"] != ""} {
176 set res [removev4 $TESTFILE]
177 }
178
179
180 # m: user known only to client with common user id
181 set tag $TNAME{m}
182 set expct "BADOWNER"
183 set ASSERTION "user known only to client with common user id, expect $expct"
184 putmsg stdout 0 "$tag: $ASSERTION"
185 set filename $tag
186 set TESTFILE [file join $ROOTDIR "$filename"]
187 set owner "$::env(TUSERC2)@$domain"
188 set group ""
189 set st [uid_creat $fh $filename owner group res s]
190 ckres "Create" $st $expct $res $PASS
191 if {[get_fh "$ROOTDIRS $filename"] != ""} {
192 set res [removev4 $TESTFILE]
193 }
194
195
196 # --------------------------------------------------------------
197 # disconnect and exit
198
199 Disconnect
200 exit $PASS