r1543: add srvsvc_NetRemoteTOD idl and torture tests
[metze/samba/wip.git] / source4 / 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 static BOOL test_NetConnEnum(struct dcerpc_pipe *p, 
291                            TALLOC_CTX *mem_ctx)
292 {
293         NTSTATUS status;
294         struct srvsvc_NetConnEnum r;
295         struct srvsvc_NetConnCtr0 c0;
296         uint32_t levels[] = {0, 1};
297         int i;
298         BOOL ret = True;
299
300         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
301         r.in.path = talloc_asprintf(mem_ctx,"%s","ADMIN$");
302         r.in.ctr.ctr0 = &c0;
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;
307
308         for (i=0;i<ARRAY_SIZE(levels);i++) {
309                 ZERO_STRUCT(r.out);
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));
315                         ret = False;
316                         continue;
317                 }
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));
320                         continue;
321                 }
322         }
323
324         return True;
325 }
326
327 static BOOL test_NetFileEnum(struct dcerpc_pipe *p, 
328                            TALLOC_CTX *mem_ctx)
329 {
330         NTSTATUS status;
331         struct srvsvc_NetFileEnum r;
332         struct srvsvc_NetFileCtr3 c3;
333         uint32_t levels[] = {2, 3};
334         int i;
335         BOOL ret = True;
336
337         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
338         r.in.path = NULL;
339         r.in.user = NULL;
340         r.in.ctr.ctr3 = &c3;
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;
345
346         for (i=0;i<ARRAY_SIZE(levels);i++) {
347                 ZERO_STRUCT(r.out);
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));
353                         ret = False;
354                         continue;
355                 }
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));
358                         continue;
359                 }
360         }
361
362         return True;
363 }
364
365 static BOOL test_NetSessEnum(struct dcerpc_pipe *p, 
366                            TALLOC_CTX *mem_ctx)
367 {
368         NTSTATUS status;
369         struct srvsvc_NetSessEnum r;
370         struct srvsvc_NetSessCtr0 c0;
371         uint32_t levels[] = {0, 1, 2, 10, 502};
372         int i;
373         BOOL ret = True;
374
375         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
376         r.in.client = NULL;
377         r.in.user = NULL;
378         r.in.ctr.ctr0 = &c0;
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;
383
384         for (i=0;i<ARRAY_SIZE(levels);i++) {
385                 ZERO_STRUCT(r.out);
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));
391                         ret = False;
392                         continue;
393                 }
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));
396                         continue;
397                 }
398         }
399
400         return True;
401 }
402
403 /**************************/
404 /* srvsvc_NetShare        */
405 /**************************/
406 static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
407                                  const char *sharename)
408 {
409         NTSTATUS status;
410         struct srvsvc_NetShareGetInfo r;
411         uint32_t levels[] = {0, 1, 2, 501, 502, 1005};
412         int i;
413         BOOL ret = True;
414
415         r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
416         r.in.share_name = sharename;
417
418         for (i=0;i<ARRAY_SIZE(levels);i++) {
419                 ZERO_STRUCT(r.out);
420                 r.in.level = levels[i];
421
422                 printf("testing NetShareGetInfo level %u on share '%s'\n", 
423                        r.in.level, r.in.share_name);
424
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));
429                         ret = False;
430                         continue;
431                 }
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));
435                         continue;
436                 }
437         }
438
439         return ret;
440 }
441
442 static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, 
443                                  TALLOC_CTX *mem_ctx)
444 {
445         NTSTATUS status;
446         struct srvsvc_NetShareEnumAll r;
447         struct srvsvc_NetShareCtr0 c0;
448         uint32_t levels[] = {0, 1, 2, 501, 502};
449         int i;
450         BOOL ret = True;
451         uint32_t resume_handle;
452
453         ZERO_STRUCT(c0);
454
455         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
456         r.in.ctr.ctr0 = &c0;
457         r.in.max_buffer = (uint32_t)-1;
458         r.in.resume_handle = &resume_handle;
459         r.out.resume_handle = &resume_handle;
460
461         for (i=0;i<ARRAY_SIZE(levels);i++) {
462                 int j;
463
464                 ZERO_STRUCT(r.out);
465                 resume_handle = 0;
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));
471                         ret = False;
472                         continue;
473                 }
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));
476                         continue;
477                 }
478
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++) {
482                                 const char *name;
483                                 name = r.out.ctr.ctr1->array[j].name;
484                                 if (!test_NetShareGetInfo(p, mem_ctx, name)) {
485                                         ret = False;
486                                 }
487                         }
488                 }
489         }
490
491         return ret;
492 }
493
494 static BOOL test_NetShareEnum(struct dcerpc_pipe *p, 
495                            TALLOC_CTX *mem_ctx)
496 {
497         NTSTATUS status;
498         struct srvsvc_NetShareEnum r;
499         struct srvsvc_NetShareCtr0 c0;
500         uint32_t levels[] = {0, 1, 2, 502};
501         int i;
502         BOOL ret = True;
503
504         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
505         r.in.ctr.ctr0 = &c0;
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;
510
511         for (i=0;i<ARRAY_SIZE(levels);i++) {
512                 ZERO_STRUCT(r.out);
513                 r.in.level = levels[i];
514                 printf("testing NetShareEnum level %u\n", r.in.level);
515                 status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r);
516                 if (!NT_STATUS_IS_OK(status)) {
517                         printf("NetShareEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
518                         ret = False;
519                         continue;
520                 }
521                 if (!W_ERROR_IS_OK(r.out.result)) {
522                         printf("NetShareEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
523                         continue;
524                 }
525         }
526
527         return True;
528 }
529
530 /**************************/
531 /* srvsvc_NetSrv          */
532 /**************************/
533 static BOOL test_NetSrvGetInfo(struct dcerpc_pipe *p, 
534                                  TALLOC_CTX *mem_ctx)
535 {
536         NTSTATUS status;
537         struct srvsvc_NetSrvGetInfo r;
538         struct srvsvc_NetSrvInfo503 i503;
539         uint32_t levels[] = {100, 101, 102, 502, 503};
540         int i;
541         BOOL ret = True;
542         uint32_t resume_handle;
543
544         ZERO_STRUCT(i503);
545
546         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
547
548         for (i=0;i<ARRAY_SIZE(levels);i++) {
549                 ZERO_STRUCT(r.out);
550                 resume_handle = 0;
551                 r.in.level = levels[i];
552                 printf("testing NetSrvGetInfo level %u\n", r.in.level);
553                 status = dcerpc_srvsvc_NetSrvGetInfo(p, mem_ctx, &r);
554                 if (!NT_STATUS_IS_OK(status)) {
555                         printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, nt_errstr(status));
556                         ret = False;
557                         continue;
558                 }
559                 if (!W_ERROR_IS_OK(r.out.result)) {
560                         printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
561                         continue;
562                 }
563         }
564
565         return ret;
566 }
567
568 /**************************/
569 /* srvsvc_NetDisk         */
570 /**************************/
571 static BOOL test_NetDiskEnum(struct dcerpc_pipe *p, 
572                            TALLOC_CTX *mem_ctx)
573 {
574         NTSTATUS status;
575         struct srvsvc_NetDiskEnum r;
576         uint32_t levels[] = {0};
577         int i;
578         BOOL ret = True;
579         uint32_t resume_handle=0;
580
581         r.in.server_unc = NULL;
582         r.in.unknown = 0;
583         r.in.resume_handle = &resume_handle;
584         r.in.ctr.ctr0 = NULL;
585
586         for (i=0;i<ARRAY_SIZE(levels);i++) {
587                 ZERO_STRUCT(r.out);
588                 r.in.level = levels[i];
589                 printf("testing NetDiskEnum level %u\n", r.in.level);
590                 status = dcerpc_srvsvc_NetDiskEnum(p, mem_ctx, &r);
591                 if (!NT_STATUS_IS_OK(status)) {
592                         NDR_PRINT_OUT_DEBUG(srvsvc_NetDiskEnum, &r);
593                         printf("NetDiskEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
594                         ret = False;
595                         continue;
596                 }
597                 if (!W_ERROR_IS_OK(r.out.result)) {
598                         printf("NetDiskEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
599                         continue;
600                 }
601         }
602
603         return ret;
604 }
605
606 /**************************/
607 /* srvsvc_NetTransport    */
608 /**************************/
609 static BOOL test_NetTransportEnum(struct dcerpc_pipe *p, 
610                            TALLOC_CTX *mem_ctx)
611 {
612         NTSTATUS status;
613         struct srvsvc_NetTransportEnum r;
614         struct srvsvc_NetTransportCtr0 c0;
615         uint32_t levels[] = {0, 1};
616         int i;
617         BOOL ret = True;
618
619         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
620         r.in.ctr.ctr0 = &c0;
621         r.in.ctr.ctr0->count = 0;
622         r.in.ctr.ctr0->array = NULL;
623         r.in.max_buffer = (uint32_t)-1;
624         r.in.resume_handle = NULL;
625
626         for (i=0;i<ARRAY_SIZE(levels);i++) {
627                 ZERO_STRUCT(r.out);
628                 r.in.level = levels[i];
629                 printf("testing NetTransportEnum level %u\n", r.in.level);
630                 status = dcerpc_srvsvc_NetTransportEnum(p, mem_ctx, &r);
631                 if (!NT_STATUS_IS_OK(status)) {
632                         printf("NetTransportEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
633                         ret = False;
634                         continue;
635                 }
636                 if (!W_ERROR_IS_OK(r.out.result)) {
637                         printf("NetTransportEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
638                         continue;
639                 }
640         }
641
642         return ret;
643 }
644
645 /**************************/
646 /* srvsvc_NetRemoteTOD    */
647 /**************************/
648 static BOOL test_NetRemoteTOD(struct dcerpc_pipe *p, 
649                            TALLOC_CTX *mem_ctx)
650 {
651         NTSTATUS status;
652         struct srvsvc_NetRemoteTOD r;
653         BOOL ret = True;
654
655         r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
656
657         ZERO_STRUCT(r.out);
658         printf("testing NetRemoteTOD\n");
659         status = dcerpc_srvsvc_NetRemoteTOD(p, mem_ctx, &r);
660         if (!NT_STATUS_IS_OK(status)) {
661                 printf("NetRemoteTOD failed - %s\n", nt_errstr(status));
662                 ret = False;
663         }
664         if (!W_ERROR_IS_OK(r.out.result)) {
665                 printf("NetRemoteTOD failed - %s\n", win_errstr(r.out.result));
666         }
667
668         return ret;
669 }
670
671 BOOL torture_rpc_srvsvc(int dummy)
672 {
673         NTSTATUS status;
674         struct dcerpc_pipe *p;
675         TALLOC_CTX *mem_ctx;
676         BOOL ret = True;
677
678         mem_ctx = talloc_init("torture_rpc_srvsvc");
679
680         status = torture_rpc_connection(&p,
681                                         DCERPC_SRVSVC_NAME,
682                                         DCERPC_SRVSVC_UUID,
683                                         DCERPC_SRVSVC_VERSION);
684         if (!NT_STATUS_IS_OK(status)) {
685                 return False;
686         }
687
688         if (!test_NetCharDevEnum(p, mem_ctx)) {
689                 ret = False;
690         }
691
692         if (!test_NetCharDevQEnum(p, mem_ctx)) {
693                 ret = False;
694         }
695
696         if (!test_NetConnEnum(p, mem_ctx)) {
697                 ret = False;
698         }
699
700         if (!test_NetFileEnum(p, mem_ctx)) {
701                 ret = False;
702         }
703
704         if (!test_NetSessEnum(p, mem_ctx)) {
705                 ret = False;
706         }
707
708         if (!test_NetShareEnumAll(p, mem_ctx)) {
709                 ret = False;
710         }
711
712         if (!test_NetSrvGetInfo(p, mem_ctx)) {
713                 ret = False;
714         }
715
716         if (!test_NetDiskEnum(p, mem_ctx)) {
717                 ret = False;
718         }
719
720         if (!test_NetTransportEnum(p, mem_ctx)) {
721                 ret = False;
722         }
723
724         if (!test_NetRemoteTOD(p, mem_ctx)) {
725                 ret = False;
726         }
727
728         if (!test_NetShareEnum(p, mem_ctx)) {
729                 ret = False;
730         }
731
732         talloc_destroy(mem_ctx);
733
734         torture_rpc_close(p);
735
736         return ret;
737 }