Remove a check on p->vuid in _netr_LogonSamLogon/off
[Samba/gebeck_regimport.git] / source / rpc_parse / parse_svcctl.c
blobc5d93864ba6f142a1c515b0dd2364f89a9af788e
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.
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.
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/>.
20 #include "includes.h"
22 #undef DBGC_CLASS
23 #define DBGC_CLASS DBGC_RPC_PARSE
25 /*******************************************************************
26 ********************************************************************/
28 static bool svcctl_io_service_status( const char *desc, SERVICE_STATUS *status, prs_struct *ps, int depth )
31 prs_debug(ps, depth, desc, "svcctl_io_service_status");
32 depth++;
34 if(!prs_uint32("type", ps, depth, &status->type))
35 return False;
37 if(!prs_uint32("state", ps, depth, &status->state))
38 return False;
40 if(!prs_uint32("controls_accepted", ps, depth, &status->controls_accepted))
41 return False;
43 if(!prs_werror("win32_exit_code", ps, depth, &status->win32_exit_code))
44 return False;
46 if(!prs_uint32("service_exit_code", ps, depth, &status->service_exit_code))
47 return False;
49 if(!prs_uint32("check_point", ps, depth, &status->check_point))
50 return False;
52 if(!prs_uint32("wait_hint", ps, depth, &status->wait_hint))
53 return False;
55 return True;
58 /*******************************************************************
59 ********************************************************************/
61 static bool svcctl_io_service_config( const char *desc, SERVICE_CONFIG *config, prs_struct *ps, int depth )
64 prs_debug(ps, depth, desc, "svcctl_io_service_config");
65 depth++;
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;
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;
79 if(!prs_uint32("tag_id", ps, depth, &config->tag_id))
80 return False;
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;
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;
100 return True;
103 /*******************************************************************
104 ********************************************************************/
106 bool svcctl_io_enum_services_status( const char *desc, ENUM_SERVICES_STATUS *enum_status, RPC_BUFFER *buffer, int depth )
108 prs_struct *ps=&buffer->prs;
110 prs_debug(ps, depth, desc, "svcctl_io_enum_services_status");
111 depth++;
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;
118 if ( !svcctl_io_service_status("svc_status", &enum_status->status, ps, depth) )
119 return False;
121 return True;
124 /*******************************************************************
125 ********************************************************************/
127 bool svcctl_io_service_status_process( const char *desc, SERVICE_STATUS_PROCESS *status, RPC_BUFFER *buffer, int depth )
129 prs_struct *ps=&buffer->prs;
131 prs_debug(ps, depth, desc, "svcctl_io_service_status_process");
132 depth++;
134 if ( !svcctl_io_service_status("status", &status->status, ps, depth) )
135 return False;
136 if(!prs_align(ps))
137 return False;
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;
144 return True;
147 /*******************************************************************
148 ********************************************************************/
150 uint32 svcctl_sizeof_enum_services_status( ENUM_SERVICES_STATUS *status )
152 uint32 size = 0;
154 size += size_of_relative_string( &status->servicename );
155 size += size_of_relative_string( &status->displayname );
156 size += sizeof(SERVICE_STATUS);
158 return size;
161 /********************************************************************
162 ********************************************************************/
164 static uint32 sizeof_unistr2( UNISTR2 *string )
166 uint32 size = 0;
168 if ( !string )
169 return 0;
171 size = sizeof(uint32) * 3; /* length fields */
172 size += 2 * string->uni_max_len; /* string data */
173 size += size % 4; /* alignment */
175 return size;
178 /********************************************************************
179 ********************************************************************/
181 uint32 svcctl_sizeof_service_config( SERVICE_CONFIG *config )
183 uint32 size = 0;
185 size = sizeof(uint32) * 4; /* static uint32 fields */
187 /* now add the UNISTR2 + pointer sizes */
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);
195 return size;
198 /*******************************************************************
199 ********************************************************************/
201 bool svcctl_io_q_enum_services_status(const char *desc, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, prs_struct *ps, int depth)
203 if (q_u == NULL)
204 return False;
206 prs_debug(ps, depth, desc, "svcctl_io_q_enum_services_status");
207 depth++;
209 if(!prs_align(ps))
210 return False;
212 if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
213 return False;
215 if(!prs_uint32("type", ps, depth, &q_u->type))
216 return False;
217 if(!prs_uint32("state", ps, depth, &q_u->state))
218 return False;
219 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
220 return False;
222 if(!prs_pointer("resume", ps, depth, (void*)&q_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
223 return False;
225 return True;
228 /*******************************************************************
229 ********************************************************************/
231 bool svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_STATUS *r_u, prs_struct *ps, int depth)
233 if (r_u == NULL)
234 return False;
236 prs_debug(ps, depth, desc, "svcctl_io_r_enum_services_status");
237 depth++;
239 if(!prs_align(ps))
240 return False;
242 if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
243 return False;
245 if(!prs_align(ps))
246 return False;
248 if(!prs_uint32("needed", ps, depth, &r_u->needed))
249 return False;
250 if(!prs_uint32("returned", ps, depth, &r_u->returned))
251 return False;
253 if(!prs_pointer("resume", ps, depth, (void*)&r_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
254 return False;
256 if(!prs_werror("status", ps, depth, &r_u->status))
257 return False;
259 return True;
262 /*******************************************************************
263 ********************************************************************/
265 bool svcctl_io_q_query_service_config(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, prs_struct *ps, int depth)
267 if (q_u == NULL)
268 return False;
270 prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config");
271 depth++;
273 if(!prs_align(ps))
274 return False;
276 if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
277 return False;
279 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
280 return False;
282 return True;
285 /*******************************************************************
286 ********************************************************************/
288 bool svcctl_io_r_query_service_config(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u, prs_struct *ps, int depth)
290 if (r_u == NULL)
291 return False;
293 prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config");
294 depth++;
297 if(!prs_align(ps))
298 return False;
300 if(!svcctl_io_service_config("config", &r_u->config, ps, depth))
301 return False;
303 if(!prs_uint32("needed", ps, depth, &r_u->needed))
304 return False;
306 if(!prs_werror("status", ps, depth, &r_u->status))
307 return False;
310 return True;
313 /*******************************************************************
314 ********************************************************************/
316 bool svcctl_io_q_query_service_config2(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, prs_struct *ps, int depth)
318 if (q_u == NULL)
319 return False;
321 prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config2");
322 depth++;
324 if(!prs_align(ps))
325 return False;
327 if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
328 return False;
330 if(!prs_uint32("level", ps, depth, &q_u->level))
331 return False;
333 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
334 return False;
336 return True;
340 /*******************************************************************
341 ********************************************************************/
343 void init_service_description_buffer(SERVICE_DESCRIPTION *desc, const char *service_desc )
345 desc->unknown = 0x04; /* always 0x0000 0004 (no idea what this is) */
346 init_unistr( &desc->description, service_desc );
349 /*******************************************************************
350 ********************************************************************/
352 bool svcctl_io_service_description( const char *desc, SERVICE_DESCRIPTION *description, RPC_BUFFER *buffer, int depth )
354 prs_struct *ps = &buffer->prs;
356 prs_debug(ps, depth, desc, "svcctl_io_service_description");
357 depth++;
359 if ( !prs_uint32("unknown", ps, depth, &description->unknown) )
360 return False;
361 if ( !prs_unistr("description", ps, depth, &description->description) )
362 return False;
364 return True;
367 /*******************************************************************
368 ********************************************************************/
370 uint32 svcctl_sizeof_service_description( SERVICE_DESCRIPTION *desc )
372 if ( !desc )
373 return 0;
375 /* make sure to include the terminating NULL */
376 return ( sizeof(uint32) + (2*(str_len_uni(&desc->description)+1)) );
379 /*******************************************************************
380 ********************************************************************/
382 static bool svcctl_io_action( const char *desc, SC_ACTION *action, prs_struct *ps, int depth )
385 prs_debug(ps, depth, desc, "svcctl_io_action");
386 depth++;
388 if ( !prs_uint32("type", ps, depth, &action->type) )
389 return False;
390 if ( !prs_uint32("delay", ps, depth, &action->delay) )
391 return False;
393 return True;
396 /*******************************************************************
397 ********************************************************************/
399 bool svcctl_io_service_fa( const char *desc, SERVICE_FAILURE_ACTIONS *fa, RPC_BUFFER *buffer, int depth )
401 prs_struct *ps = &buffer->prs;
402 int i;
404 prs_debug(ps, depth, desc, "svcctl_io_service_description");
405 depth++;
407 if ( !prs_uint32("reset_period", ps, depth, &fa->reset_period) )
408 return False;
410 if ( !prs_pointer( desc, ps, depth, (void*)&fa->rebootmsg, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
411 return False;
412 if ( !prs_pointer( desc, ps, depth, (void*)&fa->command, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
413 return False;
415 if ( !prs_uint32("num_actions", ps, depth, &fa->num_actions) )
416 return False;
418 if ( UNMARSHALLING(ps)) {
419 if (fa->num_actions) {
420 if ( !(fa->actions = TALLOC_ARRAY( talloc_tos(), SC_ACTION, fa->num_actions )) ) {
421 DEBUG(0,("svcctl_io_service_fa: talloc() failure!\n"));
422 return False;
424 } else {
425 fa->actions = NULL;
429 for ( i=0; i<fa->num_actions; i++ ) {
430 if ( !svcctl_io_action( "actions", &fa->actions[i], ps, depth ) )
431 return False;
434 return True;
437 /*******************************************************************
438 ********************************************************************/
440 uint32 svcctl_sizeof_service_fa( SERVICE_FAILURE_ACTIONS *fa)
442 uint32 size = 0;
444 if ( !fa )
445 return 0;
447 size = sizeof(uint32) * 2;
448 size += sizeof_unistr2( fa->rebootmsg );
449 size += sizeof_unistr2( fa->command );
450 size += sizeof(SC_ACTION) * fa->num_actions;
452 return size;
455 /*******************************************************************
456 ********************************************************************/
458 bool svcctl_io_r_query_service_config2(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u, prs_struct *ps, int depth)
460 if ( !r_u )
461 return False;
463 prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config2");
464 depth++;
466 if ( !prs_align(ps) )
467 return False;
469 if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
470 return False;
471 if(!prs_align(ps))
472 return False;
474 if (!prs_uint32("needed", ps, depth, &r_u->needed))
475 return False;
477 if(!prs_werror("status", ps, depth, &r_u->status))
478 return False;
480 return True;
484 /*******************************************************************
485 ********************************************************************/
487 bool svcctl_io_q_query_service_status_ex(const char *desc, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, prs_struct *ps, int depth)
489 if (q_u == NULL)
490 return False;
492 prs_debug(ps, depth, desc, "svcctl_io_q_query_service_status_ex");
493 depth++;
495 if(!prs_align(ps))
496 return False;
498 if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
499 return False;
501 if(!prs_uint32("level", ps, depth, &q_u->level))
502 return False;
504 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
505 return False;
507 return True;
511 /*******************************************************************
512 ********************************************************************/
514 bool svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u, prs_struct *ps, int depth)
516 if ( !r_u )
517 return False;
519 prs_debug(ps, depth, desc, "svcctl_io_r_query_service_status_ex");
520 depth++;
522 if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
523 return False;
525 if(!prs_align(ps))
526 return False;
528 if(!prs_uint32("needed", ps, depth, &r_u->needed))
529 return False;
531 if(!prs_werror("status", ps, depth, &r_u->status))
532 return False;
534 return True;