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