1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | test suite for oxidresolve operations
|
---|
4 |
|
---|
5 | Copyright (C) Jelmer Vernooij 2004
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or modify
|
---|
8 | it under the terms of the GNU General Public License as published by
|
---|
9 | the Free Software Foundation; either version 3 of the License, or
|
---|
10 | (at your option) any later version.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful,
|
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | GNU General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #include "includes.h"
|
---|
22 | #include "librpc/gen_ndr/ndr_oxidresolver_c.h"
|
---|
23 | #include "librpc/gen_ndr/ndr_remact_c.h"
|
---|
24 | #include "librpc/gen_ndr/epmapper.h"
|
---|
25 | #include "torture/rpc/torture_rpc.h"
|
---|
26 |
|
---|
27 | #define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
|
---|
28 |
|
---|
29 | const struct GUID IUnknown_uuid = {
|
---|
30 | 0x00000000,0x0000,0x0000,{0xc0,0x00},{0x00,0x00,0x00,0x00,0x00,0x46}
|
---|
31 | };
|
---|
32 |
|
---|
33 | static bool test_RemoteActivation(struct torture_context *tctx,
|
---|
34 | uint64_t *oxid, struct GUID *oid)
|
---|
35 | {
|
---|
36 | struct RemoteActivation r;
|
---|
37 | NTSTATUS status;
|
---|
38 | struct GUID iids[2];
|
---|
39 | uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
|
---|
40 | struct dcerpc_pipe *p;
|
---|
41 | struct dcerpc_binding_handle *b;
|
---|
42 |
|
---|
43 | status = torture_rpc_connection(tctx, &p,
|
---|
44 | &ndr_table_IRemoteActivation);
|
---|
45 |
|
---|
46 | if (!NT_STATUS_IS_OK(status)) {
|
---|
47 | return false;
|
---|
48 | }
|
---|
49 | b = p->binding_handle;
|
---|
50 |
|
---|
51 | ZERO_STRUCT(r.in);
|
---|
52 | r.in.this_object.version.MajorVersion = 5;
|
---|
53 | r.in.this_object.version.MinorVersion = 1;
|
---|
54 | r.in.this_object.cid = GUID_random();
|
---|
55 | GUID_from_string(CLSID_IMAGEDOC, &r.in.Clsid);
|
---|
56 | r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
|
---|
57 | r.in.num_protseqs = 3;
|
---|
58 | r.in.protseq = protseq;
|
---|
59 | r.in.Interfaces = 1;
|
---|
60 | iids[0] = IUnknown_uuid;
|
---|
61 | r.in.pIIDs = iids;
|
---|
62 | r.out.pOxid = oxid;
|
---|
63 | r.out.ipidRemUnknown = oid;
|
---|
64 |
|
---|
65 | status = dcerpc_RemoteActivation_r(b, tctx, &r);
|
---|
66 | if(NT_STATUS_IS_ERR(status)) {
|
---|
67 | fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status));
|
---|
68 | return false;
|
---|
69 | }
|
---|
70 |
|
---|
71 | if(!W_ERROR_IS_OK(r.out.result)) {
|
---|
72 | fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.result));
|
---|
73 | return false;
|
---|
74 | }
|
---|
75 |
|
---|
76 | if(!W_ERROR_IS_OK(*r.out.hr)) {
|
---|
77 | fprintf(stderr, "RemoteActivation: %s\n", win_errstr(*r.out.hr));
|
---|
78 | return false;
|
---|
79 | }
|
---|
80 |
|
---|
81 | if(!W_ERROR_IS_OK(r.out.results[0])) {
|
---|
82 | fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.results[0]));
|
---|
83 | return false;
|
---|
84 | }
|
---|
85 |
|
---|
86 | return true;
|
---|
87 | }
|
---|
88 |
|
---|
89 | static bool test_SimplePing(struct torture_context *tctx,
|
---|
90 | struct dcerpc_pipe *p)
|
---|
91 | {
|
---|
92 | struct SimplePing r;
|
---|
93 | NTSTATUS status;
|
---|
94 | uint64_t setid;
|
---|
95 | struct dcerpc_binding_handle *b = p->binding_handle;
|
---|
96 |
|
---|
97 | r.in.SetId = &setid;
|
---|
98 |
|
---|
99 | status = dcerpc_SimplePing_r(b, tctx, &r);
|
---|
100 | torture_assert_ntstatus_ok(tctx, status, "SimplePing");
|
---|
101 | torture_assert_werr_ok(tctx, r.out.result, "SimplePing");
|
---|
102 |
|
---|
103 | return true;
|
---|
104 | }
|
---|
105 |
|
---|
106 | static bool test_ComplexPing(struct torture_context *tctx,
|
---|
107 | struct dcerpc_pipe *p)
|
---|
108 | {
|
---|
109 | struct ComplexPing r;
|
---|
110 | NTSTATUS status;
|
---|
111 | uint64_t setid;
|
---|
112 | struct GUID oid;
|
---|
113 | uint64_t oxid;
|
---|
114 | struct dcerpc_binding_handle *b = p->binding_handle;
|
---|
115 |
|
---|
116 | if (!test_RemoteActivation(tctx, &oxid, &oid))
|
---|
117 | return false;
|
---|
118 |
|
---|
119 | setid = 0;
|
---|
120 | ZERO_STRUCT(r.in);
|
---|
121 |
|
---|
122 | r.in.SequenceNum = 0;
|
---|
123 | r.in.SetId = &setid;
|
---|
124 | r.in.cAddToSet = 1;
|
---|
125 | r.in.AddToSet = &oid;
|
---|
126 |
|
---|
127 | status = dcerpc_ComplexPing_r(b, tctx, &r);
|
---|
128 | if(NT_STATUS_IS_ERR(status)) {
|
---|
129 | fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status));
|
---|
130 | return 0;
|
---|
131 | }
|
---|
132 |
|
---|
133 | if(!W_ERROR_IS_OK(r.out.result)) {
|
---|
134 | fprintf(stderr, "ComplexPing: %s\n", win_errstr(r.out.result));
|
---|
135 | return 0;
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|
140 | return 1;
|
---|
141 | }
|
---|
142 |
|
---|
143 | static bool test_ServerAlive(struct torture_context *tctx,
|
---|
144 | struct dcerpc_pipe *p)
|
---|
145 | {
|
---|
146 | struct ServerAlive r;
|
---|
147 | NTSTATUS status;
|
---|
148 | struct dcerpc_binding_handle *b = p->binding_handle;
|
---|
149 |
|
---|
150 | status = dcerpc_ServerAlive_r(b, tctx, &r);
|
---|
151 | torture_assert_ntstatus_ok(tctx, status, "ServerAlive");
|
---|
152 | torture_assert_werr_ok(tctx, r.out.result, "ServerAlive");
|
---|
153 |
|
---|
154 | return true;
|
---|
155 | }
|
---|
156 |
|
---|
157 | static bool test_ResolveOxid(struct torture_context *tctx,
|
---|
158 | struct dcerpc_pipe *p)
|
---|
159 | {
|
---|
160 | struct ResolveOxid r;
|
---|
161 | NTSTATUS status;
|
---|
162 | uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
|
---|
163 | uint64_t oxid;
|
---|
164 | struct GUID oid;
|
---|
165 | struct dcerpc_binding_handle *b = p->binding_handle;
|
---|
166 |
|
---|
167 | if (!test_RemoteActivation(tctx, &oxid, &oid))
|
---|
168 | return false;
|
---|
169 |
|
---|
170 | r.in.pOxid = oxid;
|
---|
171 | r.in.cRequestedProtseqs = 2;
|
---|
172 | r.in.arRequestedProtseqs = protseq;
|
---|
173 |
|
---|
174 | status = dcerpc_ResolveOxid_r(b, tctx, &r);
|
---|
175 | torture_assert_ntstatus_ok(tctx, status, "ResolveOxid");
|
---|
176 | torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid");
|
---|
177 |
|
---|
178 | return true;
|
---|
179 | }
|
---|
180 |
|
---|
181 | static bool test_ResolveOxid2(struct torture_context *tctx,
|
---|
182 | struct dcerpc_pipe *p)
|
---|
183 | {
|
---|
184 | struct ResolveOxid2 r;
|
---|
185 | NTSTATUS status;
|
---|
186 | uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
|
---|
187 | uint64_t oxid;
|
---|
188 | struct GUID oid;
|
---|
189 | struct dcerpc_binding_handle *b = p->binding_handle;
|
---|
190 |
|
---|
191 | if (!test_RemoteActivation(tctx, &oxid, &oid))
|
---|
192 | return false;
|
---|
193 |
|
---|
194 | r.in.pOxid = oxid;
|
---|
195 | r.in.cRequestedProtseqs = 2;
|
---|
196 | r.in.arRequestedProtseqs = protseq;
|
---|
197 |
|
---|
198 | status = dcerpc_ResolveOxid2_r(b, tctx, &r);
|
---|
199 | torture_assert_ntstatus_ok(tctx, status, "ResolveOxid2");
|
---|
200 |
|
---|
201 | torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid2");
|
---|
202 |
|
---|
203 | torture_comment(tctx, "Remote server versions: %d, %d\n", r.out.ComVersion->MajorVersion, r.out.ComVersion->MinorVersion);
|
---|
204 |
|
---|
205 | return true;
|
---|
206 | }
|
---|
207 |
|
---|
208 | static bool test_ServerAlive2(struct torture_context *tctx,
|
---|
209 | struct dcerpc_pipe *p)
|
---|
210 | {
|
---|
211 | struct ServerAlive2 r;
|
---|
212 | NTSTATUS status;
|
---|
213 | struct dcerpc_binding_handle *b = p->binding_handle;
|
---|
214 |
|
---|
215 | status = dcerpc_ServerAlive2_r(b, tctx, &r);
|
---|
216 | torture_assert_ntstatus_ok(tctx, status, "ServerAlive2");
|
---|
217 | torture_assert_werr_ok(tctx, r.out.result, "ServerAlive2");
|
---|
218 |
|
---|
219 | return true;
|
---|
220 | }
|
---|
221 |
|
---|
222 | struct torture_suite *torture_rpc_oxidresolve(TALLOC_CTX *mem_ctx)
|
---|
223 | {
|
---|
224 | struct torture_suite *suite = torture_suite_create(mem_ctx, "oxidresolve");
|
---|
225 | struct torture_rpc_tcase *tcase;
|
---|
226 |
|
---|
227 | tcase = torture_suite_add_rpc_iface_tcase(suite, "oxidresolver",
|
---|
228 | &ndr_table_IOXIDResolver);
|
---|
229 |
|
---|
230 | torture_rpc_tcase_add_test(tcase, "ServerAlive", test_ServerAlive);
|
---|
231 |
|
---|
232 | torture_rpc_tcase_add_test(tcase, "ServerAlive2", test_ServerAlive2);
|
---|
233 |
|
---|
234 | torture_rpc_tcase_add_test(tcase, "ComplexPing", test_ComplexPing);
|
---|
235 |
|
---|
236 | torture_rpc_tcase_add_test(tcase, "SimplePing", test_SimplePing);
|
---|
237 |
|
---|
238 | torture_rpc_tcase_add_test(tcase, "ResolveOxid", test_ResolveOxid);
|
---|
239 |
|
---|
240 | torture_rpc_tcase_add_test(tcase, "ResolveOxid2", test_ResolveOxid2);
|
---|
241 |
|
---|
242 | return suite;
|
---|
243 | }
|
---|