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