fix a typo
[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
31 #define SVCCTL_SET_SERVICE_SEC                  0x05
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_NONE                      0x00000000
73 #define SVCCTL_ACCEPT_STOP                      0x00000001
74 #define SVCCTL_ACCEPT_PAUSE_CONTINUE            0x00000002
75 #define SVCCTL_ACCEPT_SHUTDOWN                  0x00000004
76 #define SVCCTL_ACCEPT_PARAMCHANGE               0x00000008
77 #define SVCCTL_ACCEPT_NETBINDCHANGE             0x00000010
78 #define SVCCTL_ACCEPT_HARDWAREPROFILECHANGE     0x00000020
79 #define SVCCTL_ACCEPT_POWEREVENT                0x00000040
80
81 /* SERVER_STATUS - ControlAccepted */
82 #define SVCCTL_SVC_ERROR_IGNORE                 0x00000000
83 #define SVCCTL_SVC_ERROR_NORMAL                 0x00000001
84 #define SVCCTL_SVC_ERROR_CRITICAL               0x00000002
85 #define SVCCTL_SVC_ERROR_SEVERE                 0x00000003
86
87 /* QueryServiceConfig2 options */
88 #define SERVICE_CONFIG_DESCRIPTION              0x00000001
89 #define SERVICE_CONFIG_FAILURE_ACTIONS          0x00000002
90
91
92 /* Service Config - values for ServiceType field*/
93
94 #define SVCCTL_KERNEL_DRVR                         0x00000001  /* doubtful we'll have these */
95 #define SVCCTL_FILE_SYSTEM_DRVR                    0x00000002  
96 #define SVCCTL_WIN32_OWN_PROC                      0x00000010
97 #define SVCCTL_WIN32_SHARED_PROC                   0x00000020
98 #define SVCCTL_WIN32_INTERACTIVE                   0x00000100 
99
100 /* Service Config - values for StartType field */
101 #define SVCCTL_BOOT_START                          0x00000000
102 #define SVCCTL_SYSTEM_START                        0x00000001
103 #define SVCCTL_AUTO_START                          0x00000002
104 #define SVCCTL_DEMAND_START                        0x00000003
105 #define SVCCTL_DISABLED                            0x00000004
106
107 /* Service Controls */
108
109 #define SVCCTL_CONTROL_STOP                     0x00000001
110 #define SVCCTL_CONTROL_PAUSE                    0x00000002
111 #define SVCCTL_CONTROL_CONTINUE                 0x00000003
112 #define SVCCTL_CONTROL_INTERROGATE              0x00000004
113 #define SVCCTL_CONTROL_SHUTDOWN                 0x00000005
114
115 #define SVC_HANDLE_IS_SCM                       0x0000001
116 #define SVC_HANDLE_IS_SERVICE                   0x0000002
117 #define SVC_HANDLE_IS_DBLOCK                    0x0000003
118
119 #define SVC_STATUS_PROCESS_INFO                 0x00000000
120
121 /* where we assume the location of the service control scripts */
122 #define SVCCTL_SCRIPT_DIR  "svcctl"
123
124 /* utility structures for RPCs */
125
126 typedef struct {
127         uint32 type;
128         uint32 state;
129         uint32 controls_accepted;
130         WERROR win32_exit_code;
131         uint32 service_exit_code;
132         uint32 check_point;
133         uint32 wait_hint;
134 } SERVICE_STATUS;
135
136 typedef struct {
137         SERVICE_STATUS status;
138         uint32 process_id;
139         uint32 service_flags;
140 } SERVICE_STATUS_PROCESS;
141
142
143 typedef struct {
144         UNISTR servicename;
145         UNISTR displayname;
146         SERVICE_STATUS status;
147 } ENUM_SERVICES_STATUS;
148
149 typedef struct {
150         uint32 service_type;
151         uint32 start_type;
152         uint32 error_control;
153         UNISTR2 *executablepath;
154         UNISTR2 *loadordergroup;
155         uint32 tag_id;
156         UNISTR2 *dependencies;
157         UNISTR2 *startname;
158         UNISTR2 *displayname;
159 } SERVICE_CONFIG;
160
161 typedef struct {
162         uint32 unknown; 
163         UNISTR description;
164 } SERVICE_DESCRIPTION;
165
166 typedef struct {
167         uint32 type;
168         uint32 delay;
169 } SC_ACTION;
170
171 typedef struct {
172         uint32 reset_period;
173         UNISTR2 *rebootmsg;     /* i have no idea if these are UNISTR2's.  I can't get a good trace */
174         UNISTR2 *command;
175         uint32  num_actions;
176         SC_ACTION *actions;
177 } SERVICE_FAILURE_ACTIONS;
178
179 /* 
180  * dispatch table of functions to handle the =ServiceControl API
181  */ 
182  
183 typedef struct {
184         /* functions for enumerating subkeys and values */      
185         WERROR  (*stop_service)( const char *service, SERVICE_STATUS *status );
186         WERROR  (*start_service) ( const char *service );
187         WERROR  (*service_status)( const char *service, SERVICE_STATUS *status );
188 } SERVICE_CONTROL_OPS;
189
190 /* structure to store the service handle information  */
191
192 typedef struct _ServiceInfo {
193         uint8                   type;
194         char                    *name;
195         uint32                  access_granted;
196         SERVICE_CONTROL_OPS     *ops;
197 } SERVICE_INFO;
198
199
200 /* rpc structures */
201
202 /**************************/
203
204 typedef struct {
205         POLICY_HND handle;
206 } SVCCTL_Q_CLOSE_SERVICE;
207
208 typedef struct {
209         POLICY_HND handle;
210         WERROR status;
211 } SVCCTL_R_CLOSE_SERVICE;
212
213 /**************************/
214
215 typedef struct {
216         UNISTR2 *servername;
217         UNISTR2 *database; 
218         uint32 access;
219 } SVCCTL_Q_OPEN_SCMANAGER;
220
221 typedef struct {
222         POLICY_HND handle;
223         WERROR status;
224 } SVCCTL_R_OPEN_SCMANAGER;
225
226 /**************************/
227
228 typedef struct {
229         POLICY_HND handle;
230         UNISTR2 servicename;
231         uint32  display_name_len;
232 } SVCCTL_Q_GET_DISPLAY_NAME;
233
234 typedef struct {
235         UNISTR2 displayname;
236         uint32 display_name_len;
237         WERROR status;
238 } SVCCTL_R_GET_DISPLAY_NAME;
239
240 /**************************/
241
242 typedef struct {
243         POLICY_HND handle;
244         UNISTR2 servicename;
245         uint32 access;
246 } SVCCTL_Q_OPEN_SERVICE;
247
248 typedef struct {
249         POLICY_HND handle;
250         WERROR status;
251 } SVCCTL_R_OPEN_SERVICE;
252
253 /**************************/
254
255 typedef struct {
256         POLICY_HND handle;
257         uint32 parmcount;
258         UNISTR4_ARRAY *parameters;
259 } SVCCTL_Q_START_SERVICE;
260
261 typedef struct {
262         WERROR status;
263 } SVCCTL_R_START_SERVICE;
264
265 /**************************/
266
267 typedef struct {
268         POLICY_HND handle;
269         uint32 control;
270 } SVCCTL_Q_CONTROL_SERVICE;
271
272 typedef struct {
273         SERVICE_STATUS svc_status;
274         WERROR status;
275 } SVCCTL_R_CONTROL_SERVICE;
276
277 /**************************/
278
279 typedef struct {
280         POLICY_HND handle;
281 } SVCCTL_Q_QUERY_STATUS;
282
283 typedef struct {
284         SERVICE_STATUS svc_status;
285         WERROR status;
286 } SVCCTL_R_QUERY_STATUS;
287
288 /**************************/
289
290 typedef struct {
291         POLICY_HND handle;
292         uint32 type;
293         uint32 state;
294         uint32 buffer_size;
295         uint32 *resume;
296 } SVCCTL_Q_ENUM_SERVICES_STATUS;
297
298 typedef struct {
299         RPC_BUFFER buffer;
300         uint32 needed;
301         uint32 returned;
302         uint32 *resume;
303         WERROR status;
304 } SVCCTL_R_ENUM_SERVICES_STATUS;
305
306 /**************************/
307
308 typedef struct {
309         POLICY_HND handle;
310         uint32 state;
311         uint32 buffer_size;
312 } SVCCTL_Q_ENUM_DEPENDENT_SERVICES;
313
314 typedef struct {
315         RPC_BUFFER buffer;
316         uint32 needed;
317         uint32 returned;
318         WERROR status;
319 } SVCCTL_R_ENUM_DEPENDENT_SERVICES;
320
321
322 /**************************/
323
324 typedef struct {
325         POLICY_HND handle;
326         uint32 buffer_size;
327 } SVCCTL_Q_QUERY_SERVICE_CONFIG;
328
329 typedef struct {
330         SERVICE_CONFIG config;
331         uint32 needed;
332         WERROR status;
333 } SVCCTL_R_QUERY_SERVICE_CONFIG;
334
335
336 /**************************/
337
338 typedef struct {
339         POLICY_HND handle;
340         uint32 level;
341         uint32 buffer_size;
342 } SVCCTL_Q_QUERY_SERVICE_CONFIG2;
343
344 typedef struct {
345         RPC_BUFFER buffer;
346         uint32 needed;
347         WERROR status;
348 } SVCCTL_R_QUERY_SERVICE_CONFIG2;
349
350
351 /**************************/
352
353 typedef struct {
354         POLICY_HND handle;
355         uint32 level;
356         uint32 buffer_size;
357 } SVCCTL_Q_QUERY_SERVICE_STATUSEX;
358
359 typedef struct {
360         RPC_BUFFER buffer;
361         uint32 needed;
362         WERROR status;
363 } SVCCTL_R_QUERY_SERVICE_STATUSEX;
364
365
366 /**************************/
367
368 typedef struct {
369         POLICY_HND handle;
370 } SVCCTL_Q_LOCK_SERVICE_DB;
371
372 typedef struct {
373         POLICY_HND h_lock;
374         WERROR status;
375 } SVCCTL_R_LOCK_SERVICE_DB;
376
377
378 /**************************/
379
380 typedef struct {
381         POLICY_HND h_lock;
382 } SVCCTL_Q_UNLOCK_SERVICE_DB;
383
384 typedef struct {
385         WERROR status;
386 } SVCCTL_R_UNLOCK_SERVICE_DB;
387
388
389 /**************************/
390
391 typedef struct {
392         POLICY_HND handle;
393         uint32 security_flags;
394         uint32 buffer_size;     
395 } SVCCTL_Q_QUERY_SERVICE_SEC;
396
397 typedef struct {
398         RPC_BUFFER buffer;
399         uint32 needed;
400         WERROR status;
401 } SVCCTL_R_QUERY_SERVICE_SEC;
402
403 /**************************/
404
405 typedef struct {
406         POLICY_HND handle; 
407         uint32 security_flags;        
408         RPC_BUFFER buffer;
409         uint32 buffer_size;
410 } SVCCTL_Q_SET_SERVICE_SEC;
411
412 typedef struct {
413         WERROR status;
414 } SVCCTL_R_SET_SERVICE_SEC;
415
416
417 #endif /* _RPC_SVCCTL_H */
418