/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- test_handles_lsa
- test_handles_lsa_shared
- test_handles_samr
- test_handles_mixed_shared
- test_handles_random_assoc
- test_handles_drsuapi
- torture_rpc_handles
1 /*
2 Unix SMB/CIFS implementation.
3
4 test suite for behaviour of rpc policy handles
5
6 Copyright (C) Andrew Tridgell 2007
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "torture/torture.h"
24 #include "librpc/gen_ndr/ndr_samr_c.h"
25 #include "librpc/gen_ndr/ndr_lsa_c.h"
26 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
27 #include "torture/rpc/rpc.h"
28
29 /*
30 this tests the use of policy handles between connections
31 */
32
33 static bool test_handles_lsa(struct torture_context *torture)
/* [<][>][^][v][top][bottom][index][help] */
34 {
35 NTSTATUS status;
36 struct dcerpc_pipe *p1, *p2;
37 struct policy_handle handle;
38 struct policy_handle handle2;
39 struct lsa_ObjectAttribute attr;
40 struct lsa_QosInfo qos;
41 struct lsa_OpenPolicy r;
42 struct lsa_Close c;
43 uint16_t system_name = '\\';
44 TALLOC_CTX *mem_ctx = talloc_new(torture);
45
46 torture_comment(torture, "RPC-HANDLE-LSARPC\n");
47
48 status = torture_rpc_connection(torture, &p1, &ndr_table_lsarpc);
49 torture_assert_ntstatus_ok(torture, status, "opening lsa pipe1");
50
51 status = torture_rpc_connection(torture, &p2, &ndr_table_lsarpc);
52 torture_assert_ntstatus_ok(torture, status, "opening lsa pipe1");
53
54 qos.len = 0;
55 qos.impersonation_level = 2;
56 qos.context_mode = 1;
57 qos.effective_only = 0;
58
59 attr.len = 0;
60 attr.root_dir = NULL;
61 attr.object_name = NULL;
62 attr.attributes = 0;
63 attr.sec_desc = NULL;
64 attr.sec_qos = &qos;
65
66 r.in.system_name = &system_name;
67 r.in.attr = &attr;
68 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
69 r.out.handle = &handle;
70
71 status = dcerpc_lsa_OpenPolicy(p1, mem_ctx, &r);
72 if (!NT_STATUS_IS_OK(status)) {
73 torture_comment(torture, "lsa_OpenPolicy not supported - skipping\n");
74 talloc_free(mem_ctx);
75 return true;
76 }
77
78 c.in.handle = &handle;
79 c.out.handle = &handle2;
80
81 status = dcerpc_lsa_Close(p2, mem_ctx, &c);
82 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
83 "closing policy handle on p2");
84 torture_assert_int_equal(torture, p2->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
85 "closing policy handle on p2");
86
87 status = dcerpc_lsa_Close(p1, mem_ctx, &c);
88 torture_assert_ntstatus_ok(torture, status, "closing policy handle on p1");
89
90 status = dcerpc_lsa_Close(p1, mem_ctx, &c);
91 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
92 "closing policy handle on p1 again");
93 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
94 "closing policy handle on p1 again");
95
96 talloc_free(mem_ctx);
97
98 return true;
99 }
100
101 static bool test_handles_lsa_shared(struct torture_context *torture)
/* [<][>][^][v][top][bottom][index][help] */
102 {
103 NTSTATUS status;
104 struct dcerpc_pipe *p1, *p2, *p3, *p4, *p5;
105 struct policy_handle handle;
106 struct policy_handle handle2;
107 struct lsa_ObjectAttribute attr;
108 struct lsa_QosInfo qos;
109 struct lsa_OpenPolicy r;
110 struct lsa_Close c;
111 struct lsa_QuerySecurity qsec;
112 struct sec_desc_buf *sdbuf = NULL;
113 uint16_t system_name = '\\';
114 TALLOC_CTX *mem_ctx = talloc_new(torture);
115 enum dcerpc_transport_t transport;
116 uint32_t assoc_group_id;
117
118 torture_comment(torture, "RPC-HANDLE-LSARPC-SHARED\n");
119
120 torture_comment(torture, "connect lsa pipe1\n");
121 status = torture_rpc_connection(torture, &p1, &ndr_table_lsarpc);
122 torture_assert_ntstatus_ok(torture, status, "opening lsa pipe1");
123
124 transport = p1->conn->transport.transport,
125 assoc_group_id = p1->assoc_group_id;
126
127 torture_comment(torture, "use assoc_group_id[0x%08X] for new connections\n", assoc_group_id);
128
129 torture_comment(torture, "connect lsa pipe2\n");
130 status = torture_rpc_connection_transport(torture, &p2, &ndr_table_lsarpc,
131 transport,
132 assoc_group_id);
133 torture_assert_ntstatus_ok(torture, status, "opening lsa pipe2");
134
135 qos.len = 0;
136 qos.impersonation_level = 2;
137 qos.context_mode = 1;
138 qos.effective_only = 0;
139
140 attr.len = 0;
141 attr.root_dir = NULL;
142 attr.object_name = NULL;
143 attr.attributes = 0;
144 attr.sec_desc = NULL;
145 attr.sec_qos = &qos;
146
147 r.in.system_name = &system_name;
148 r.in.attr = &attr;
149 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
150 r.out.handle = &handle;
151
152 torture_comment(torture, "open lsa policy handle\n");
153 status = dcerpc_lsa_OpenPolicy(p1, mem_ctx, &r);
154 if (!NT_STATUS_IS_OK(status)) {
155 torture_comment(torture, "lsa_OpenPolicy not supported - skipping\n");
156 talloc_free(mem_ctx);
157 return true;
158 }
159
160 /*
161 * connect p3 after the policy handle is opened
162 */
163 torture_comment(torture, "connect lsa pipe3 after the policy handle is opened\n");
164 status = torture_rpc_connection_transport(torture, &p3, &ndr_table_lsarpc,
165 transport,
166 assoc_group_id);
167 torture_assert_ntstatus_ok(torture, status, "opening lsa pipe3");
168
169 qsec.in.handle = &handle;
170 qsec.in.sec_info = 0;
171 qsec.out.sdbuf = &sdbuf;
172 c.in.handle = &handle;
173 c.out.handle = &handle2;
174
175 /*
176 * use policy handle on all 3 connections
177 */
178 torture_comment(torture, "use the policy handle on p1,p2,p3\n");
179 status = dcerpc_lsa_QuerySecurity(p1, mem_ctx, &qsec);
180 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
181 "use policy handle on p1");
182
183 status = dcerpc_lsa_QuerySecurity(p2, mem_ctx, &qsec);
184 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
185 "use policy handle on p2");
186
187 status = dcerpc_lsa_QuerySecurity(p3, mem_ctx, &qsec);
188 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
189 "use policy handle on p3");
190
191 /*
192 * close policy handle on connection 2 and the others get a fault
193 */
194 torture_comment(torture, "close the policy handle on p2 others get a fault\n");
195 status = dcerpc_lsa_Close(p2, mem_ctx, &c);
196 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
197 "closing policy handle on p2");
198
199 status = dcerpc_lsa_Close(p1, mem_ctx, &c);
200 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
201 "closing policy handle on p1 again");
202 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
203 "closing policy handle on p1 again");
204
205 status = dcerpc_lsa_Close(p3, mem_ctx, &c);
206 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
207 "closing policy handle on p3");
208 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
209 "closing policy handle on p3");
210
211 status = dcerpc_lsa_Close(p2, mem_ctx, &c);
212 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
213 "closing policy handle on p2 again");
214 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
215 "closing policy handle on p2 again");
216
217 /*
218 * open a new policy handle on p3
219 */
220 torture_comment(torture, "open a new policy handle on p3\n");
221 status = dcerpc_lsa_OpenPolicy(p3, mem_ctx, &r);
222 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
223 "open policy handle on p3");
224
225 /*
226 * use policy handle on all 3 connections
227 */
228 torture_comment(torture, "use the policy handle on p1,p2,p3\n");
229 status = dcerpc_lsa_QuerySecurity(p1, mem_ctx, &qsec);
230 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
231 "use policy handle on p1");
232
233 status = dcerpc_lsa_QuerySecurity(p2, mem_ctx, &qsec);
234 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
235 "use policy handle on p2");
236
237 status = dcerpc_lsa_QuerySecurity(p3, mem_ctx, &qsec);
238 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
239 "use policy handle on p3");
240
241 /*
242 * close policy handle on connection 2 and the others get a fault
243 */
244 torture_comment(torture, "close the policy handle on p2 others get a fault\n");
245 status = dcerpc_lsa_Close(p2, mem_ctx, &c);
246 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
247 "closing policy handle on p2");
248
249 status = dcerpc_lsa_Close(p1, mem_ctx, &c);
250 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
251 "closing policy handle on p1 again");
252 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
253 "closing policy handle on p1 again");
254
255 status = dcerpc_lsa_Close(p3, mem_ctx, &c);
256 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
257 "closing policy handle on p3");
258 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
259 "closing policy handle on p3");
260
261 status = dcerpc_lsa_Close(p2, mem_ctx, &c);
262 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
263 "closing policy handle on p2 again");
264 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
265 "closing policy handle on p2 again");
266
267 /*
268 * open a new policy handle
269 */
270 torture_comment(torture, "open a new policy handle on p1 and use it\n");
271 status = dcerpc_lsa_OpenPolicy(p1, mem_ctx, &r);
272 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
273 "open 2nd policy handle on p1");
274
275 status = dcerpc_lsa_QuerySecurity(p1, mem_ctx, &qsec);
276 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
277 "QuerySecurity handle on p1");
278
279 /* close first connection */
280 torture_comment(torture, "disconnect p1\n");
281 talloc_free(p1);
282 msleep(5);
283
284 /*
285 * and it's still available on p2,p3
286 */
287 torture_comment(torture, "use policy handle on p2,p3\n");
288 status = dcerpc_lsa_QuerySecurity(p2, mem_ctx, &qsec);
289 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
290 "QuerySecurity handle on p2 after p1 was disconnected");
291
292 status = dcerpc_lsa_QuerySecurity(p3, mem_ctx, &qsec);
293 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
294 "QuerySecurity handle on p3 after p1 was disconnected");
295
296 /*
297 * now open p4
298 * and use the handle on it
299 */
300 torture_comment(torture, "connect lsa pipe4 and use policy handle\n");
301 status = torture_rpc_connection_transport(torture, &p4, &ndr_table_lsarpc,
302 transport,
303 assoc_group_id);
304 torture_assert_ntstatus_ok(torture, status, "opening lsa pipe4");
305
306 status = dcerpc_lsa_QuerySecurity(p4, mem_ctx, &qsec);
307 torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
308 "using policy handle on p4");
309
310 /*
311 * now close p2,p3,p4
312 * without closing the policy handle
313 */
314 torture_comment(torture, "disconnect p2,p3,p4\n");
315 talloc_free(p2);
316 talloc_free(p3);
317 talloc_free(p4);
318 msleep(10);
319
320 /*
321 * now open p5
322 */
323 torture_comment(torture, "connect lsa pipe5 - should fail\n");
324 status = torture_rpc_connection_transport(torture, &p5, &ndr_table_lsarpc,
325 transport,
326 assoc_group_id);
327 torture_assert_ntstatus_equal(torture, status, NT_STATUS_UNSUCCESSFUL,
328 "opening lsa pipe5");
329
330 talloc_free(mem_ctx);
331
332 return true;
333 }
334
335
336 static bool test_handles_samr(struct torture_context *torture)
/* [<][>][^][v][top][bottom][index][help] */
337 {
338 NTSTATUS status;
339 struct dcerpc_pipe *p1, *p2;
340 struct policy_handle handle;
341 struct policy_handle handle2;
342 struct samr_Connect r;
343 struct samr_Close c;
344 TALLOC_CTX *mem_ctx = talloc_new(torture);
345
346 torture_comment(torture, "RPC-HANDLE-SAMR\n");
347
348 status = torture_rpc_connection(torture, &p1, &ndr_table_samr);
349 torture_assert_ntstatus_ok(torture, status, "opening samr pipe1");
350
351 status = torture_rpc_connection(torture, &p2, &ndr_table_samr);
352 torture_assert_ntstatus_ok(torture, status, "opening samr pipe1");
353
354 r.in.system_name = 0;
355 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
356 r.out.connect_handle = &handle;
357
358 status = dcerpc_samr_Connect(p1, mem_ctx, &r);
359 torture_assert_ntstatus_ok(torture, status, "opening policy handle on p1");
360
361 c.in.handle = &handle;
362 c.out.handle = &handle2;
363
364 status = dcerpc_samr_Close(p2, mem_ctx, &c);
365 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
366 "closing policy handle on p2");
367 torture_assert_int_equal(torture, p2->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
368 "closing policy handle on p2");
369
370 status = dcerpc_samr_Close(p1, mem_ctx, &c);
371 torture_assert_ntstatus_ok(torture, status, "closing policy handle on p1");
372
373 status = dcerpc_samr_Close(p1, mem_ctx, &c);
374 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
375 "closing policy handle on p1 again");
376 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
377 "closing policy handle on p1 again");
378
379 talloc_free(mem_ctx);
380
381 return true;
382 }
383
384 static bool test_handles_mixed_shared(struct torture_context *torture)
/* [<][>][^][v][top][bottom][index][help] */
385 {
386 NTSTATUS status;
387 struct dcerpc_pipe *p1, *p2, *p3, *p4, *p5, *p6;
388 struct policy_handle handle;
389 struct policy_handle handle2;
390 struct samr_Connect r;
391 struct lsa_Close lc;
392 struct samr_Close sc;
393 TALLOC_CTX *mem_ctx = talloc_new(torture);
394 enum dcerpc_transport_t transport;
395 uint32_t assoc_group_id;
396
397 torture_comment(torture, "RPC-HANDLE-MIXED-SHARED\n");
398
399 torture_comment(torture, "connect samr pipe1\n");
400 status = torture_rpc_connection(torture, &p1, &ndr_table_samr);
401 torture_assert_ntstatus_ok(torture, status, "opening samr pipe1");
402
403 transport = p1->conn->transport.transport,
404 assoc_group_id = p1->assoc_group_id;
405
406 torture_comment(torture, "use assoc_group_id[0x%08X] for new connections\n", assoc_group_id);
407
408 torture_comment(torture, "connect lsa pipe2\n");
409 status = torture_rpc_connection_transport(torture, &p2, &ndr_table_lsarpc,
410 transport,
411 assoc_group_id);
412 torture_assert_ntstatus_ok(torture, status, "opening lsa pipe2");
413
414 r.in.system_name = 0;
415 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
416 r.out.connect_handle = &handle;
417
418 torture_comment(torture, "samr_Connect to open a policy handle on samr p1\n");
419 status = dcerpc_samr_Connect(p1, mem_ctx, &r);
420 torture_assert_ntstatus_ok(torture, status, "opening policy handle on p1");
421
422 lc.in.handle = &handle;
423 lc.out.handle = &handle2;
424 sc.in.handle = &handle;
425 sc.out.handle = &handle2;
426
427 torture_comment(torture, "use policy handle on lsa p2 - should fail\n");
428 status = dcerpc_lsa_Close(p2, mem_ctx, &lc);
429 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
430 "closing handle on lsa p2");
431 torture_assert_int_equal(torture, p2->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
432 "closing handle on lsa p2");
433
434 torture_comment(torture, "closing policy handle on samr p1\n");
435 status = dcerpc_samr_Close(p1, mem_ctx, &sc);
436 torture_assert_ntstatus_ok(torture, status, "closing policy handle on p1");
437
438 talloc_free(p1);
439 talloc_free(p2);
440 msleep(10);
441
442 torture_comment(torture, "connect samr pipe3 - should fail\n");
443 status = torture_rpc_connection_transport(torture, &p3, &ndr_table_samr,
444 transport,
445 assoc_group_id);
446 torture_assert_ntstatus_equal(torture, status, NT_STATUS_UNSUCCESSFUL,
447 "opening samr pipe3");
448
449 torture_comment(torture, "connect lsa pipe4 - should fail\n");
450 status = torture_rpc_connection_transport(torture, &p4, &ndr_table_lsarpc,
451 transport,
452 assoc_group_id);
453 torture_assert_ntstatus_equal(torture, status, NT_STATUS_UNSUCCESSFUL,
454 "opening lsa pipe4");
455
456 torture_comment(torture, "connect samr pipe5 with assoc_group_id[0x%08X]- should fail\n", ++assoc_group_id);
457 status = torture_rpc_connection_transport(torture, &p5, &ndr_table_samr,
458 transport,
459 assoc_group_id);
460 torture_assert_ntstatus_equal(torture, status, NT_STATUS_UNSUCCESSFUL,
461 "opening samr pipe5");
462
463 torture_comment(torture, "connect lsa pipe6 with assoc_group_id[0x%08X]- should fail\n", ++assoc_group_id);
464 status = torture_rpc_connection_transport(torture, &p6, &ndr_table_lsarpc,
465 transport,
466 assoc_group_id);
467 torture_assert_ntstatus_equal(torture, status, NT_STATUS_UNSUCCESSFUL,
468 "opening lsa pipe6");
469
470 talloc_free(mem_ctx);
471
472 return true;
473 }
474
475 static bool test_handles_random_assoc(struct torture_context *torture)
/* [<][>][^][v][top][bottom][index][help] */
476 {
477 NTSTATUS status;
478 struct dcerpc_pipe *p1, *p2, *p3;
479 TALLOC_CTX *mem_ctx = talloc_new(torture);
480 enum dcerpc_transport_t transport;
481 uint32_t assoc_group_id;
482
483 torture_comment(torture, "RPC-HANDLE-RANDOM-ASSOC\n");
484
485 torture_comment(torture, "connect samr pipe1\n");
486 status = torture_rpc_connection(torture, &p1, &ndr_table_samr);
487 torture_assert_ntstatus_ok(torture, status, "opening samr pipe1");
488
489 transport = p1->conn->transport.transport,
490 assoc_group_id = p1->assoc_group_id;
491
492 torture_comment(torture, "pip1 use assoc_group_id[0x%08X]\n", assoc_group_id);
493
494 torture_comment(torture, "connect samr pipe2 with assoc_group_id[0x%08X]- should fail\n", ++assoc_group_id);
495 status = torture_rpc_connection_transport(torture, &p2, &ndr_table_samr,
496 transport,
497 assoc_group_id);
498 torture_assert_ntstatus_equal(torture, status, NT_STATUS_UNSUCCESSFUL,
499 "opening samr pipe2");
500
501 torture_comment(torture, "connect samr pipe3 with assoc_group_id[0x%08X]- should fail\n", ++assoc_group_id);
502 status = torture_rpc_connection_transport(torture, &p3, &ndr_table_samr,
503 transport,
504 assoc_group_id);
505 torture_assert_ntstatus_equal(torture, status, NT_STATUS_UNSUCCESSFUL,
506 "opening samr pipe3");
507
508 talloc_free(mem_ctx);
509
510 return true;
511 }
512
513
514 static bool test_handles_drsuapi(struct torture_context *torture)
/* [<][>][^][v][top][bottom][index][help] */
515 {
516 NTSTATUS status;
517 struct dcerpc_pipe *p1, *p2;
518 struct policy_handle handle;
519 struct policy_handle handle2;
520 struct GUID bind_guid;
521 struct drsuapi_DsBind r;
522 struct drsuapi_DsUnbind c;
523 TALLOC_CTX *mem_ctx = talloc_new(torture);
524
525 torture_comment(torture, "RPC-HANDLE-DRSUAPI\n");
526
527 status = torture_rpc_connection(torture, &p1, &ndr_table_drsuapi);
528 torture_assert_ntstatus_ok(torture, status, "opening drsuapi pipe1");
529
530 status = torture_rpc_connection(torture, &p2, &ndr_table_drsuapi);
531 torture_assert_ntstatus_ok(torture, status, "opening drsuapi pipe1");
532
533 GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid);
534
535 r.in.bind_guid = &bind_guid;
536 r.in.bind_info = NULL;
537 r.out.bind_handle = &handle;
538
539 status = dcerpc_drsuapi_DsBind(p1, mem_ctx, &r);
540 if (!NT_STATUS_IS_OK(status)) {
541 torture_comment(torture, "drsuapi_DsBind not supported - skipping\n");
542 talloc_free(mem_ctx);
543 return true;
544 }
545
546 c.in.bind_handle = &handle;
547 c.out.bind_handle = &handle2;
548
549 status = dcerpc_drsuapi_DsUnbind(p2, mem_ctx, &c);
550 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
551 "closing policy handle on p2");
552 torture_assert_int_equal(torture, p2->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
553 "closing policy handle on p2");
554
555 status = dcerpc_drsuapi_DsUnbind(p1, mem_ctx, &c);
556 torture_assert_ntstatus_ok(torture, status, "closing policy handle on p1");
557
558 status = dcerpc_drsuapi_DsUnbind(p1, mem_ctx, &c);
559 torture_assert_ntstatus_equal(torture, status, NT_STATUS_NET_WRITE_FAULT,
560 "closing policy handle on p1 again");
561 torture_assert_int_equal(torture, p1->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
562 "closing policy handle on p1 again");
563
564 talloc_free(mem_ctx);
565
566 return true;
567 }
568
569
570 struct torture_suite *torture_rpc_handles(TALLOC_CTX *mem_ctx)
/* [<][>][^][v][top][bottom][index][help] */
571 {
572 struct torture_suite *suite;
573
574 suite = torture_suite_create(mem_ctx, "HANDLES");
575 torture_suite_add_simple_test(suite, "lsarpc", test_handles_lsa);
576 torture_suite_add_simple_test(suite, "lsarpc-shared", test_handles_lsa_shared);
577 torture_suite_add_simple_test(suite, "samr", test_handles_samr);
578 torture_suite_add_simple_test(suite, "mixed-shared", test_handles_mixed_shared);
579 torture_suite_add_simple_test(suite, "random-assoc", test_handles_random_assoc);
580 torture_suite_add_simple_test(suite, "drsuapi", test_handles_drsuapi);
581 return suite;
582 }