r10656: BIG merge from trunk. Features not copied over
[tprouty/samba.git] / source / include / rpc_svcctl.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Andrew Tridgell              1992-1997,
5    Copyright (C) Gerald (Jerry) Carter        2005
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef _RPC_SVCCTL_H /* _RPC_SVCCTL_H */
23 #define _RPC_SVCCTL_H 
24
25 /* svcctl pipe */
26
27 #define SVCCTL_CLOSE_SERVICE                    0x00
28 #define SVCCTL_CONTROL_SERVICE                  0x01
29 #define SVCCTL_LOCK_SERVICE_DB                  0x03
30 #define SVCCTL_QUERY_SERVICE_SEC                0x04    /* not impmenented */
31 #define SVCCTL_SET_SEVICE_SEC                   0x05    /* not implemented */
32 #define SVCCTL_QUERY_STATUS                     0x06
33 #define SVCCTL_UNLOCK_SERVICE_DB                0x08
34 #define SVCCTL_ENUM_DEPENDENT_SERVICES_W        0x0d
35 #define SVCCTL_ENUM_SERVICES_STATUS_W           0x0e
36 #define SVCCTL_OPEN_SCMANAGER_W                 0x0f
37 #define SVCCTL_OPEN_SERVICE_W                   0x10
38 #define SVCCTL_QUERY_SERVICE_CONFIG_W           0x11
39 #define SVCCTL_START_SERVICE_W                  0x13
40 #define SVCCTL_GET_DISPLAY_NAME                 0x14
41 #define SVCCTL_QUERY_SERVICE_CONFIG2_W          0x27
42 #define SVCCTL_QUERY_SERVICE_STATUSEX_W         0x28
43
44 /* ANSI versions not implemented currently 
45 #define SVCCTL_ENUM_SERVICES_STATUS_A           0x0e
46 #define SVCCTL_OPEN_SCMANAGER_A                 0x1b
47 */
48
49 /* SERVER_STATUS - type */
50
51 #define SVCCTL_TYPE_WIN32               0x00000030
52 #define SVCCTL_TYPE_DRIVER              0x0000000f
53
54 /* SERVER_STATUS - state */
55 #define SVCCTL_STATE_ACTIVE             0x00000001
56 #define SVCCTL_STATE_INACTIVE           0x00000002
57 #define SVCCTL_STATE_ALL                ( SVCCTL_STATE_ACTIVE | SVCCTL_STATE_INACTIVE )
58
59 /* SERVER_STATUS - CurrentState */
60
61 #define SVCCTL_STATE_UNKNOWN            0x00000000      /* only used internally to smbd */
62 #define SVCCTL_STOPPED                  0x00000001
63 #define SVCCTL_START_PENDING            0x00000002
64 #define SVCCTL_STOP_PENDING             0x00000003
65 #define SVCCTL_RUNNING                  0x00000004
66 #define SVCCTL_CONTINUE_PENDING         0x00000005
67 #define SVCCTL_PAUSE_PENDING            0x00000006
68 #define SVCCTL_PAUSED                   0x00000007
69
70 /* SERVER_STATUS - ControlAccepted */
71
72 #define SVCCTL_ACCEPT_STOP                      0x00000001
73 #define SVCCTL_ACCEPT_PAUSE_CONTINUE            0x00000002
74 #define SVCCTL_ACCEPT_SHUTDOWN                  0x00000004
75 #define SVCCTL_ACCEPT_PARAMCHANGE               0x00000008
76 #define SVCCTL_ACCEPT_NETBINDCHANGE             0x00000010
77 #define SVCCTL_ACCEPT_HARDWAREPROFILECHANGE     0x00000020
78 #define SVCCTL_ACCEPT_POWEREVENT                0x00000040
79
80 /* SERVER_STATUS - ControlAccepted */
81 #define SVCCTL_SVC_ERROR_IGNORE                 0x00000000
82 #define SVCCTL_SVC_ERROR_NORMAL                 0x00000001
83 #define SVCCTL_SVC_ERROR_CRITICAL               0x00000002
84 #define SVCCTL_SVC_ERROR_SEVERE                 0x00000003
85
86 /* QueryServiceConfig2 options */
87 #define SERVICE_CONFIG_DESCRIPTION              0x00000001
88 #define SERVICE_CONFIG_FAILURE_ACTIONS          0x00000002
89
90
91 /* Service Config - values for ServiceType field*/
92
93 #define SVCCTL_KERNEL_DRVR                         0x00000001  /* doubtful we'll have these */
94 #define SVCCTL_FILE_SYSTEM_DRVR                    0x00000002  
95 #define SVCCTL_WIN32_OWN_PROC                      0x00000010
96 #define SVCCTL_WIN32_SHARED_PROC                   0x00000020
97 #define SVCCTL_WIN32_INTERACTIVE                   0x00000100 
98
99 /* Service Config - values for StartType field */
100 #define SVCCTL_BOOT_START                          0x00000000
101 #define SVCCTL_SYSTEM_START                        0x00000001
102 #define SVCCTL_AUTO_START                          0x00000002
103 #define SVCCTL_DEMAND_START                        0x00000003
104 #define SVCCTL_DISABLED                            0x00000004
105
106 /* Service Controls */
107
108 #define SVCCTL_CONTROL_STOP                     0x00000001
109 #define SVCCTL_CONTROL_PAUSE                    0x00000002
110 #define SVCCTL_CONTROL_CONTINUE                 0x00000003
111 #define SVCCTL_CONTROL_INTERROGATE              0x00000004
112 #define SVCCTL_CONTROL_SHUTDOWN                 0x00000005
113
114 #define SVC_HANDLE_IS_SCM                       0x0000001
115 #define SVC_HANDLE_IS_SERVICE                   0x0000002
116 #define SVC_HANDLE_IS_DBLOCK                    0x0000003
117
118 #define SVC_STATUS_PROCESS_INFO                 0x00000000
119
120 /* where we assume the location of the service control scripts */
121 #define SVCCTL_SCRIPT_DIR  "svcctl"
122
123 /* utility structures for RPCs */
124
125 typedef struct {
126         uint32 type;
127         uint32 state;
128         uint32 controls_accepted;
129         uint32 win32_exit_code;
130         uint32 service_exit_code;
131         uint32 check_point;
132         uint32 wait_hint;
133 } SERVICE_STATUS;
134
135 typedef struct {
136         SERVICE_STATUS status;
137         uint32 process_id;
138         uint32 service_flags;
139 } SERVICE_STATUS_PROCESS;
140
141
142 typedef struct {
143         UNISTR servicename;
144         UNISTR displayname;
145         SERVICE_STATUS status;
146 } ENUM_SERVICES_STATUS;
147
148 typedef struct {
149         uint32 service_type;
150         uint32 start_type;
151         uint32 error_control;
152         UNISTR2 *executablepath;
153         UNISTR2 *loadordergroup;
154         uint32 tag_id;
155         UNISTR2 *dependencies;
156         UNISTR2 *startname;
157         UNISTR2 *displayname;
158 } SERVICE_CONFIG;
159
160 typedef struct {
161         uint32 unknown; 
162         UNISTR description;
163 } SERVICE_DESCRIPTION;
164
165 typedef struct {
166         uint32 type;
167         uint32 delay;
168 } SC_ACTION;
169
170 typedef struct {
171         uint32 reset_period;
172         UNISTR2 *rebootmsg;     /* i have no idea if these are UNISTR2's.  I can't get a good trace */
173         UNISTR2 *command;
174         uint32  num_actions;
175         SC_ACTION *actions;
176 } SERVICE_FAILURE_ACTIONS;
177
178 typedef struct Service_info_struct {
179         uint32  type;           /* should be SVC_HANDLE_IS_SERVICE */
180         pstring servicename;    /* the name of the service */
181         pstring servicetype;    /* internal or external */
182         pstring filename;       /* what file name we can find this in, 
183                                    as well as the "index" for what the 
184                                    service name is */
185         pstring provides;
186         pstring dependencies;
187         pstring shouldstart;
188         pstring shouldstop;
189         pstring requiredstart;
190         pstring requiredstop;
191         pstring shortdescription;
192         pstring description;
193 } Service_info;
194
195 /* 
196  * dispatch table of functions to handle the =ServiceControl API
197  */ 
198  
199 typedef struct {
200         /* functions for enumerating subkeys and values */      
201         WERROR  (*stop_service)( const char *service, SERVICE_STATUS *status );
202         WERROR  (*start_service) ( const char *service );
203         WERROR  (*service_status)( const char *service, SERVICE_STATUS *status );
204 } SERVICE_CONTROL_OPS;
205
206 /* structure to store the service handle information  */
207
208 typedef struct _ServiceInfo {
209         uint8                   type;
210         char                    *name;
211         uint32                  access_granted;
212         SERVICE_CONTROL_OPS     *ops;
213 } SERVICE_INFO;
214
215
216 /* rpc structures */
217
218 /**************************/
219
220 typedef struct {
221         POLICY_HND handle;
222 } SVCCTL_Q_CLOSE_SERVICE;
223
224 typedef struct {
225         POLICY_HND handle;
226         WERROR status;
227 } SVCCTL_R_CLOSE_SERVICE;
228
229 /**************************/
230
231 typedef struct {
232         UNISTR2 *servername;
233         UNISTR2 *database; 
234         uint32 access;
235 } SVCCTL_Q_OPEN_SCMANAGER;
236
237 typedef struct {
238         POLICY_HND handle;
239         WERROR status;
240 } SVCCTL_R_OPEN_SCMANAGER;
241
242 /**************************/
243
244 typedef struct {
245         POLICY_HND handle;
246         UNISTR2 servicename;
247         uint32  display_name_len;
248 } SVCCTL_Q_GET_DISPLAY_NAME;
249
250 typedef struct {
251         UNISTR2 displayname;
252         uint32 display_name_len;
253         WERROR status;
254 } SVCCTL_R_GET_DISPLAY_NAME;
255
256 /**************************/
257
258 typedef struct {
259         POLICY_HND handle;
260         UNISTR2 servicename;
261         uint32 access;
262 } SVCCTL_Q_OPEN_SERVICE;
263
264 typedef struct {
265         POLICY_HND handle;
266         WERROR status;
267 } SVCCTL_R_OPEN_SERVICE;
268
269 /**************************/
270
271 typedef struct {
272         POLICY_HND handle;
273         uint32 parmcount;
274         UNISTR4_ARRAY *parameters;
275 } SVCCTL_Q_START_SERVICE;
276
277 typedef struct {
278         WERROR status;
279 } SVCCTL_R_START_SERVICE;
280
281 /**************************/
282
283 typedef struct {
284         POLICY_HND handle;
285         uint32 control;
286 } SVCCTL_Q_CONTROL_SERVICE;
287
288 typedef struct {
289         SERVICE_STATUS svc_status;
290         WERROR status;
291 } SVCCTL_R_CONTROL_SERVICE;
292
293 /**************************/
294
295 typedef struct {
296         POLICY_HND handle;
297 } SVCCTL_Q_QUERY_STATUS;
298
299 typedef struct {
300         SERVICE_STATUS svc_status;
301         WERROR status;
302 } SVCCTL_R_QUERY_STATUS;
303
304 /**************************/
305
306 typedef struct {
307         POLICY_HND handle;
308         uint32 type;
309         uint32 state;
310         uint32 buffer_size;
311         uint32 *resume;
312 } SVCCTL_Q_ENUM_SERVICES_STATUS;
313
314 typedef struct {
315         RPC_BUFFER buffer;
316         uint32 needed;
317         uint32 returned;
318         uint32 *resume;
319         WERROR status;
320 } SVCCTL_R_ENUM_SERVICES_STATUS;
321
322 /**************************/
323
324 typedef struct {
325         POLICY_HND handle;
326         uint32 state;
327         uint32 buffer_size;
328 } SVCCTL_Q_ENUM_DEPENDENT_SERVICES;
329
330 typedef struct {
331         RPC_BUFFER buffer;
332         uint32 needed;
333         uint32 returned;
334         WERROR status;
335 } SVCCTL_R_ENUM_DEPENDENT_SERVICES;
336
337
338 /**************************/
339
340 typedef struct {
341         POLICY_HND handle;
342         uint32 buffer_size;
343 } SVCCTL_Q_QUERY_SERVICE_CONFIG;
344
345 typedef struct {
346         SERVICE_CONFIG config;
347         uint32 needed;
348         WERROR status;
349 } SVCCTL_R_QUERY_SERVICE_CONFIG;
350
351
352 /**************************/
353
354 typedef struct {
355         POLICY_HND handle;
356         uint32 level;
357         uint32 buffer_size;
358 } SVCCTL_Q_QUERY_SERVICE_CONFIG2;
359
360 typedef struct {
361         RPC_BUFFER buffer;
362         uint32 needed;
363         WERROR status;
364 } SVCCTL_R_QUERY_SERVICE_CONFIG2;
365
366
367 /**************************/
368
369 typedef struct {
370         POLICY_HND handle;
371         uint32 level;
372         uint32 buffer_size;
373 } SVCCTL_Q_QUERY_SERVICE_STATUSEX;
374
375 typedef struct {
376         RPC_BUFFER buffer;
377         uint32 needed;
378         WERROR status;
379 } SVCCTL_R_QUERY_SERVICE_STATUSEX;
380
381
382 /**************************/
383
384 typedef struct {
385         POLICY_HND handle;
386 } SVCCTL_Q_LOCK_SERVICE_DB;
387
388 typedef struct {
389         POLICY_HND h_lock;
390         WERROR status;
391 } SVCCTL_R_LOCK_SERVICE_DB;
392
393
394 /**************************/
395
396 typedef struct {
397         POLICY_HND h_lock;
398 } SVCCTL_Q_UNLOCK_SERVICE_DB;
399
400 typedef struct {
401         WERROR status;
402 } SVCCTL_R_UNLOCK_SERVICE_DB;
403
404 #endif /* _RPC_SVCCTL_H */
405