2 Unix SMB/CIFS implementation.
3 test suite for srvsvc rpc operations
5 Copyright (C) Stefan (metze) Metzmacher 2003
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 2 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /**************************/
25 /* srvsvc_NetCharDev */
26 /**************************/
27 static BOOL test_NetCharDevGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
31 struct srvsvc_NetCharDevGetInfo r;
32 uint32_t levels[] = {0, 1};
36 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
37 r.in.device_name = devname;
39 for (i=0;i<ARRAY_SIZE(levels);i++) {
41 r.in.level = levels[i];
42 printf("testing NetCharDevGetInfo level %u on device '%s'\n",
43 r.in.level, r.in.device_name);
44 status = dcerpc_srvsvc_NetCharDevGetInfo(p, mem_ctx, &r);
45 if (!NT_STATUS_IS_OK(status)) {
46 printf("NetCharDevGetInfo level %u on device '%s' failed - %s\n",
47 r.in.level, r.in.device_name, nt_errstr(status));
51 if (!W_ERROR_IS_OK(r.out.result)) {
52 printf("NetCharDevGetInfo level %u on device '%s' failed - %s\n",
53 r.in.level, r.in.device_name, win_errstr(r.out.result));
61 static BOOL test_NetCharDevControl(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
65 struct srvsvc_NetCharDevControl r;
66 uint32_t opcodes[] = {0, 1};
70 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
71 r.in.device_name = devname;
73 for (i=0;i<ARRAY_SIZE(opcodes);i++) {
75 r.in.opcode = opcodes[i];
76 printf("testing NetCharDevControl opcode %u on device '%s'\n",
77 r.in.opcode, r.in.device_name);
78 status = dcerpc_srvsvc_NetCharDevControl(p, mem_ctx, &r);
79 if (!NT_STATUS_IS_OK(status)) {
80 printf("NetCharDevControl opcode %u failed - %s\n", r.in.opcode, nt_errstr(status));
84 if (!W_ERROR_IS_OK(r.out.result)) {
85 printf("NetCharDevControl opcode %u failed - %s\n", r.in.opcode, win_errstr(r.out.result));
93 static BOOL test_NetCharDevEnum(struct dcerpc_pipe *p,
97 struct srvsvc_NetCharDevEnum r;
98 struct srvsvc_NetCharDevCtr0 c0;
99 uint32_t levels[] = {0, 1};
103 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
105 r.in.ctr.ctr0->count = 0;
106 r.in.ctr.ctr0->array = NULL;
107 r.in.max_buffer = (uint32)-1;
108 r.in.resume_handle = NULL;
110 for (i=0;i<ARRAY_SIZE(levels);i++) {
115 r.in.level = levels[i];
116 printf("testing NetCharDevEnum level %u\n", r.in.level);
117 status = dcerpc_srvsvc_NetCharDevEnum(p, mem_ctx, &r);
118 if (!NT_STATUS_IS_OK(status)) {
119 printf("NetCharDevEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
123 if (!W_ERROR_IS_OK(r.out.result)) {
124 printf("NetCharDevEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
128 /* call test_NetCharDevGetInfo and test_NetCharDevControl for each returned share */
129 if (r.in.level == 1) {
130 for (j=0;j<r.out.ctr.ctr1->count;j++) {
132 device = r.out.ctr.ctr1->array[j].device;
133 if (!test_NetCharDevGetInfo(p, mem_ctx, device)) {
136 if (!test_NetCharDevControl(p, mem_ctx, device)) {
146 /**************************/
147 /* srvsvc_NetCharDevQ */
148 /**************************/
149 static BOOL test_NetCharDevQGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
150 const char *devicequeue)
153 struct srvsvc_NetCharDevQGetInfo r;
154 uint32_t levels[] = {0, 1};
158 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
159 r.in.queue_name = devicequeue;
160 r.in.user = talloc_asprintf(mem_ctx,"Administrator");
162 for (i=0;i<ARRAY_SIZE(levels);i++) {
164 r.in.level = levels[i];
165 printf("testing NetCharDevQGetInfo level %u on devicequeue '%s'\n",
166 r.in.level, r.in.queue_name);
167 status = dcerpc_srvsvc_NetCharDevQGetInfo(p, mem_ctx, &r);
168 if (!NT_STATUS_IS_OK(status)) {
169 printf("NetCharDevQGetInfo level %u on devicequeue '%s' failed - %s\n",
170 r.in.level, r.in.queue_name, nt_errstr(status));
174 if (!W_ERROR_IS_OK(r.out.result)) {
175 printf("NetCharDevQGetInfo level %u on devicequeue '%s' failed - %s\n",
176 r.in.level, r.in.queue_name, win_errstr(r.out.result));
185 static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
186 const char *devicequeue)
189 struct srvsvc_NetCharDevQSetInfo r;
191 uint32_t levels[] = {0, 1};
195 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
196 r.in.queue_name = devicequeue;
198 for (i=0;i<ARRAY_SIZE(levels);i++) {
201 r.in.level = levels[i];
202 printf("testing NetCharDevQSetInfo level %u on devicequeue '%s'\n",
203 r.in.level, devicequeue);
204 switch (r.in.level) {
206 r.in.info.info0 = talloc_p(mem_ctx, struct srvsvc_NetCharDevQInfo0);
207 r.in.info.info0->device = r.in.queue_name;
210 r.in.info.info1 = talloc_p(mem_ctx, struct srvsvc_NetCharDevQInfo1);
211 r.in.info.info1->device = r.in.queue_name;
212 r.in.info.info1->priority = 0x000;
213 r.in.info.info1->devices = r.in.queue_name;
214 r.in.info.info1->users = 0x000;
215 r.in.info.info1->num_ahead = 0x000;
220 r.in.parm_error = &parm_error;
221 status = dcerpc_srvsvc_NetCharDevQSetInfo(p, mem_ctx, &r);
222 if (!NT_STATUS_IS_OK(status)) {
223 printf("NetCharDevQSetInfo level %u on devicequeue '%s' failed - %s\n",
224 r.in.level, r.in.queue_name, nt_errstr(status));
228 if (!W_ERROR_IS_OK(r.out.result)) {
229 printf("NetCharDevQSetInfo level %u on devicequeue '%s' failed - %s\n",
230 r.in.level, r.in.queue_name, win_errstr(r.out.result));
239 static BOOL test_NetCharDevQEnum(struct dcerpc_pipe *p,
243 struct srvsvc_NetCharDevQEnum r;
244 struct srvsvc_NetCharDevQCtr0 c0;
245 uint32_t levels[] = {0, 1};
249 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
250 r.in.user = talloc_asprintf(mem_ctx,"%s","Administrator");
252 r.in.ctr.ctr0->count = 0;
253 r.in.ctr.ctr0->array = NULL;
254 r.in.max_buffer = (uint32)-1;
255 r.in.resume_handle = NULL;
257 for (i=0;i<ARRAY_SIZE(levels);i++) {
261 r.in.level = levels[i];
262 printf("testing NetCharDevQEnum level %u\n", r.in.level);
263 status = dcerpc_srvsvc_NetCharDevQEnum(p, mem_ctx, &r);
264 if (!NT_STATUS_IS_OK(status)) {
265 printf("NetCharDevQEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
269 if (!W_ERROR_IS_OK(r.out.result)) {
270 printf("NetCharDevQEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
274 /* call test_NetCharDevGetInfo and test_NetCharDevControl for each returned share */
275 if (r.in.level == 1) {
276 for (j=0;j<r.out.ctr.ctr1->count;j++) {
278 device = r.out.ctr.ctr1->array[j].device;
279 if (!test_NetCharDevQGetInfo(p, mem_ctx, device)) {
290 static BOOL test_NetConnEnum(struct dcerpc_pipe *p,
294 struct srvsvc_NetConnEnum r;
295 struct srvsvc_NetConnCtr0 c0;
296 uint32_t levels[] = {0, 1};
300 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
301 r.in.path = talloc_asprintf(mem_ctx,"%s","ADMIN$");
303 r.in.ctr.ctr0->count = 0;
304 r.in.ctr.ctr0->array = NULL;
305 r.in.max_buffer = (uint32_t)-1;
306 r.in.resume_handle = NULL;
308 for (i=0;i<ARRAY_SIZE(levels);i++) {
310 r.in.level = levels[i];
311 printf("testing NetConnEnum level %u\n", r.in.level);
312 status = dcerpc_srvsvc_NetConnEnum(p, mem_ctx, &r);
313 if (!NT_STATUS_IS_OK(status)) {
314 printf("NetConnEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
318 if (!W_ERROR_IS_OK(r.out.result)) {
319 printf("NetConnEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
327 static BOOL test_NetFileEnum(struct dcerpc_pipe *p,
331 struct srvsvc_NetFileEnum r;
332 struct srvsvc_NetFileCtr3 c3;
333 uint32_t levels[] = {2, 3};
337 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
341 r.in.ctr.ctr3->count = 0;
342 r.in.ctr.ctr3->array = NULL;
343 r.in.max_buffer = (uint32_t)4096;
344 r.in.resume_handle = NULL;
346 for (i=0;i<ARRAY_SIZE(levels);i++) {
348 r.in.level = levels[i];
349 printf("testing NetFileEnum level %u\n", r.in.level);
350 status = dcerpc_srvsvc_NetFileEnum(p, mem_ctx, &r);
351 if (!NT_STATUS_IS_OK(status)) {
352 printf("NetFileEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
356 if (!W_ERROR_IS_OK(r.out.result)) {
357 printf("NetFileEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
365 static BOOL test_NetSessEnum(struct dcerpc_pipe *p,
369 struct srvsvc_NetSessEnum r;
370 struct srvsvc_NetSessCtr0 c0;
371 uint32_t levels[] = {0, 1, 2, 10, 502};
375 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
379 r.in.ctr.ctr0->count = 0;
380 r.in.ctr.ctr0->array = NULL;
381 r.in.max_buffer = (uint32_t)-1;
382 r.in.resume_handle = NULL;
384 for (i=0;i<ARRAY_SIZE(levels);i++) {
386 r.in.level = levels[i];
387 printf("testing NetSessEnum level %u\n", r.in.level);
388 status = dcerpc_srvsvc_NetSessEnum(p, mem_ctx, &r);
389 if (!NT_STATUS_IS_OK(status)) {
390 printf("NetSessEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
394 if (!W_ERROR_IS_OK(r.out.result)) {
395 printf("NetSessEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
403 /**************************/
404 /* srvsvc_NetShare */
405 /**************************/
406 static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
407 const char *sharename)
410 struct srvsvc_NetShareGetInfo r;
411 uint32_t levels[] = {0, 1, 2, 501, 502, 1005};
415 r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
416 r.in.share_name = sharename;
418 for (i=0;i<ARRAY_SIZE(levels);i++) {
420 r.in.level = levels[i];
422 printf("testing NetShareGetInfo level %u on share '%s'\n",
423 r.in.level, r.in.share_name);
425 status = dcerpc_srvsvc_NetShareGetInfo(p, mem_ctx, &r);
426 if (!NT_STATUS_IS_OK(status)) {
427 printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
428 r.in.level, r.in.share_name, nt_errstr(status));
432 if (!W_ERROR_IS_OK(r.out.result)) {
433 printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
434 r.in.level, r.in.share_name, win_errstr(r.out.result));
442 static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p,
446 struct srvsvc_NetShareEnumAll r;
447 struct srvsvc_NetShareCtr0 c0;
448 uint32_t levels[] = {0, 1, 2, 501, 502};
451 uint32_t resume_handle;
455 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
457 r.in.max_buffer = (uint32_t)-1;
458 r.in.resume_handle = &resume_handle;
459 r.out.resume_handle = &resume_handle;
461 for (i=0;i<ARRAY_SIZE(levels);i++) {
466 r.in.level = levels[i];
467 printf("testing NetShareEnumAll level %u\n", r.in.level);
468 status = dcerpc_srvsvc_NetShareEnumAll(p, mem_ctx, &r);
469 if (!NT_STATUS_IS_OK(status)) {
470 printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status));
474 if (!W_ERROR_IS_OK(r.out.result)) {
475 printf("NetShareEnumAll level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
479 /* call srvsvc_NetShareGetInfo for each returned share */
480 if (r.in.level == 1) {
481 for (j=0;j<r.out.ctr.ctr1->count;j++) {
483 name = r.out.ctr.ctr1->array[j].name;
484 if (!test_NetShareGetInfo(p, mem_ctx, name)) {
494 static BOOL test_NetShareEnum(struct dcerpc_pipe *p,
498 struct srvsvc_NetShareEnum r;
499 struct srvsvc_NetShareCtr0 c0;
500 uint32_t levels[] = {0, 1, 2, 502};
504 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
506 r.in.ctr.ctr0->count = 0;
507 r.in.ctr.ctr0->array = NULL;
508 r.in.max_buffer = (uint32_t)-1;
509 r.in.resume_handle = NULL;
511 for (i=0;i<ARRAY_SIZE(levels);i++) {
515 r.in.level = levels[i];
516 printf("testing NetShareEnum level %u\n", r.in.level);
517 status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r);
518 if (!NT_STATUS_IS_OK(status)) {
519 printf("NetShareEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
523 if (!W_ERROR_IS_OK(r.out.result)) {
524 printf("NetShareEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
528 /* call srvsvc_NetShareGetInfo for each returned share */
529 if (r.in.level == 1) {
530 for (j=0;j<r.out.ctr.ctr1->count;j++) {
532 name = r.out.ctr.ctr1->array[j].name;
533 if (!test_NetShareGetInfo(p, mem_ctx, name)) {
543 /**************************/
545 /**************************/
546 static BOOL test_NetSrvGetInfo(struct dcerpc_pipe *p,
550 struct srvsvc_NetSrvGetInfo r;
551 struct srvsvc_NetSrvInfo503 i503;
552 uint32_t levels[] = {100, 101, 102, 502, 503};
555 uint32_t resume_handle;
559 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
561 for (i=0;i<ARRAY_SIZE(levels);i++) {
564 r.in.level = levels[i];
565 printf("testing NetSrvGetInfo level %u\n", r.in.level);
566 status = dcerpc_srvsvc_NetSrvGetInfo(p, mem_ctx, &r);
567 if (!NT_STATUS_IS_OK(status)) {
568 printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, nt_errstr(status));
572 if (!W_ERROR_IS_OK(r.out.result)) {
573 printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
581 /**************************/
583 /**************************/
584 static BOOL test_NetDiskEnum(struct dcerpc_pipe *p,
588 struct srvsvc_NetDiskEnum r;
589 uint32_t levels[] = {0};
592 uint32_t resume_handle=0;
594 r.in.server_unc = NULL;
596 r.in.resume_handle = &resume_handle;
597 r.in.ctr.ctr0 = NULL;
599 for (i=0;i<ARRAY_SIZE(levels);i++) {
601 r.in.level = levels[i];
602 printf("testing NetDiskEnum level %u\n", r.in.level);
603 status = dcerpc_srvsvc_NetDiskEnum(p, mem_ctx, &r);
604 if (!NT_STATUS_IS_OK(status)) {
605 NDR_PRINT_OUT_DEBUG(srvsvc_NetDiskEnum, &r);
606 printf("NetDiskEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
610 if (!W_ERROR_IS_OK(r.out.result)) {
611 printf("NetDiskEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
619 /**************************/
620 /* srvsvc_NetTransport */
621 /**************************/
622 static BOOL test_NetTransportEnum(struct dcerpc_pipe *p,
626 struct srvsvc_NetTransportEnum r;
627 struct srvsvc_NetTransportCtr0 c0;
628 uint32_t levels[] = {0, 1};
632 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
634 r.in.ctr.ctr0->count = 0;
635 r.in.ctr.ctr0->array = NULL;
636 r.in.max_buffer = (uint32_t)-1;
637 r.in.resume_handle = NULL;
639 for (i=0;i<ARRAY_SIZE(levels);i++) {
641 r.in.level = levels[i];
642 printf("testing NetTransportEnum level %u\n", r.in.level);
643 status = dcerpc_srvsvc_NetTransportEnum(p, mem_ctx, &r);
644 if (!NT_STATUS_IS_OK(status)) {
645 printf("NetTransportEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
649 if (!W_ERROR_IS_OK(r.out.result)) {
650 printf("NetTransportEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
658 BOOL torture_rpc_srvsvc(int dummy)
661 struct dcerpc_pipe *p;
665 mem_ctx = talloc_init("torture_rpc_srvsvc");
667 status = torture_rpc_connection(&p,
670 DCERPC_SRVSVC_VERSION);
671 if (!NT_STATUS_IS_OK(status)) {
675 if (!test_NetCharDevEnum(p, mem_ctx)) {
679 if (!test_NetCharDevQEnum(p, mem_ctx)) {
683 if (!test_NetConnEnum(p, mem_ctx)) {
687 if (!test_NetFileEnum(p, mem_ctx)) {
691 if (!test_NetSessEnum(p, mem_ctx)) {
695 if (!test_NetShareEnumAll(p, mem_ctx)) {
699 if (!test_NetSrvGetInfo(p, mem_ctx)) {
703 if (!test_NetDiskEnum(p, mem_ctx)) {
707 if (!test_NetTransportEnum(p, mem_ctx)) {
711 if (!test_NetShareEnum(p, mem_ctx)) {
715 talloc_destroy(mem_ctx);
717 torture_rpc_close(p);