source: branches/samba-3.2.x/source/rpc_parse/parse_svcctl.c

Last change on this file was 133, checked in by Paul Smedley, 17 years ago

Update trunk to 3.2.0pre3

File size: 16.0 KB
Line 
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
28static 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
61static 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
106bool 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
127bool 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
150uint32 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
164static 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
181uint32 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
201bool svcctl_io_q_enum_services_status(const char *desc, SVCCTL_Q_ENUM_SERVICES_STATUS *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_enum_services_status");
207 depth++;
208
209 if(!prs_align(ps))
210 return False;
211
212 if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
213 return False;
214
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;
221
222 if(!prs_pointer("resume", ps, depth, (void*)&q_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
223 return False;
224
225 return True;
226}
227
228/*******************************************************************
229********************************************************************/
230
231bool svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_STATUS *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_enum_services_status");
237 depth++;
238
239 if(!prs_align(ps))
240 return False;
241
242 if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
243 return False;
244
245 if(!prs_align(ps))
246 return False;
247
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;
252
253 if(!prs_pointer("resume", ps, depth, (void*)&r_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
254 return False;
255
256 if(!prs_werror("status", ps, depth, &r_u->status))
257 return False;
258
259 return True;
260}
261
262/*******************************************************************
263********************************************************************/
264
265bool svcctl_io_q_enum_dependent_services(const char *desc, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, prs_struct *ps, int depth)
266{
267 if (q_u == NULL)
268 return False;
269
270 prs_debug(ps, depth, desc, "svcctl_io_q_enum_dependent_services");
271 depth++;
272
273 if(!prs_align(ps))
274 return False;
275
276 if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
277 return False;
278
279 if(!prs_uint32("state", ps, depth, &q_u->state))
280 return False;
281 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
282 return False;
283
284 return True;
285}
286
287/*******************************************************************
288********************************************************************/
289
290bool svcctl_io_r_enum_dependent_services(const char *desc, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u, prs_struct *ps, int depth)
291{
292 if (r_u == NULL)
293 return False;
294
295 prs_debug(ps, depth, desc, "svcctl_io_r_enum_dependent_services");
296 depth++;
297
298 if(!prs_align(ps))
299 return False;
300
301 if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
302 return False;
303
304 if(!prs_align(ps))
305 return False;
306
307 if(!prs_uint32("needed", ps, depth, &r_u->needed))
308 return False;
309 if(!prs_uint32("returned", ps, depth, &r_u->returned))
310 return False;
311
312 if(!prs_werror("status", ps, depth, &r_u->status))
313 return False;
314
315 return True;
316}
317
318/*******************************************************************
319********************************************************************/
320
321bool svcctl_io_q_query_service_config(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, prs_struct *ps, int depth)
322{
323 if (q_u == NULL)
324 return False;
325
326 prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config");
327 depth++;
328
329 if(!prs_align(ps))
330 return False;
331
332 if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
333 return False;
334
335 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
336 return False;
337
338 return True;
339}
340
341/*******************************************************************
342********************************************************************/
343
344bool svcctl_io_r_query_service_config(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u, prs_struct *ps, int depth)
345{
346 if (r_u == NULL)
347 return False;
348
349 prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config");
350 depth++;
351
352
353 if(!prs_align(ps))
354 return False;
355
356 if(!svcctl_io_service_config("config", &r_u->config, ps, depth))
357 return False;
358
359 if(!prs_uint32("needed", ps, depth, &r_u->needed))
360 return False;
361
362 if(!prs_werror("status", ps, depth, &r_u->status))
363 return False;
364
365
366 return True;
367}
368
369/*******************************************************************
370********************************************************************/
371
372bool svcctl_io_q_query_service_config2(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, prs_struct *ps, int depth)
373{
374 if (q_u == NULL)
375 return False;
376
377 prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config2");
378 depth++;
379
380 if(!prs_align(ps))
381 return False;
382
383 if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
384 return False;
385
386 if(!prs_uint32("level", ps, depth, &q_u->level))
387 return False;
388
389 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
390 return False;
391
392 return True;
393}
394
395
396/*******************************************************************
397********************************************************************/
398
399void init_service_description_buffer(SERVICE_DESCRIPTION *desc, const char *service_desc )
400{
401 desc->unknown = 0x04; /* always 0x0000 0004 (no idea what this is) */
402 init_unistr( &desc->description, service_desc );
403}
404
405/*******************************************************************
406********************************************************************/
407
408bool svcctl_io_service_description( const char *desc, SERVICE_DESCRIPTION *description, RPC_BUFFER *buffer, int depth )
409{
410 prs_struct *ps = &buffer->prs;
411
412 prs_debug(ps, depth, desc, "svcctl_io_service_description");
413 depth++;
414
415 if ( !prs_uint32("unknown", ps, depth, &description->unknown) )
416 return False;
417 if ( !prs_unistr("description", ps, depth, &description->description) )
418 return False;
419
420 return True;
421}
422
423/*******************************************************************
424********************************************************************/
425
426uint32 svcctl_sizeof_service_description( SERVICE_DESCRIPTION *desc )
427{
428 if ( !desc )
429 return 0;
430
431 /* make sure to include the terminating NULL */
432 return ( sizeof(uint32) + (2*(str_len_uni(&desc->description)+1)) );
433}
434
435/*******************************************************************
436********************************************************************/
437
438static bool svcctl_io_action( const char *desc, SC_ACTION *action, prs_struct *ps, int depth )
439{
440
441 prs_debug(ps, depth, desc, "svcctl_io_action");
442 depth++;
443
444 if ( !prs_uint32("type", ps, depth, &action->type) )
445 return False;
446 if ( !prs_uint32("delay", ps, depth, &action->delay) )
447 return False;
448
449 return True;
450}
451
452/*******************************************************************
453********************************************************************/
454
455bool svcctl_io_service_fa( const char *desc, SERVICE_FAILURE_ACTIONS *fa, RPC_BUFFER *buffer, int depth )
456{
457 prs_struct *ps = &buffer->prs;
458 int i;
459
460 prs_debug(ps, depth, desc, "svcctl_io_service_description");
461 depth++;
462
463 if ( !prs_uint32("reset_period", ps, depth, &fa->reset_period) )
464 return False;
465
466 if ( !prs_pointer( desc, ps, depth, (void*)&fa->rebootmsg, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
467 return False;
468 if ( !prs_pointer( desc, ps, depth, (void*)&fa->command, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
469 return False;
470
471 if ( !prs_uint32("num_actions", ps, depth, &fa->num_actions) )
472 return False;
473
474 if ( UNMARSHALLING(ps)) {
475 if (fa->num_actions) {
476 if ( !(fa->actions = TALLOC_ARRAY( talloc_tos(), SC_ACTION, fa->num_actions )) ) {
477 DEBUG(0,("svcctl_io_service_fa: talloc() failure!\n"));
478 return False;
479 }
480 } else {
481 fa->actions = NULL;
482 }
483 }
484
485 for ( i=0; i<fa->num_actions; i++ ) {
486 if ( !svcctl_io_action( "actions", &fa->actions[i], ps, depth ) )
487 return False;
488 }
489
490 return True;
491}
492
493/*******************************************************************
494********************************************************************/
495
496uint32 svcctl_sizeof_service_fa( SERVICE_FAILURE_ACTIONS *fa)
497{
498 uint32 size = 0;
499
500 if ( !fa )
501 return 0;
502
503 size = sizeof(uint32) * 2;
504 size += sizeof_unistr2( fa->rebootmsg );
505 size += sizeof_unistr2( fa->command );
506 size += sizeof(SC_ACTION) * fa->num_actions;
507
508 return size;
509}
510
511/*******************************************************************
512********************************************************************/
513
514bool svcctl_io_r_query_service_config2(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u, prs_struct *ps, int depth)
515{
516 if ( !r_u )
517 return False;
518
519 prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config2");
520 depth++;
521
522 if ( !prs_align(ps) )
523 return False;
524
525 if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
526 return False;
527 if(!prs_align(ps))
528 return False;
529
530 if (!prs_uint32("needed", ps, depth, &r_u->needed))
531 return False;
532
533 if(!prs_werror("status", ps, depth, &r_u->status))
534 return False;
535
536 return True;
537}
538
539
540/*******************************************************************
541********************************************************************/
542
543bool svcctl_io_q_query_service_status_ex(const char *desc, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, prs_struct *ps, int depth)
544{
545 if (q_u == NULL)
546 return False;
547
548 prs_debug(ps, depth, desc, "svcctl_io_q_query_service_status_ex");
549 depth++;
550
551 if(!prs_align(ps))
552 return False;
553
554 if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth))
555 return False;
556
557 if(!prs_uint32("level", ps, depth, &q_u->level))
558 return False;
559
560 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
561 return False;
562
563 return True;
564
565}
566
567/*******************************************************************
568********************************************************************/
569
570bool svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u, prs_struct *ps, int depth)
571{
572 if ( !r_u )
573 return False;
574
575 prs_debug(ps, depth, desc, "svcctl_io_r_query_service_status_ex");
576 depth++;
577
578 if (!prs_rpcbuffer("", ps, depth, &r_u->buffer))
579 return False;
580
581 if(!prs_align(ps))
582 return False;
583
584 if(!prs_uint32("needed", ps, depth, &r_u->needed))
585 return False;
586
587 if(!prs_werror("status", ps, depth, &r_u->status))
588 return False;
589
590 return True;
591}
Note: See TracBrowser for help on using the repository browser.