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