r1544: add some comments and fix 'return True' -> 'return ret'
[kai/samba.git] / source / torture / rpc / srvsvc.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for srvsvc rpc operations
4
5    Copyright (C) Stefan (metze) Metzmacher 2003
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 2 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, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23
24 /**************************/
25 /* srvsvc_NetCharDev      */
26 /**************************/
27 static BOOL test_NetCharDevGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
28                                 const char *devname)
29 {
30         NTSTATUS status;
31         struct srvsvc_NetCharDevGetInfo r;
32         uint32_t levels[] = {0, 1};
33         int i;
34         BOOL ret = True;
35
36         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
37         r.in.device_name = devname;
38
39         for (i=0;i<ARRAY_SIZE(levels);i++) {
40                 ZERO_STRUCT(r.out);
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));
48                         ret = False;
49                         continue;
50                 }
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));
54                         continue;
55                 }
56         }
57
58         return ret;
59 }
60
61 static BOOL test_NetCharDevControl(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
62                                 const char *devname)
63 {
64         NTSTATUS status;
65         struct srvsvc_NetCharDevControl r;
66         uint32_t opcodes[] = {0, 1};
67         int i;
68         BOOL ret = True;
69
70         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
71         r.in.device_name = devname;
72
73         for (i=0;i<ARRAY_SIZE(opcodes);i++) {
74                 ZERO_STRUCT(r.out);
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));
81                         ret = False;
82                         continue;
83                 }
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));
86                         continue;
87                 }
88         }
89
90         return ret;
91 }
92
93 static BOOL test_NetCharDevEnum(struct dcerpc_pipe *p, 
94                            TALLOC_CTX *mem_ctx)
95 {
96         NTSTATUS status;
97         struct srvsvc_NetCharDevEnum r;
98         struct srvsvc_NetCharDevCtr0 c0;
99         uint32_t levels[] = {0, 1};
100         int i;
101         BOOL ret = True;
102
103         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
104         r.in.ctr.ctr0 = &c0;
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;
109
110         for (i=0;i<ARRAY_SIZE(levels);i++) {
111                 int j;
112
113
114                 ZERO_STRUCT(r.out);
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));
120                         ret = False;
121                         continue;
122                 }
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));
125                         continue;
126                 }
127
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++) {
131                                 const char *device;
132                                 device = r.out.ctr.ctr1->array[j].device;
133                                 if (!test_NetCharDevGetInfo(p, mem_ctx, device)) {
134                                         ret = False;
135                                 }
136                                 if (!test_NetCharDevControl(p, mem_ctx, device)) {
137                                         ret = False;
138                                 }
139                         }
140                 }
141         }
142
143         return ret;
144 }
145
146 /**************************/
147 /* srvsvc_NetCharDevQ     */
148 /**************************/
149 static BOOL test_NetCharDevQGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
150                                 const char *devicequeue)
151 {
152         NTSTATUS status;
153         struct srvsvc_NetCharDevQGetInfo r;
154         uint32_t levels[] = {0, 1};
155         int i;
156         BOOL ret = True;
157
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");
161
162         for (i=0;i<ARRAY_SIZE(levels);i++) {
163                 ZERO_STRUCT(r.out);
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));
171                         ret = False;
172                         continue;
173                 }
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));
177                         continue;
178                 }
179         }
180
181         return ret;
182 }
183
184 #if 0
185 static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
186                                 const char *devicequeue)
187 {
188         NTSTATUS status;
189         struct srvsvc_NetCharDevQSetInfo r;
190         uint32_t parm_error;
191         uint32_t levels[] = {0, 1};
192         int i;
193         BOOL ret = True;
194
195         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
196         r.in.queue_name = devicequeue;
197
198         for (i=0;i<ARRAY_SIZE(levels);i++) {
199                 ZERO_STRUCT(r.out);
200                 parm_error = 0;
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) {
205                 case 0:
206                         r.in.info.info0 = talloc_p(mem_ctx, struct srvsvc_NetCharDevQInfo0);
207                         r.in.info.info0->device = r.in.queue_name;
208                         break;
209                 case 1:
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;
216                         break;
217                 default:
218                         break;
219                 }
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));
225                         ret = False;
226                         continue;
227                 }
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));
231                         continue;
232                 }
233         }
234
235         return ret;
236 }
237 #endif
238
239 static BOOL test_NetCharDevQEnum(struct dcerpc_pipe *p, 
240                            TALLOC_CTX *mem_ctx)
241 {
242         NTSTATUS status;
243         struct srvsvc_NetCharDevQEnum r;
244         struct srvsvc_NetCharDevQCtr0 c0;
245         uint32_t levels[] = {0, 1};
246         int i;
247         BOOL ret = True;
248
249         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
250         r.in.user = talloc_asprintf(mem_ctx,"%s","Administrator");
251         r.in.ctr.ctr0 = &c0;
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;
256
257         for (i=0;i<ARRAY_SIZE(levels);i++) {
258                 int j;
259
260                 ZERO_STRUCT(r.out);
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));
266                         ret = False;
267                         continue;
268                 }
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));
271                         continue;
272                 }
273
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++) {
277                                 const char *device;
278                                 device = r.out.ctr.ctr1->array[j].device;
279                                 if (!test_NetCharDevQGetInfo(p, mem_ctx, device)) {
280                                         ret = False;
281                                 }
282                         }
283                 }
284         }
285
286         return ret;
287 }
288
289 /**************************/
290 /* srvsvc_NetConn         */
291 /**************************/
292 static BOOL test_NetConnEnum(struct dcerpc_pipe *p, 
293                            TALLOC_CTX *mem_ctx)
294 {
295         NTSTATUS status;
296         struct srvsvc_NetConnEnum r;
297         struct srvsvc_NetConnCtr0 c0;
298         uint32_t levels[] = {0, 1};
299         int i;
300         BOOL ret = True;
301
302         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
303         r.in.path = talloc_asprintf(mem_ctx,"%s","ADMIN$");
304         r.in.ctr.ctr0 = &c0;
305         r.in.ctr.ctr0->count = 0;
306         r.in.ctr.ctr0->array = NULL;
307         r.in.max_buffer = (uint32_t)-1;
308         r.in.resume_handle = NULL;
309
310         for (i=0;i<ARRAY_SIZE(levels);i++) {
311                 ZERO_STRUCT(r.out);
312                 r.in.level = levels[i];
313                 printf("testing NetConnEnum level %u\n", r.in.level);
314                 status = dcerpc_srvsvc_NetConnEnum(p, mem_ctx, &r);
315                 if (!NT_STATUS_IS_OK(status)) {
316                         printf("NetConnEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
317                         ret = False;
318                         continue;
319                 }
320                 if (!W_ERROR_IS_OK(r.out.result)) {
321                         printf("NetConnEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
322                         continue;
323                 }
324         }
325
326         return ret;
327 }
328
329 /**************************/
330 /* srvsvc_NetFile         */
331 /**************************/
332 static BOOL test_NetFileEnum(struct dcerpc_pipe *p, 
333                            TALLOC_CTX *mem_ctx)
334 {
335         NTSTATUS status;
336         struct srvsvc_NetFileEnum r;
337         struct srvsvc_NetFileCtr3 c3;
338         uint32_t levels[] = {2, 3};
339         int i;
340         BOOL ret = True;
341
342         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
343         r.in.path = NULL;
344         r.in.user = NULL;
345         r.in.ctr.ctr3 = &c3;
346         r.in.ctr.ctr3->count = 0;
347         r.in.ctr.ctr3->array = NULL;
348         r.in.max_buffer = (uint32_t)4096;
349         r.in.resume_handle = NULL;
350
351         for (i=0;i<ARRAY_SIZE(levels);i++) {
352                 ZERO_STRUCT(r.out);
353                 r.in.level = levels[i];
354                 printf("testing NetFileEnum level %u\n", r.in.level);
355                 status = dcerpc_srvsvc_NetFileEnum(p, mem_ctx, &r);
356                 if (!NT_STATUS_IS_OK(status)) {
357                         printf("NetFileEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
358                         ret = False;
359                         continue;
360                 }
361                 if (!W_ERROR_IS_OK(r.out.result)) {
362                         printf("NetFileEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
363                         continue;
364                 }
365         }
366
367         return ret;
368 }
369
370 /**************************/
371 /* srvsvc_NetSess         */
372 /**************************/
373 static BOOL test_NetSessEnum(struct dcerpc_pipe *p, 
374                            TALLOC_CTX *mem_ctx)
375 {
376         NTSTATUS status;
377         struct srvsvc_NetSessEnum r;
378         struct srvsvc_NetSessCtr0 c0;
379         uint32_t levels[] = {0, 1, 2, 10, 502};
380         int i;
381         BOOL ret = True;
382
383         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
384         r.in.client = NULL;
385         r.in.user = NULL;
386         r.in.ctr.ctr0 = &c0;
387         r.in.ctr.ctr0->count = 0;
388         r.in.ctr.ctr0->array = NULL;
389         r.in.max_buffer = (uint32_t)-1;
390         r.in.resume_handle = NULL;
391
392         for (i=0;i<ARRAY_SIZE(levels);i++) {
393                 ZERO_STRUCT(r.out);
394                 r.in.level = levels[i];
395                 printf("testing NetSessEnum level %u\n", r.in.level);
396                 status = dcerpc_srvsvc_NetSessEnum(p, mem_ctx, &r);
397                 if (!NT_STATUS_IS_OK(status)) {
398                         printf("NetSessEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
399                         ret = False;
400                         continue;
401                 }
402                 if (!W_ERROR_IS_OK(r.out.result)) {
403                         printf("NetSessEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
404                         continue;
405                 }
406         }
407
408         return ret;
409 }
410
411 /**************************/
412 /* srvsvc_NetShare        */
413 /**************************/
414 static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
415                                  const char *sharename)
416 {
417         NTSTATUS status;
418         struct srvsvc_NetShareGetInfo r;
419         uint32_t levels[] = {0, 1, 2, 501, 502, 1005};
420         int i;
421         BOOL ret = True;
422
423         r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
424         r.in.share_name = sharename;
425
426         for (i=0;i<ARRAY_SIZE(levels);i++) {
427                 ZERO_STRUCT(r.out);
428                 r.in.level = levels[i];
429
430                 printf("testing NetShareGetInfo level %u on share '%s'\n", 
431                        r.in.level, r.in.share_name);
432
433                 status = dcerpc_srvsvc_NetShareGetInfo(p, mem_ctx, &r);
434                 if (!NT_STATUS_IS_OK(status)) {
435                         printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
436                                 r.in.level, r.in.share_name, nt_errstr(status));
437                         ret = False;
438                         continue;
439                 }
440                 if (!W_ERROR_IS_OK(r.out.result)) {
441                         printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
442                                 r.in.level, r.in.share_name, win_errstr(r.out.result));
443                         continue;
444                 }
445         }
446
447         return ret;
448 }
449
450 /**************************/
451 /* srvsvc_NetShare        */
452 /**************************/
453 static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, 
454                                  TALLOC_CTX *mem_ctx)
455 {
456         NTSTATUS status;
457         struct srvsvc_NetShareEnumAll r;
458         struct srvsvc_NetShareCtr0 c0;
459         uint32_t levels[] = {0, 1, 2, 501, 502};
460         int i;
461         BOOL ret = True;
462         uint32_t resume_handle;
463
464         ZERO_STRUCT(c0);
465
466         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
467         r.in.ctr.ctr0 = &c0;
468         r.in.max_buffer = (uint32_t)-1;
469         r.in.resume_handle = &resume_handle;
470         r.out.resume_handle = &resume_handle;
471
472         for (i=0;i<ARRAY_SIZE(levels);i++) {
473                 int j;
474
475                 ZERO_STRUCT(r.out);
476                 resume_handle = 0;
477                 r.in.level = levels[i];
478                 printf("testing NetShareEnumAll level %u\n", r.in.level);
479                 status = dcerpc_srvsvc_NetShareEnumAll(p, mem_ctx, &r);
480                 if (!NT_STATUS_IS_OK(status)) {
481                         printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status));
482                         ret = False;
483                         continue;
484                 }
485                 if (!W_ERROR_IS_OK(r.out.result)) {
486                         printf("NetShareEnumAll level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
487                         continue;
488                 }
489
490                 /* call srvsvc_NetShareGetInfo for each returned share */
491                 if (r.in.level == 1) {
492                         for (j=0;j<r.out.ctr.ctr1->count;j++) {
493                                 const char *name;
494                                 name = r.out.ctr.ctr1->array[j].name;
495                                 if (!test_NetShareGetInfo(p, mem_ctx, name)) {
496                                         ret = False;
497                                 }
498                         }
499                 }
500         }
501
502         return ret;
503 }
504
505 static BOOL test_NetShareEnum(struct dcerpc_pipe *p, 
506                            TALLOC_CTX *mem_ctx)
507 {
508         NTSTATUS status;
509         struct srvsvc_NetShareEnum r;
510         struct srvsvc_NetShareCtr0 c0;
511         uint32_t levels[] = {0, 1, 2, 502};
512         int i;
513         BOOL ret = True;
514
515         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
516         r.in.ctr.ctr0 = &c0;
517         r.in.ctr.ctr0->count = 0;
518         r.in.ctr.ctr0->array = NULL;
519         r.in.max_buffer = (uint32_t)-1;
520         r.in.resume_handle = NULL;
521
522         for (i=0;i<ARRAY_SIZE(levels);i++) {
523                 ZERO_STRUCT(r.out);
524                 r.in.level = levels[i];
525                 printf("testing NetShareEnum level %u\n", r.in.level);
526                 status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r);
527                 if (!NT_STATUS_IS_OK(status)) {
528                         printf("NetShareEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
529                         ret = False;
530                         continue;
531                 }
532                 if (!W_ERROR_IS_OK(r.out.result)) {
533                         printf("NetShareEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
534                         continue;
535                 }
536         }
537
538         return ret;
539 }
540
541 /**************************/
542 /* srvsvc_NetSrv          */
543 /**************************/
544 static BOOL test_NetSrvGetInfo(struct dcerpc_pipe *p, 
545                                  TALLOC_CTX *mem_ctx)
546 {
547         NTSTATUS status;
548         struct srvsvc_NetSrvGetInfo r;
549         struct srvsvc_NetSrvInfo503 i503;
550         uint32_t levels[] = {100, 101, 102, 502, 503};
551         int i;
552         BOOL ret = True;
553         uint32_t resume_handle;
554
555         ZERO_STRUCT(i503);
556
557         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
558
559         for (i=0;i<ARRAY_SIZE(levels);i++) {
560                 ZERO_STRUCT(r.out);
561                 resume_handle = 0;
562                 r.in.level = levels[i];
563                 printf("testing NetSrvGetInfo level %u\n", r.in.level);
564                 status = dcerpc_srvsvc_NetSrvGetInfo(p, mem_ctx, &r);
565                 if (!NT_STATUS_IS_OK(status)) {
566                         printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, nt_errstr(status));
567                         ret = False;
568                         continue;
569                 }
570                 if (!W_ERROR_IS_OK(r.out.result)) {
571                         printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
572                         continue;
573                 }
574         }
575
576         return ret;
577 }
578
579 /**************************/
580 /* srvsvc_NetDisk         */
581 /**************************/
582 static BOOL test_NetDiskEnum(struct dcerpc_pipe *p, 
583                            TALLOC_CTX *mem_ctx)
584 {
585         NTSTATUS status;
586         struct srvsvc_NetDiskEnum r;
587         uint32_t levels[] = {0};
588         int i;
589         BOOL ret = True;
590         uint32_t resume_handle=0;
591
592         r.in.server_unc = NULL;
593         r.in.unknown = 0;
594         r.in.resume_handle = &resume_handle;
595         r.in.ctr.ctr0 = NULL;
596
597         for (i=0;i<ARRAY_SIZE(levels);i++) {
598                 ZERO_STRUCT(r.out);
599                 r.in.level = levels[i];
600                 printf("testing NetDiskEnum level %u\n", r.in.level);
601                 status = dcerpc_srvsvc_NetDiskEnum(p, mem_ctx, &r);
602                 if (!NT_STATUS_IS_OK(status)) {
603                         NDR_PRINT_OUT_DEBUG(srvsvc_NetDiskEnum, &r);
604                         printf("NetDiskEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
605                         ret = False;
606                         continue;
607                 }
608                 if (!W_ERROR_IS_OK(r.out.result)) {
609                         printf("NetDiskEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
610                         continue;
611                 }
612         }
613
614         return ret;
615 }
616
617 /**************************/
618 /* srvsvc_NetTransport    */
619 /**************************/
620 static BOOL test_NetTransportEnum(struct dcerpc_pipe *p, 
621                            TALLOC_CTX *mem_ctx)
622 {
623         NTSTATUS status;
624         struct srvsvc_NetTransportEnum r;
625         struct srvsvc_NetTransportCtr0 c0;
626         uint32_t levels[] = {0, 1};
627         int i;
628         BOOL ret = True;
629
630         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
631         r.in.ctr.ctr0 = &c0;
632         r.in.ctr.ctr0->count = 0;
633         r.in.ctr.ctr0->array = NULL;
634         r.in.max_buffer = (uint32_t)-1;
635         r.in.resume_handle = NULL;
636
637         for (i=0;i<ARRAY_SIZE(levels);i++) {
638                 ZERO_STRUCT(r.out);
639                 r.in.level = levels[i];
640                 printf("testing NetTransportEnum level %u\n", r.in.level);
641                 status = dcerpc_srvsvc_NetTransportEnum(p, mem_ctx, &r);
642                 if (!NT_STATUS_IS_OK(status)) {
643                         printf("NetTransportEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
644                         ret = False;
645                         continue;
646                 }
647                 if (!W_ERROR_IS_OK(r.out.result)) {
648                         printf("NetTransportEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
649                         continue;
650                 }
651         }
652
653         return ret;
654 }
655
656 /**************************/
657 /* srvsvc_NetRemoteTOD    */
658 /**************************/
659 static BOOL test_NetRemoteTOD(struct dcerpc_pipe *p, 
660                            TALLOC_CTX *mem_ctx)
661 {
662         NTSTATUS status;
663         struct srvsvc_NetRemoteTOD r;
664         BOOL ret = True;
665
666         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
667
668         ZERO_STRUCT(r.out);
669         printf("testing NetRemoteTOD\n");
670         status = dcerpc_srvsvc_NetRemoteTOD(p, mem_ctx, &r);
671         if (!NT_STATUS_IS_OK(status)) {
672                 printf("NetRemoteTOD failed - %s\n", nt_errstr(status));
673                 ret = False;
674         }
675         if (!W_ERROR_IS_OK(r.out.result)) {
676                 printf("NetRemoteTOD failed - %s\n", win_errstr(r.out.result));
677         }
678
679         return ret;
680 }
681
682 BOOL torture_rpc_srvsvc(int dummy)
683 {
684         NTSTATUS status;
685         struct dcerpc_pipe *p;
686         TALLOC_CTX *mem_ctx;
687         BOOL ret = True;
688
689         mem_ctx = talloc_init("torture_rpc_srvsvc");
690
691         status = torture_rpc_connection(&p,
692                                         DCERPC_SRVSVC_NAME,
693                                         DCERPC_SRVSVC_UUID,
694                                         DCERPC_SRVSVC_VERSION);
695         if (!NT_STATUS_IS_OK(status)) {
696                 return False;
697         }
698
699         if (!test_NetCharDevEnum(p, mem_ctx)) {
700                 ret = False;
701         }
702
703         if (!test_NetCharDevQEnum(p, mem_ctx)) {
704                 ret = False;
705         }
706
707         if (!test_NetConnEnum(p, mem_ctx)) {
708                 ret = False;
709         }
710
711         if (!test_NetFileEnum(p, mem_ctx)) {
712                 ret = False;
713         }
714
715         if (!test_NetSessEnum(p, mem_ctx)) {
716                 ret = False;
717         }
718
719         if (!test_NetShareEnumAll(p, mem_ctx)) {
720                 ret = False;
721         }
722
723         if (!test_NetSrvGetInfo(p, mem_ctx)) {
724                 ret = False;
725         }
726
727         if (!test_NetDiskEnum(p, mem_ctx)) {
728                 ret = False;
729         }
730
731         if (!test_NetTransportEnum(p, mem_ctx)) {
732                 ret = False;
733         }
734
735         if (!test_NetRemoteTOD(p, mem_ctx)) {
736                 ret = False;
737         }
738
739         if (!test_NetShareEnum(p, mem_ctx)) {
740                 ret = False;
741         }
742
743         talloc_destroy(mem_ctx);
744
745         torture_rpc_close(p);
746
747         return ret;
748 }