Initial import
[samba] / source / rpc_parse / parse_svcctl.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Gerald (Jerry) Carter             2005.
5  *  
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #include "includes.h"
22
23 #undef DBGC_CLASS
24 #define DBGC_CLASS DBGC_RPC_PARSE
25
26 /*******************************************************************
27 ********************************************************************/
28
29 static BOOL svcctl_io_service_status( const char *desc, SERVICE_STATUS *status, prs_struct *ps, int depth )
30 {
31
32         prs_debug(ps, depth, desc, "svcctl_io_service_status");
33         depth++;
34
35         if(!prs_uint32("type", ps, depth, &status->type))
36                 return False;
37
38         if(!prs_uint32("state", ps, depth, &status->state))
39                 return False;
40
41         if(!prs_uint32("controls_accepted", ps, depth, &status->controls_accepted))
42                 return False;
43
44         if(!prs_werror("win32_exit_code", ps, depth, &status->win32_exit_code))
45                 return False;
46
47         if(!prs_uint32("service_exit_code", ps, depth, &status->service_exit_code))
48                 return False;
49
50         if(!prs_uint32("check_point", ps, depth, &status->check_point))
51                 return False;
52
53         if(!prs_uint32("wait_hint", ps, depth, &status->wait_hint))
54                 return False;
55
56         return True;
57 }
58
59 /*******************************************************************
60 ********************************************************************/
61
62 static BOOL svcctl_io_service_config( const char *desc, SERVICE_CONFIG *config, prs_struct *ps, int depth )
63 {
64
65         prs_debug(ps, depth, desc, "svcctl_io_service_config");
66         depth++;
67
68         if(!prs_uint32("service_type", ps, depth, &config->service_type))
69                 return False;
70         if(!prs_uint32("start_type", ps, depth, &config->start_type))
71                 return False;
72         if(!prs_uint32("error_control", ps, depth, &config->error_control))
73                 return False;
74
75         if (!prs_io_unistr2_p("", ps, depth, &config->executablepath))
76                 return False;
77         if (!prs_io_unistr2_p("", ps, depth, &config->loadordergroup))
78                 return False;
79
80         if(!prs_uint32("tag_id", ps, depth, &config->tag_id))
81                 return False;
82
83         if (!prs_io_unistr2_p("", ps, depth, &config->dependencies))
84                 return False;
85         if (!prs_io_unistr2_p("", ps, depth, &config->startname))
86                 return False;
87         if (!prs_io_unistr2_p("", ps, depth, &config->displayname))
88                 return False;
89
90         if (!prs_io_unistr2("", ps, depth, config->executablepath))
91                 return False;
92         if (!prs_io_unistr2("", ps, depth, config->loadordergroup))
93                 return False;
94         if (!prs_io_unistr2("", ps, depth, config->dependencies))
95                 return False;
96         if (!prs_io_unistr2("", ps, depth, config->startname))
97                 return False;
98         if (!prs_io_unistr2("", ps, depth, config->displayname))
99                 return False;
100
101         return True;
102 }
103
104 /*******************************************************************
105 ********************************************************************/
106
107 BOOL svcctl_io_enum_services_status( const char *desc, ENUM_SERVICES_STATUS *enum_status, RPC_BUFFER *buffer, int depth )
108 {
109         prs_struct *ps=&buffer->prs;
110         
111         prs_debug(ps, depth, desc, "svcctl_io_enum_services_status");
112         depth++;
113         
114         if ( !smb_io_relstr("servicename", buffer, depth, &enum_status->servicename) )
115                 return False;
116         if ( !smb_io_relstr("displayname", buffer, depth, &enum_status->displayname) )
117                 return False;
118
119         if ( !svcctl_io_service_status("svc_status", &enum_status->status, ps, depth) )
120                 return False;
121         
122         return True;
123 }
124
125 /*******************************************************************
126 ********************************************************************/
127
128 BOOL svcctl_io_service_status_process( const char *desc, SERVICE_STATUS_PROCESS *status, RPC_BUFFER *buffer, int depth )
129 {
130         prs_struct *ps=&buffer->prs;
131
132         prs_debug(ps, depth, desc, "svcctl_io_service_status_process");
133         depth++;
134
135         if ( !svcctl_io_service_status("status", &status->status, ps, depth) )
136                 return False;
137         if(!prs_align(ps))
138                 return False;
139
140         if(!prs_uint32("process_id", ps, depth, &status->process_id))
141                 return False;
142         if(!prs_uint32("service_flags", ps, depth, &status->service_flags))
143                 return False;
144
145         return True;
146 }
147
148 /*******************************************************************
149 ********************************************************************/
150
151 uint32 svcctl_sizeof_enum_services_status( ENUM_SERVICES_STATUS *status )
152 {
153         uint32 size = 0;
154         
155         size += size_of_relative_string( &status->servicename );
156         size += size_of_relative_string( &status->displayname );
157         size += sizeof(SERVICE_STATUS);
158
159         return size;
160 }
161
162 /********************************************************************
163 ********************************************************************/
164
165 static uint32 sizeof_unistr2( UNISTR2 *string )
166 {
167         uint32 size = 0;
168
169         if ( !string ) 
170                 return 0;       
171
172         size  = sizeof(uint32) * 3;             /* length fields */
173         size += 2 * string->uni_max_len;        /* string data */
174         size += size % 4;                       /* alignment */
175
176         return size;
177 }
178
179 /********************************************************************
180 ********************************************************************/
181
182 uint32 svcctl_sizeof_service_config( SERVICE_CONFIG *config )
183 {
184         uint32 size = 0;
185
186         size = sizeof(uint32) * 4;      /* static uint32 fields */
187
188         /* now add the UNISTR2 + pointer sizes */
189
190         size += sizeof(uint32) * sizeof_unistr2(config->executablepath);
191         size += sizeof(uint32) * sizeof_unistr2(config->loadordergroup);
192         size += sizeof(uint32) * sizeof_unistr2(config->dependencies);
193         size += sizeof(uint32) * sizeof_unistr2(config->startname);
194         size += sizeof(uint32) * sizeof_unistr2(config->displayname);
195         
196         return size;
197 }
198
199
200
201 /*******************************************************************
202 ********************************************************************/
203
204 BOOL svcctl_io_q_close_service(const char *desc, SVCCTL_Q_CLOSE_SERVICE *q_u, prs_struct *ps, int depth)
205 {
206         
207         if (q_u == NULL)
208                 return False;
209
210         prs_debug(ps, depth, desc, "svcctl_io_q_close_service");
211         depth++;
212
213         if(!prs_align(ps))
214                 return False;
215
216         if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
217                 return False;
218
219         return True;
220 }
221
222
223 /*******************************************************************
224 ********************************************************************/
225
226 BOOL svcctl_io_r_close_service(const char *desc, SVCCTL_R_CLOSE_SERVICE *r_u, prs_struct *ps, int depth)
227 {
228         if (r_u == NULL)
229                 return False;
230
231         prs_debug(ps, depth, desc, "svcctl_io_r_close_service");
232         depth++;
233
234         if(!prs_align(ps))
235             return False;
236
237         if(!smb_io_pol_hnd("pol_handle", &r_u->handle, ps, depth))
238            return False; 
239
240         if(!prs_werror("status", ps, depth, &r_u->status))
241                 return False;
242
243         return True;
244 }
245
246 /*******************************************************************
247 ********************************************************************/
248
249 BOOL svcctl_io_q_open_scmanager(const char *desc, SVCCTL_Q_OPEN_SCMANAGER *q_u, prs_struct *ps, int depth)
250 {
251         if (q_u == NULL)
252                 return False;
253
254         prs_debug(ps, depth, desc, "svcctl_io_q_open_scmanager");
255         depth++;
256
257         if(!prs_align(ps))
258                 return False;
259
260         if(!prs_pointer("servername", ps, depth, (void**)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
261                 return False;
262         if(!prs_align(ps))
263                 return False;
264
265         if(!prs_pointer("database", ps, depth, (void**)&q_u->database, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
266                 return False;
267         if(!prs_align(ps))
268                 return False;
269
270         if(!prs_uint32("access", ps, depth, &q_u->access))
271                 return False;
272
273         return True;
274 }
275
276 /*******************************************************************
277 ********************************************************************/
278
279 BOOL svcctl_io_r_open_scmanager(const char *desc, SVCCTL_R_OPEN_SCMANAGER *r_u, prs_struct *ps, int depth)
280 {
281         if (r_u == NULL)
282                 return False;
283
284         prs_debug(ps, depth, desc, "svcctl_io_r_open_scmanager");
285         depth++;
286
287         if(!prs_align(ps))
288                 return False;
289
290         if(!smb_io_pol_hnd("scm_pol", &r_u->handle, ps, depth))
291                 return False;
292
293         if(!prs_werror("status", ps, depth, &r_u->status))
294                 return False;
295
296         return True;
297 }
298
299 /*******************************************************************
300 ********************************************************************/
301
302 BOOL svcctl_io_q_get_display_name(const char *desc, SVCCTL_Q_GET_DISPLAY_NAME *q_u, prs_struct *ps, int depth)
303 {
304         if (q_u == NULL)
305                 return False;
306
307         prs_debug(ps, depth, desc, "svcctl_io_q_get_display_name");
308         depth++;
309
310         if(!prs_align(ps))
311                 return False;
312
313         if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
314                 return False;
315
316         if(!smb_io_unistr2("servicename", &q_u->servicename, 1, ps, depth))
317                 return False;
318
319         if(!prs_align(ps))
320                 return False;
321
322         if(!prs_uint32("display_name_len", ps, depth, &q_u->display_name_len))
323                 return False;
324         
325         return True;
326 }
327
328 /*******************************************************************
329 ********************************************************************/
330
331 BOOL init_svcctl_r_get_display_name( SVCCTL_R_GET_DISPLAY_NAME *r_u, const char *displayname )
332 {
333         r_u->display_name_len = strlen(displayname);
334         init_unistr2( &r_u->displayname, displayname, UNI_STR_TERMINATE );
335
336         return True;
337 }
338
339 /*******************************************************************
340 ********************************************************************/
341
342 BOOL svcctl_io_r_get_display_name(const char *desc, SVCCTL_R_GET_DISPLAY_NAME *r_u, prs_struct *ps, int depth)
343 {
344         if (r_u == NULL)
345                 return False;
346
347         prs_debug(ps, depth, desc, "svcctl_io_r_get_display_name");
348         depth++;
349
350         if(!prs_align(ps))
351                 return False;
352
353         
354         if(!smb_io_unistr2("displayname", &r_u->displayname, 1, ps, depth))
355                 return False;
356
357         if(!prs_align(ps))
358                 return False;
359
360         if(!prs_uint32("display_name_len", ps, depth, &r_u->display_name_len))
361                 return False;
362
363         if(!prs_werror("status", ps, depth, &r_u->status))
364                 return False;
365
366         return True;
367 }
368
369
370 /*******************************************************************
371 ********************************************************************/
372
373 BOOL svcctl_io_q_open_service(const char *desc, SVCCTL_Q_OPEN_SERVICE *q_u, prs_struct *ps, int depth)
374 {
375         if (q_u == NULL)
376                 return False;
377
378         prs_debug(ps, depth, desc, "svcctl_io_q_open_service");
379         depth++;
380
381         if(!prs_align(ps))
382                 return False;
383
384         if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
385                 return False;
386
387         if(!smb_io_unistr2("servicename", &q_u->servicename, 1, ps, depth))
388                 return False;
389
390         if(!prs_align(ps))
391                 return False;
392
393         if(!prs_uint32("access", ps, depth, &q_u->access))
394                 return False;
395         
396         return True;
397 }
398
399 /*******************************************************************
400 ********************************************************************/
401
402 BOOL svcctl_io_r_open_service(const char *desc, SVCCTL_R_OPEN_SERVICE *r_u, prs_struct *ps, int depth)
403 {
404         if (r_u == NULL)
405                 return False;
406
407         prs_debug(ps, depth, desc, "svcctl_io_r_open_service");
408         depth++;
409
410         if(!prs_align(ps))
411                 return False;
412
413         if(!smb_io_pol_hnd("service_pol", &r_u->handle, ps, depth))
414                 return False;
415
416         if(!prs_werror("status", ps, depth, &r_u->status))
417                 return False;
418
419         return True;
420 }
421
422 /*******************************************************************
423 ********************************************************************/
424
425 BOOL svcctl_io_q_query_status(const char *desc, SVCCTL_Q_QUERY_STATUS *q_u, prs_struct *ps, int depth)
426 {
427         if (q_u == NULL)
428                 return False;
429
430         prs_debug(ps, depth, desc, "svcctl_io_q_query_status");
431         depth++;
432
433         if(!prs_align(ps))
434                 return False;
435
436         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
437                 return False;
438         
439         return True;
440 }
441
442 /*******************************************************************
443 ********************************************************************/
444
445 BOOL svcctl_io_r_query_status(const char *desc, SVCCTL_R_QUERY_STATUS *r_u, prs_struct *ps, int depth)
446 {
447         if (r_u == NULL)
448                 return False;
449
450         prs_debug(ps, depth, desc, "svcctl_io_r_query_status");
451         depth++;
452
453         if(!prs_align(ps))
454                 return False;
455
456         if(!svcctl_io_service_status("service_status", &r_u->svc_status, ps, depth))
457                 return False;
458
459         if(!prs_werror("status", ps, depth, &r_u->status))
460                 return False;
461
462         return True;
463 }
464
465 /*******************************************************************
466 ********************************************************************/
467
468 BOOL svcctl_io_q_enum_services_status(const char *desc, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, prs_struct *ps, int depth)
469 {
470         if (q_u == NULL)
471                 return False;
472
473         prs_debug(ps, depth, desc, "svcctl_io_q_enum_services_status");
474         depth++;
475
476         if(!prs_align(ps))
477                 return False;
478
479         if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
480                 return False;
481
482         if(!prs_uint32("type", ps, depth, &q_u->type))
483                 return False;
484         if(!prs_uint32("state", ps, depth, &q_u->state))
485                 return False;
486         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
487                 return False;
488
489         if(!prs_pointer("resume", ps, depth, (void**)&q_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
490                 return False;
491         
492         return True;
493 }
494
495 /*******************************************************************
496 ********************************************************************/
497
498 BOOL svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_STATUS *r_u, prs_struct *ps, int depth)
499 {
500         if (r_u == NULL)
501                 return False;
502
503         prs_debug(ps, depth, desc, "svcctl_io_r_enum_services_status");
504         depth++;
505
506         if(!prs_align(ps))
507                 return False;
508
509         if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
510                 return False;
511
512         if(!prs_align(ps))
513                 return False;
514
515         if(!prs_uint32("needed", ps, depth, &r_u->needed))
516                 return False;
517         if(!prs_uint32("returned", ps, depth, &r_u->returned))
518                 return False;
519
520         if(!prs_pointer("resume", ps, depth, (void**)&r_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
521                 return False;
522
523         if(!prs_werror("status", ps, depth, &r_u->status))
524                 return False;
525
526         return True;
527 }
528
529 /*******************************************************************
530 ********************************************************************/
531
532 BOOL svcctl_io_q_start_service(const char *desc, SVCCTL_Q_START_SERVICE *q_u, prs_struct *ps, int depth)
533 {
534         if (q_u == NULL)
535                 return False;
536
537         prs_debug(ps, depth, desc, "svcctl_io_q_start_service");
538         depth++;
539
540         if(!prs_align(ps))
541                 return False;
542
543         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
544                 return False;
545
546         if(!prs_uint32("parmcount", ps, depth, &q_u->parmcount))
547                 return False;
548
549         if ( !prs_pointer("rights", ps, depth, (void**)&q_u->parameters, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
550                 return False;
551
552         return True;
553 }
554
555 /*******************************************************************
556 ********************************************************************/
557
558 BOOL svcctl_io_r_start_service(const char *desc, SVCCTL_R_START_SERVICE *r_u, prs_struct *ps, int depth)
559 {
560         if (r_u == NULL)
561                 return False;
562
563         prs_debug(ps, depth, desc, "svcctl_io_r_start_service");
564         depth++;
565
566         if(!prs_werror("status", ps, depth, &r_u->status))
567                 return False;
568
569         return True;
570 }
571
572
573 /*******************************************************************
574 ********************************************************************/
575
576 BOOL svcctl_io_q_enum_dependent_services(const char *desc, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, prs_struct *ps, int depth)
577 {
578         if (q_u == NULL)
579                 return False;
580
581         prs_debug(ps, depth, desc, "svcctl_io_q_enum_dependent_services");
582         depth++;
583
584         if(!prs_align(ps))
585                 return False;
586
587         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
588                 return False;
589
590         if(!prs_uint32("state", ps, depth, &q_u->state))
591                 return False;
592         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
593                 return False;
594
595         return True;
596 }
597
598 /*******************************************************************
599 ********************************************************************/
600
601 BOOL svcctl_io_r_enum_dependent_services(const char *desc, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u, prs_struct *ps, int depth)
602 {
603         if (r_u == NULL)
604                 return False;
605
606         prs_debug(ps, depth, desc, "svcctl_io_r_enum_dependent_services");
607         depth++;
608
609         if(!prs_align(ps))
610                 return False;
611
612         if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
613                 return False;
614
615         if(!prs_align(ps))
616                 return False;
617
618         if(!prs_uint32("needed", ps, depth, &r_u->needed))
619                 return False;
620         if(!prs_uint32("returned", ps, depth, &r_u->returned))
621                 return False;
622
623         if(!prs_werror("status", ps, depth, &r_u->status))
624                 return False;
625
626         return True;
627 }
628
629 /*******************************************************************
630 ********************************************************************/
631
632 BOOL svcctl_io_q_control_service(const char *desc, SVCCTL_Q_CONTROL_SERVICE *q_u, prs_struct *ps, int depth)
633 {
634         if (q_u == NULL)
635                 return False;
636
637         prs_debug(ps, depth, desc, "svcctl_io_q_control_service");
638         depth++;
639
640         if(!prs_align(ps))
641                 return False;
642
643         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
644                 return False;
645
646         if(!prs_uint32("control", ps, depth, &q_u->control))
647                 return False;
648
649         return True;
650 }
651
652 /*******************************************************************
653 ********************************************************************/
654
655 BOOL svcctl_io_r_control_service(const char *desc, SVCCTL_R_CONTROL_SERVICE *r_u, prs_struct *ps, int depth)
656 {
657         if (r_u == NULL)
658                 return False;
659
660         prs_debug(ps, depth, desc, "svcctl_io_r_control_service");
661         depth++;
662
663         if(!prs_align(ps))
664                 return False;
665
666         if(!svcctl_io_service_status("service_status", &r_u->svc_status, ps, depth))
667                 return False;
668
669         if(!prs_werror("status", ps, depth, &r_u->status))
670                 return False;
671
672         return True;
673 }
674
675
676 /*******************************************************************
677 ********************************************************************/
678
679 BOOL svcctl_io_q_query_service_config(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, prs_struct *ps, int depth)
680 {
681         if (q_u == NULL)
682                 return False;
683
684         prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config");
685         depth++;
686
687         if(!prs_align(ps))
688                 return False;
689
690         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
691                 return False;
692
693         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
694                 return False;
695
696         return True;
697 }
698
699 /*******************************************************************
700 ********************************************************************/
701
702 BOOL svcctl_io_r_query_service_config(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u, prs_struct *ps, int depth)
703 {
704         if (r_u == NULL)
705                 return False;
706
707         prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config");
708         depth++;
709
710
711         if(!prs_align(ps))
712                 return False;
713
714         if(!svcctl_io_service_config("config", &r_u->config, ps, depth))
715                 return False;
716
717         if(!prs_uint32("needed", ps, depth, &r_u->needed))
718                 return False;
719
720         if(!prs_werror("status", ps, depth, &r_u->status))
721                 return False;
722
723
724         return True;
725 }
726
727 /*******************************************************************
728 ********************************************************************/
729
730 BOOL svcctl_io_q_query_service_config2(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, prs_struct *ps, int depth)
731 {
732         if (q_u == NULL)
733                 return False;
734
735         prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config2");
736         depth++;
737
738         if(!prs_align(ps))
739                 return False;
740
741         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
742                 return False;
743
744         if(!prs_uint32("level", ps, depth, &q_u->level))
745                 return False;
746
747         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
748                 return False;
749
750         return True;
751 }
752
753
754 /*******************************************************************
755 ********************************************************************/
756
757 void init_service_description_buffer(SERVICE_DESCRIPTION *desc, const char *service_desc )
758 {
759         desc->unknown = 0x04;   /* always 0x0000 0004 (no idea what this is) */
760         init_unistr( &desc->description, service_desc );
761 }
762
763 /*******************************************************************
764 ********************************************************************/
765
766 BOOL svcctl_io_service_description( const char *desc, SERVICE_DESCRIPTION *description, RPC_BUFFER *buffer, int depth )
767 {
768         prs_struct *ps = &buffer->prs;
769
770         prs_debug(ps, depth, desc, "svcctl_io_service_description");
771         depth++;
772
773         if ( !prs_uint32("unknown", ps, depth, &description->unknown) )
774                 return False;
775         if ( !prs_unistr("description", ps, depth, &description->description) )
776                 return False;
777
778         return True;
779
780
781 /*******************************************************************
782 ********************************************************************/
783
784 uint32 svcctl_sizeof_service_description( SERVICE_DESCRIPTION *desc )
785 {
786         if ( !desc )
787                 return 0;
788
789         /* make sure to include the terminating NULL */
790         return ( sizeof(uint32) + (2*(str_len_uni(&desc->description)+1)) );
791 }
792
793 /*******************************************************************
794 ********************************************************************/
795
796 static BOOL svcctl_io_action( const char *desc, SC_ACTION *action, prs_struct *ps, int depth )
797 {
798
799         prs_debug(ps, depth, desc, "svcctl_io_action");
800         depth++;
801
802         if ( !prs_uint32("type", ps, depth, &action->type) )
803                 return False;
804         if ( !prs_uint32("delay", ps, depth, &action->delay) )
805                 return False;
806
807         return True;
808 }
809
810 /*******************************************************************
811 ********************************************************************/
812
813 BOOL svcctl_io_service_fa( const char *desc, SERVICE_FAILURE_ACTIONS *fa, RPC_BUFFER *buffer, int depth )
814 {
815         prs_struct *ps = &buffer->prs;
816         int i;
817
818         prs_debug(ps, depth, desc, "svcctl_io_service_description");
819         depth++;
820
821         if ( !prs_uint32("reset_period", ps, depth, &fa->reset_period) )
822                 return False;
823
824         if ( !prs_pointer( desc, ps, depth, (void**)&fa->rebootmsg, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
825                 return False;
826         if ( !prs_pointer( desc, ps, depth, (void**)&fa->command, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
827                 return False;
828
829         if ( !prs_uint32("num_actions", ps, depth, &fa->num_actions) )
830                 return False;
831
832         if ( UNMARSHALLING(ps) && fa->num_actions ) {
833                 if ( !(fa->actions = TALLOC_ARRAY( get_talloc_ctx(), SC_ACTION, fa->num_actions )) ) {
834                         DEBUG(0,("svcctl_io_service_fa: talloc() failure!\n"));
835                         return False;
836                 }
837         }
838
839         for ( i=0; i<fa->num_actions; i++ ) {
840                 if ( !svcctl_io_action( "actions", &fa->actions[i], ps, depth ) )
841                         return False;
842         }
843
844         return True;
845
846
847 /*******************************************************************
848 ********************************************************************/
849
850 uint32 svcctl_sizeof_service_fa( SERVICE_FAILURE_ACTIONS *fa)
851 {
852         uint32 size = 0;
853
854         if ( !fa )
855                 return 0;
856
857         size  = sizeof(uint32) * 2;
858         size += sizeof_unistr2( fa->rebootmsg );
859         size += sizeof_unistr2( fa->command );
860         size += sizeof(SC_ACTION) * fa->num_actions;
861
862         return size;
863 }
864
865 /*******************************************************************
866 ********************************************************************/
867
868 BOOL svcctl_io_r_query_service_config2(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u, prs_struct *ps, int depth)
869 {
870         if ( !r_u )
871                 return False;
872
873         prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config2");
874         depth++;
875
876         if ( !prs_align(ps) )
877                 return False;
878
879         if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
880                 return False;
881         if(!prs_align(ps))
882                 return False;
883
884         if (!prs_uint32("needed", ps, depth, &r_u->needed))
885                 return False;
886
887         if(!prs_werror("status", ps, depth, &r_u->status))
888                 return False;
889
890         return True;
891 }
892
893
894 /*******************************************************************
895 ********************************************************************/
896
897 BOOL svcctl_io_q_query_service_status_ex(const char *desc, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, prs_struct *ps, int depth)
898 {
899         if (q_u == NULL)
900                 return False;
901
902         prs_debug(ps, depth, desc, "svcctl_io_q_query_service_status_ex");
903         depth++;
904
905         if(!prs_align(ps))
906                 return False;
907
908         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
909                 return False;
910
911         if(!prs_uint32("level", ps, depth, &q_u->level))
912                 return False;
913
914         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
915                 return False;
916
917         return True;
918
919 }
920
921 /*******************************************************************
922 ********************************************************************/
923
924 BOOL svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u, prs_struct *ps, int depth)
925 {
926         if ( !r_u )
927                 return False;
928
929         prs_debug(ps, depth, desc, "svcctl_io_r_query_service_status_ex");
930         depth++;
931
932         if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
933                 return False;
934
935         if(!prs_align(ps))
936                 return False;
937
938         if(!prs_uint32("needed", ps, depth, &r_u->needed))
939                 return False;
940
941         if(!prs_werror("status", ps, depth, &r_u->status))
942                 return False;
943
944         return True;
945 }
946
947 /*******************************************************************
948 ********************************************************************/
949
950 BOOL svcctl_io_q_lock_service_db(const char *desc, SVCCTL_Q_LOCK_SERVICE_DB *q_u, prs_struct *ps, int depth)
951 {
952         if (q_u == NULL)
953                 return False;
954
955         prs_debug(ps, depth, desc, "svcctl_io_q_lock_service_db");
956         depth++;
957
958         if(!prs_align(ps))
959                 return False;
960
961         if(!smb_io_pol_hnd("scm_handle", &q_u->handle, ps, depth))
962                 return False;
963
964         return True;
965
966 }
967
968 /*******************************************************************
969 ********************************************************************/
970
971 BOOL svcctl_io_r_lock_service_db(const char *desc, SVCCTL_R_LOCK_SERVICE_DB *r_u, prs_struct *ps, int depth)
972 {
973         if ( !r_u )
974                 return False;
975
976         prs_debug(ps, depth, desc, "svcctl_io_r_lock_service_db");
977         depth++;
978
979         if(!prs_align(ps))
980                 return False;
981
982         if(!smb_io_pol_hnd("lock_handle", &r_u->h_lock, ps, depth))
983                 return False;
984
985         if(!prs_werror("status", ps, depth, &r_u->status))
986                 return False;
987
988         return True;
989 }
990
991 /*******************************************************************
992 ********************************************************************/
993
994 BOOL svcctl_io_q_unlock_service_db(const char *desc, SVCCTL_Q_UNLOCK_SERVICE_DB *q_u, prs_struct *ps, int depth)
995 {
996         if (q_u == NULL)
997                 return False;
998
999         prs_debug(ps, depth, desc, "svcctl_io_q_unlock_service_db");
1000         depth++;
1001
1002         if(!prs_align(ps))
1003                 return False;
1004
1005         if(!smb_io_pol_hnd("h_lock", &q_u->h_lock, ps, depth))
1006                 return False;
1007
1008         return True;
1009
1010 }
1011
1012 /*******************************************************************
1013 ********************************************************************/
1014
1015 BOOL svcctl_io_r_unlock_service_db(const char *desc, SVCCTL_R_UNLOCK_SERVICE_DB *r_u, prs_struct *ps, int depth)
1016 {
1017         if ( !r_u )
1018                 return False;
1019
1020         prs_debug(ps, depth, desc, "svcctl_io_r_unlock_service_db");
1021         depth++;
1022
1023         if(!prs_align(ps))
1024                 return False;
1025
1026         if(!prs_werror("status", ps, depth, &r_u->status))
1027                 return False;
1028
1029         return True;
1030 }
1031
1032 /*******************************************************************
1033 ********************************************************************/
1034
1035 BOOL svcctl_io_q_query_service_sec(const char *desc, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, prs_struct *ps, int depth)
1036 {
1037         if (q_u == NULL)
1038                 return False;
1039
1040         prs_debug(ps, depth, desc, "svcctl_io_q_query_service_sec");
1041         depth++;
1042
1043         if(!prs_align(ps))
1044                 return False;
1045
1046         if(!smb_io_pol_hnd("handle", &q_u->handle, ps, depth))
1047                 return False;
1048         if(!prs_uint32("security_flags", ps, depth, &q_u->security_flags))
1049                 return False;
1050         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1051                 return False;
1052
1053         return True;
1054
1055 }
1056
1057 /*******************************************************************
1058 ********************************************************************/
1059
1060 BOOL svcctl_io_r_query_service_sec(const char *desc, SVCCTL_R_QUERY_SERVICE_SEC *r_u, prs_struct *ps, int depth)
1061 {
1062         if ( !r_u )
1063                 return False;
1064
1065         prs_debug(ps, depth, desc, "svcctl_io_r_query_service_sec");
1066         depth++;
1067
1068         if(!prs_align(ps))
1069                 return False;
1070
1071         if (!prs_rpcbuffer("buffer", ps, depth, &r_u->buffer))
1072                 return False;
1073
1074         if(!prs_uint32("needed", ps, depth, &r_u->needed))
1075                 return False;
1076
1077         if(!prs_werror("status", ps, depth, &r_u->status))
1078                 return False;
1079
1080         return True;
1081 }
1082
1083 /*******************************************************************
1084 ********************************************************************/
1085
1086 BOOL svcctl_io_q_set_service_sec(const char *desc, SVCCTL_Q_SET_SERVICE_SEC *q_u, prs_struct *ps, int depth)
1087 {
1088         if (q_u == NULL)
1089                 return False;
1090
1091         prs_debug(ps, depth, desc, "svcctl_io_q_set_service_sec");
1092         depth++;
1093
1094         if(!prs_align(ps))
1095                 return False;
1096
1097         if(!smb_io_pol_hnd("handle", &q_u->handle, ps, depth))
1098                 return False;
1099         if(!prs_uint32("security_flags", ps, depth, &q_u->security_flags))
1100                 return False;
1101
1102         if (!prs_rpcbuffer("buffer", ps, depth, &q_u->buffer))
1103                 return False;
1104
1105         if(!prs_align(ps))
1106                 return False;
1107
1108         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1109                 return False;
1110
1111         return True;
1112
1113 }
1114
1115 /*******************************************************************
1116 ********************************************************************/
1117
1118 BOOL svcctl_io_r_set_service_sec(const char *desc, SVCCTL_R_SET_SERVICE_SEC *r_u, prs_struct *ps, int depth)
1119 {
1120         if ( !r_u )
1121                 return False;
1122
1123         prs_debug(ps, depth, desc, "svcctl_io_r_set_service_sec");
1124         depth++;
1125
1126         if(!prs_align(ps))
1127                 return False;
1128
1129         if(!prs_werror("status", ps, depth, &r_u->status))
1130                 return False;
1131
1132         return True;
1133 }
1134
1135
1136
1137