99f231adae1882269a2d86b351995a37cd94947d
[gd/samba/.git] / 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 3 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 BOOL svcctl_io_q_open_scmanager(const char *desc, SVCCTL_Q_OPEN_SCMANAGER *q_u, prs_struct *ps, int depth)
203 {
204         if (q_u == NULL)
205                 return False;
206
207         prs_debug(ps, depth, desc, "svcctl_io_q_open_scmanager");
208         depth++;
209
210         if(!prs_align(ps))
211                 return False;
212
213         if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
214                 return False;
215         if(!prs_align(ps))
216                 return False;
217
218         if(!prs_pointer("database", ps, depth, (void*)&q_u->database, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
219                 return False;
220         if(!prs_align(ps))
221                 return False;
222
223         if(!prs_uint32("access", ps, depth, &q_u->access))
224                 return False;
225
226         return True;
227 }
228
229 /*******************************************************************
230 ********************************************************************/
231
232 BOOL svcctl_io_r_open_scmanager(const char *desc, SVCCTL_R_OPEN_SCMANAGER *r_u, prs_struct *ps, int depth)
233 {
234         if (r_u == NULL)
235                 return False;
236
237         prs_debug(ps, depth, desc, "svcctl_io_r_open_scmanager");
238         depth++;
239
240         if(!prs_align(ps))
241                 return False;
242
243         if(!smb_io_pol_hnd("scm_pol", &r_u->handle, ps, depth))
244                 return False;
245
246         if(!prs_werror("status", ps, depth, &r_u->status))
247                 return False;
248
249         return True;
250 }
251
252 /*******************************************************************
253 ********************************************************************/
254
255 BOOL svcctl_io_q_get_display_name(const char *desc, SVCCTL_Q_GET_DISPLAY_NAME *q_u, prs_struct *ps, int depth)
256 {
257         if (q_u == NULL)
258                 return False;
259
260         prs_debug(ps, depth, desc, "svcctl_io_q_get_display_name");
261         depth++;
262
263         if(!prs_align(ps))
264                 return False;
265
266         if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
267                 return False;
268
269         if(!smb_io_unistr2("servicename", &q_u->servicename, 1, ps, depth))
270                 return False;
271
272         if(!prs_align(ps))
273                 return False;
274
275         if(!prs_uint32("display_name_len", ps, depth, &q_u->display_name_len))
276                 return False;
277         
278         return True;
279 }
280
281 /*******************************************************************
282 ********************************************************************/
283
284 BOOL init_svcctl_r_get_display_name( SVCCTL_R_GET_DISPLAY_NAME *r_u, const char *displayname )
285 {
286         r_u->display_name_len = strlen(displayname);
287         init_unistr2( &r_u->displayname, displayname, UNI_STR_TERMINATE );
288
289         return True;
290 }
291
292 /*******************************************************************
293 ********************************************************************/
294
295 BOOL svcctl_io_r_get_display_name(const char *desc, SVCCTL_R_GET_DISPLAY_NAME *r_u, prs_struct *ps, int depth)
296 {
297         if (r_u == NULL)
298                 return False;
299
300         prs_debug(ps, depth, desc, "svcctl_io_r_get_display_name");
301         depth++;
302
303         if(!prs_align(ps))
304                 return False;
305
306         
307         if(!smb_io_unistr2("displayname", &r_u->displayname, 1, ps, depth))
308                 return False;
309
310         if(!prs_align(ps))
311                 return False;
312
313         if(!prs_uint32("display_name_len", ps, depth, &r_u->display_name_len))
314                 return False;
315
316         if(!prs_werror("status", ps, depth, &r_u->status))
317                 return False;
318
319         return True;
320 }
321
322
323 /*******************************************************************
324 ********************************************************************/
325
326 BOOL svcctl_io_q_open_service(const char *desc, SVCCTL_Q_OPEN_SERVICE *q_u, prs_struct *ps, int depth)
327 {
328         if (q_u == NULL)
329                 return False;
330
331         prs_debug(ps, depth, desc, "svcctl_io_q_open_service");
332         depth++;
333
334         if(!prs_align(ps))
335                 return False;
336
337         if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
338                 return False;
339
340         if(!smb_io_unistr2("servicename", &q_u->servicename, 1, ps, depth))
341                 return False;
342
343         if(!prs_align(ps))
344                 return False;
345
346         if(!prs_uint32("access", ps, depth, &q_u->access))
347                 return False;
348         
349         return True;
350 }
351
352 /*******************************************************************
353 ********************************************************************/
354
355 BOOL svcctl_io_r_open_service(const char *desc, SVCCTL_R_OPEN_SERVICE *r_u, prs_struct *ps, int depth)
356 {
357         if (r_u == NULL)
358                 return False;
359
360         prs_debug(ps, depth, desc, "svcctl_io_r_open_service");
361         depth++;
362
363         if(!prs_align(ps))
364                 return False;
365
366         if(!smb_io_pol_hnd("service_pol", &r_u->handle, ps, depth))
367                 return False;
368
369         if(!prs_werror("status", ps, depth, &r_u->status))
370                 return False;
371
372         return True;
373 }
374
375 /*******************************************************************
376 ********************************************************************/
377
378 BOOL svcctl_io_q_query_status(const char *desc, SVCCTL_Q_QUERY_STATUS *q_u, prs_struct *ps, int depth)
379 {
380         if (q_u == NULL)
381                 return False;
382
383         prs_debug(ps, depth, desc, "svcctl_io_q_query_status");
384         depth++;
385
386         if(!prs_align(ps))
387                 return False;
388
389         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
390                 return False;
391         
392         return True;
393 }
394
395 /*******************************************************************
396 ********************************************************************/
397
398 BOOL svcctl_io_r_query_status(const char *desc, SVCCTL_R_QUERY_STATUS *r_u, prs_struct *ps, int depth)
399 {
400         if (r_u == NULL)
401                 return False;
402
403         prs_debug(ps, depth, desc, "svcctl_io_r_query_status");
404         depth++;
405
406         if(!prs_align(ps))
407                 return False;
408
409         if(!svcctl_io_service_status("service_status", &r_u->svc_status, ps, depth))
410                 return False;
411
412         if(!prs_werror("status", ps, depth, &r_u->status))
413                 return False;
414
415         return True;
416 }
417
418 /*******************************************************************
419 ********************************************************************/
420
421 BOOL svcctl_io_q_enum_services_status(const char *desc, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, prs_struct *ps, int depth)
422 {
423         if (q_u == NULL)
424                 return False;
425
426         prs_debug(ps, depth, desc, "svcctl_io_q_enum_services_status");
427         depth++;
428
429         if(!prs_align(ps))
430                 return False;
431
432         if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
433                 return False;
434
435         if(!prs_uint32("type", ps, depth, &q_u->type))
436                 return False;
437         if(!prs_uint32("state", ps, depth, &q_u->state))
438                 return False;
439         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
440                 return False;
441
442         if(!prs_pointer("resume", ps, depth, (void*)&q_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
443                 return False;
444         
445         return True;
446 }
447
448 /*******************************************************************
449 ********************************************************************/
450
451 BOOL svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_STATUS *r_u, prs_struct *ps, int depth)
452 {
453         if (r_u == NULL)
454                 return False;
455
456         prs_debug(ps, depth, desc, "svcctl_io_r_enum_services_status");
457         depth++;
458
459         if(!prs_align(ps))
460                 return False;
461
462         if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
463                 return False;
464
465         if(!prs_align(ps))
466                 return False;
467
468         if(!prs_uint32("needed", ps, depth, &r_u->needed))
469                 return False;
470         if(!prs_uint32("returned", ps, depth, &r_u->returned))
471                 return False;
472
473         if(!prs_pointer("resume", ps, depth, (void*)&r_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
474                 return False;
475
476         if(!prs_werror("status", ps, depth, &r_u->status))
477                 return False;
478
479         return True;
480 }
481
482 /*******************************************************************
483 ********************************************************************/
484
485 BOOL svcctl_io_q_start_service(const char *desc, SVCCTL_Q_START_SERVICE *q_u, prs_struct *ps, int depth)
486 {
487         if (q_u == NULL)
488                 return False;
489
490         prs_debug(ps, depth, desc, "svcctl_io_q_start_service");
491         depth++;
492
493         if(!prs_align(ps))
494                 return False;
495
496         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
497                 return False;
498
499         if(!prs_uint32("parmcount", ps, depth, &q_u->parmcount))
500                 return False;
501
502         if ( !prs_pointer("rights", ps, depth, (void*)&q_u->parameters, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
503                 return False;
504
505         return True;
506 }
507
508 /*******************************************************************
509 ********************************************************************/
510
511 BOOL svcctl_io_r_start_service(const char *desc, SVCCTL_R_START_SERVICE *r_u, prs_struct *ps, int depth)
512 {
513         if (r_u == NULL)
514                 return False;
515
516         prs_debug(ps, depth, desc, "svcctl_io_r_start_service");
517         depth++;
518
519         if(!prs_werror("status", ps, depth, &r_u->status))
520                 return False;
521
522         return True;
523 }
524
525
526 /*******************************************************************
527 ********************************************************************/
528
529 BOOL svcctl_io_q_enum_dependent_services(const char *desc, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, prs_struct *ps, int depth)
530 {
531         if (q_u == NULL)
532                 return False;
533
534         prs_debug(ps, depth, desc, "svcctl_io_q_enum_dependent_services");
535         depth++;
536
537         if(!prs_align(ps))
538                 return False;
539
540         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
541                 return False;
542
543         if(!prs_uint32("state", ps, depth, &q_u->state))
544                 return False;
545         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
546                 return False;
547
548         return True;
549 }
550
551 /*******************************************************************
552 ********************************************************************/
553
554 BOOL svcctl_io_r_enum_dependent_services(const char *desc, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u, prs_struct *ps, int depth)
555 {
556         if (r_u == NULL)
557                 return False;
558
559         prs_debug(ps, depth, desc, "svcctl_io_r_enum_dependent_services");
560         depth++;
561
562         if(!prs_align(ps))
563                 return False;
564
565         if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
566                 return False;
567
568         if(!prs_align(ps))
569                 return False;
570
571         if(!prs_uint32("needed", ps, depth, &r_u->needed))
572                 return False;
573         if(!prs_uint32("returned", ps, depth, &r_u->returned))
574                 return False;
575
576         if(!prs_werror("status", ps, depth, &r_u->status))
577                 return False;
578
579         return True;
580 }
581
582 /*******************************************************************
583 ********************************************************************/
584
585 BOOL svcctl_io_q_control_service(const char *desc, SVCCTL_Q_CONTROL_SERVICE *q_u, prs_struct *ps, int depth)
586 {
587         if (q_u == NULL)
588                 return False;
589
590         prs_debug(ps, depth, desc, "svcctl_io_q_control_service");
591         depth++;
592
593         if(!prs_align(ps))
594                 return False;
595
596         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
597                 return False;
598
599         if(!prs_uint32("control", ps, depth, &q_u->control))
600                 return False;
601
602         return True;
603 }
604
605 /*******************************************************************
606 ********************************************************************/
607
608 BOOL svcctl_io_r_control_service(const char *desc, SVCCTL_R_CONTROL_SERVICE *r_u, prs_struct *ps, int depth)
609 {
610         if (r_u == NULL)
611                 return False;
612
613         prs_debug(ps, depth, desc, "svcctl_io_r_control_service");
614         depth++;
615
616         if(!prs_align(ps))
617                 return False;
618
619         if(!svcctl_io_service_status("service_status", &r_u->svc_status, ps, depth))
620                 return False;
621
622         if(!prs_werror("status", ps, depth, &r_u->status))
623                 return False;
624
625         return True;
626 }
627
628
629 /*******************************************************************
630 ********************************************************************/
631
632 BOOL svcctl_io_q_query_service_config(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG *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_query_service_config");
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("buffer_size", ps, depth, &q_u->buffer_size))
647                 return False;
648
649         return True;
650 }
651
652 /*******************************************************************
653 ********************************************************************/
654
655 BOOL svcctl_io_r_query_service_config(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG *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_query_service_config");
661         depth++;
662
663
664         if(!prs_align(ps))
665                 return False;
666
667         if(!svcctl_io_service_config("config", &r_u->config, ps, depth))
668                 return False;
669
670         if(!prs_uint32("needed", ps, depth, &r_u->needed))
671                 return False;
672
673         if(!prs_werror("status", ps, depth, &r_u->status))
674                 return False;
675
676
677         return True;
678 }
679
680 /*******************************************************************
681 ********************************************************************/
682
683 BOOL svcctl_io_q_query_service_config2(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, prs_struct *ps, int depth)
684 {
685         if (q_u == NULL)
686                 return False;
687
688         prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config2");
689         depth++;
690
691         if(!prs_align(ps))
692                 return False;
693
694         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
695                 return False;
696
697         if(!prs_uint32("level", ps, depth, &q_u->level))
698                 return False;
699
700         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
701                 return False;
702
703         return True;
704 }
705
706
707 /*******************************************************************
708 ********************************************************************/
709
710 void init_service_description_buffer(SERVICE_DESCRIPTION *desc, const char *service_desc )
711 {
712         desc->unknown = 0x04;   /* always 0x0000 0004 (no idea what this is) */
713         init_unistr( &desc->description, service_desc );
714 }
715
716 /*******************************************************************
717 ********************************************************************/
718
719 BOOL svcctl_io_service_description( const char *desc, SERVICE_DESCRIPTION *description, RPC_BUFFER *buffer, int depth )
720 {
721         prs_struct *ps = &buffer->prs;
722
723         prs_debug(ps, depth, desc, "svcctl_io_service_description");
724         depth++;
725
726         if ( !prs_uint32("unknown", ps, depth, &description->unknown) )
727                 return False;
728         if ( !prs_unistr("description", ps, depth, &description->description) )
729                 return False;
730
731         return True;
732
733
734 /*******************************************************************
735 ********************************************************************/
736
737 uint32 svcctl_sizeof_service_description( SERVICE_DESCRIPTION *desc )
738 {
739         if ( !desc )
740                 return 0;
741
742         /* make sure to include the terminating NULL */
743         return ( sizeof(uint32) + (2*(str_len_uni(&desc->description)+1)) );
744 }
745
746 /*******************************************************************
747 ********************************************************************/
748
749 static BOOL svcctl_io_action( const char *desc, SC_ACTION *action, prs_struct *ps, int depth )
750 {
751
752         prs_debug(ps, depth, desc, "svcctl_io_action");
753         depth++;
754
755         if ( !prs_uint32("type", ps, depth, &action->type) )
756                 return False;
757         if ( !prs_uint32("delay", ps, depth, &action->delay) )
758                 return False;
759
760         return True;
761 }
762
763 /*******************************************************************
764 ********************************************************************/
765
766 BOOL svcctl_io_service_fa( const char *desc, SERVICE_FAILURE_ACTIONS *fa, RPC_BUFFER *buffer, int depth )
767 {
768         prs_struct *ps = &buffer->prs;
769         int i;
770
771         prs_debug(ps, depth, desc, "svcctl_io_service_description");
772         depth++;
773
774         if ( !prs_uint32("reset_period", ps, depth, &fa->reset_period) )
775                 return False;
776
777         if ( !prs_pointer( desc, ps, depth, (void*)&fa->rebootmsg, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
778                 return False;
779         if ( !prs_pointer( desc, ps, depth, (void*)&fa->command, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
780                 return False;
781
782         if ( !prs_uint32("num_actions", ps, depth, &fa->num_actions) )
783                 return False;
784
785         if ( UNMARSHALLING(ps)) {
786                 if (fa->num_actions) {
787                         if ( !(fa->actions = TALLOC_ARRAY( get_talloc_ctx(), SC_ACTION, fa->num_actions )) ) {
788                                 DEBUG(0,("svcctl_io_service_fa: talloc() failure!\n"));
789                                 return False;
790                         }
791                 } else {
792                         fa->actions = NULL;
793                 }
794         }
795
796         for ( i=0; i<fa->num_actions; i++ ) {
797                 if ( !svcctl_io_action( "actions", &fa->actions[i], ps, depth ) )
798                         return False;
799         }
800
801         return True;
802
803
804 /*******************************************************************
805 ********************************************************************/
806
807 uint32 svcctl_sizeof_service_fa( SERVICE_FAILURE_ACTIONS *fa)
808 {
809         uint32 size = 0;
810
811         if ( !fa )
812                 return 0;
813
814         size  = sizeof(uint32) * 2;
815         size += sizeof_unistr2( fa->rebootmsg );
816         size += sizeof_unistr2( fa->command );
817         size += sizeof(SC_ACTION) * fa->num_actions;
818
819         return size;
820 }
821
822 /*******************************************************************
823 ********************************************************************/
824
825 BOOL svcctl_io_r_query_service_config2(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u, prs_struct *ps, int depth)
826 {
827         if ( !r_u )
828                 return False;
829
830         prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config2");
831         depth++;
832
833         if ( !prs_align(ps) )
834                 return False;
835
836         if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
837                 return False;
838         if(!prs_align(ps))
839                 return False;
840
841         if (!prs_uint32("needed", ps, depth, &r_u->needed))
842                 return False;
843
844         if(!prs_werror("status", ps, depth, &r_u->status))
845                 return False;
846
847         return True;
848 }
849
850
851 /*******************************************************************
852 ********************************************************************/
853
854 BOOL svcctl_io_q_query_service_status_ex(const char *desc, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, prs_struct *ps, int depth)
855 {
856         if (q_u == NULL)
857                 return False;
858
859         prs_debug(ps, depth, desc, "svcctl_io_q_query_service_status_ex");
860         depth++;
861
862         if(!prs_align(ps))
863                 return False;
864
865         if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
866                 return False;
867
868         if(!prs_uint32("level", ps, depth, &q_u->level))
869                 return False;
870
871         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
872                 return False;
873
874         return True;
875
876 }
877
878 /*******************************************************************
879 ********************************************************************/
880
881 BOOL svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u, prs_struct *ps, int depth)
882 {
883         if ( !r_u )
884                 return False;
885
886         prs_debug(ps, depth, desc, "svcctl_io_r_query_service_status_ex");
887         depth++;
888
889         if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
890                 return False;
891
892         if(!prs_align(ps))
893                 return False;
894
895         if(!prs_uint32("needed", ps, depth, &r_u->needed))
896                 return False;
897
898         if(!prs_werror("status", ps, depth, &r_u->status))
899                 return False;
900
901         return True;
902 }
903
904 /*******************************************************************
905 ********************************************************************/
906
907 BOOL svcctl_io_q_lock_service_db(const char *desc, SVCCTL_Q_LOCK_SERVICE_DB *q_u, prs_struct *ps, int depth)
908 {
909         if (q_u == NULL)
910                 return False;
911
912         prs_debug(ps, depth, desc, "svcctl_io_q_lock_service_db");
913         depth++;
914
915         if(!prs_align(ps))
916                 return False;
917
918         if(!smb_io_pol_hnd("scm_handle", &q_u->handle, ps, depth))
919                 return False;
920
921         return True;
922
923 }
924
925 /*******************************************************************
926 ********************************************************************/
927
928 BOOL svcctl_io_r_lock_service_db(const char *desc, SVCCTL_R_LOCK_SERVICE_DB *r_u, prs_struct *ps, int depth)
929 {
930         if ( !r_u )
931                 return False;
932
933         prs_debug(ps, depth, desc, "svcctl_io_r_lock_service_db");
934         depth++;
935
936         if(!prs_align(ps))
937                 return False;
938
939         if(!smb_io_pol_hnd("lock_handle", &r_u->h_lock, ps, depth))
940                 return False;
941
942         if(!prs_werror("status", ps, depth, &r_u->status))
943                 return False;
944
945         return True;
946 }
947
948 /*******************************************************************
949 ********************************************************************/
950
951 BOOL svcctl_io_q_unlock_service_db(const char *desc, SVCCTL_Q_UNLOCK_SERVICE_DB *q_u, prs_struct *ps, int depth)
952 {
953         if (q_u == NULL)
954                 return False;
955
956         prs_debug(ps, depth, desc, "svcctl_io_q_unlock_service_db");
957         depth++;
958
959         if(!prs_align(ps))
960                 return False;
961
962         if(!smb_io_pol_hnd("h_lock", &q_u->h_lock, ps, depth))
963                 return False;
964
965         return True;
966
967 }
968
969 /*******************************************************************
970 ********************************************************************/
971
972 BOOL svcctl_io_r_unlock_service_db(const char *desc, SVCCTL_R_UNLOCK_SERVICE_DB *r_u, prs_struct *ps, int depth)
973 {
974         if ( !r_u )
975                 return False;
976
977         prs_debug(ps, depth, desc, "svcctl_io_r_unlock_service_db");
978         depth++;
979
980         if(!prs_align(ps))
981                 return False;
982
983         if(!prs_werror("status", ps, depth, &r_u->status))
984                 return False;
985
986         return True;
987 }
988
989 /*******************************************************************
990 ********************************************************************/
991
992 BOOL svcctl_io_q_query_service_sec(const char *desc, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, prs_struct *ps, int depth)
993 {
994         if (q_u == NULL)
995                 return False;
996
997         prs_debug(ps, depth, desc, "svcctl_io_q_query_service_sec");
998         depth++;
999
1000         if(!prs_align(ps))
1001                 return False;
1002
1003         if(!smb_io_pol_hnd("handle", &q_u->handle, ps, depth))
1004                 return False;
1005         if(!prs_uint32("security_flags", ps, depth, &q_u->security_flags))
1006                 return False;
1007         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1008                 return False;
1009
1010         return True;
1011
1012 }
1013
1014 /*******************************************************************
1015 ********************************************************************/
1016
1017 BOOL svcctl_io_r_query_service_sec(const char *desc, SVCCTL_R_QUERY_SERVICE_SEC *r_u, prs_struct *ps, int depth)
1018 {
1019         if ( !r_u )
1020                 return False;
1021
1022         prs_debug(ps, depth, desc, "svcctl_io_r_query_service_sec");
1023         depth++;
1024
1025         if(!prs_align(ps))
1026                 return False;
1027
1028         if (!prs_rpcbuffer("buffer", ps, depth, &r_u->buffer))
1029                 return False;
1030
1031         if(!prs_uint32("needed", ps, depth, &r_u->needed))
1032                 return False;
1033
1034         if(!prs_werror("status", ps, depth, &r_u->status))
1035                 return False;
1036
1037         return True;
1038 }
1039
1040 /*******************************************************************
1041 ********************************************************************/
1042
1043 BOOL svcctl_io_q_set_service_sec(const char *desc, SVCCTL_Q_SET_SERVICE_SEC *q_u, prs_struct *ps, int depth)
1044 {
1045         if (q_u == NULL)
1046                 return False;
1047
1048         prs_debug(ps, depth, desc, "svcctl_io_q_set_service_sec");
1049         depth++;
1050
1051         if(!prs_align(ps))
1052                 return False;
1053
1054         if(!smb_io_pol_hnd("handle", &q_u->handle, ps, depth))
1055                 return False;
1056         if(!prs_uint32("security_flags", ps, depth, &q_u->security_flags))
1057                 return False;
1058
1059         if (!prs_rpcbuffer("buffer", ps, depth, &q_u->buffer))
1060                 return False;
1061
1062         if(!prs_align(ps))
1063                 return False;
1064
1065         if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1066                 return False;
1067
1068         return True;
1069
1070 }
1071
1072 /*******************************************************************
1073 ********************************************************************/
1074
1075 BOOL svcctl_io_r_set_service_sec(const char *desc, SVCCTL_R_SET_SERVICE_SEC *r_u, prs_struct *ps, int depth)
1076 {
1077         if ( !r_u )
1078                 return False;
1079
1080         prs_debug(ps, depth, desc, "svcctl_io_r_set_service_sec");
1081         depth++;
1082
1083         if(!prs_align(ps))
1084                 return False;
1085
1086         if(!prs_werror("status", ps, depth, &r_u->status))
1087                 return False;
1088
1089         return True;
1090 }
1091
1092
1093
1094