RIP BOOL. Convert BOOL -> bool. I found a few interesting
[nivanova/samba-autobuild/.git] / source3 / 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 3 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, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _RPC_SVCCTL_H /* _RPC_SVCCTL_H */
22 #define _RPC_SVCCTL_H 
23
24 /* svcctl pipe */
25
26 #define SVCCTL_CLOSE_SERVICE                    0x00
27 #define SVCCTL_CONTROL_SERVICE                  0x01
28 #define SVCCTL_LOCK_SERVICE_DB                  0x03
29 #define SVCCTL_QUERY_SERVICE_SEC                0x04
30 #define SVCCTL_SET_SERVICE_SEC                  0x05
31 #define SVCCTL_QUERY_STATUS                     0x06
32 #define SVCCTL_UNLOCK_SERVICE_DB                0x08
33 #define SVCCTL_ENUM_DEPENDENT_SERVICES_W        0x0d
34 #define SVCCTL_ENUM_SERVICES_STATUS_W           0x0e
35 #define SVCCTL_OPEN_SCMANAGER_W                 0x0f
36 #define SVCCTL_OPEN_SERVICE_W                   0x10
37 #define SVCCTL_QUERY_SERVICE_CONFIG_W           0x11
38 #define SVCCTL_START_SERVICE_W                  0x13
39 #define SVCCTL_GET_DISPLAY_NAME                 0x14
40 #define SVCCTL_QUERY_SERVICE_CONFIG2_W          0x27
41 #define SVCCTL_QUERY_SERVICE_STATUSEX_W         0x28
42
43 /* ANSI versions not implemented currently 
44 #define SVCCTL_ENUM_SERVICES_STATUS_A           0x0e
45 #define SVCCTL_OPEN_SCMANAGER_A                 0x1b
46 */
47
48 /* SERVER_STATUS - type */
49
50 #define SVCCTL_TYPE_WIN32               0x00000030
51 #define SVCCTL_TYPE_DRIVER              0x0000000f
52
53 /* SERVER_STATUS - state */
54 #define SVCCTL_STATE_ACTIVE             0x00000001
55 #define SVCCTL_STATE_INACTIVE           0x00000002
56 #define SVCCTL_STATE_ALL                ( SVCCTL_STATE_ACTIVE | SVCCTL_STATE_INACTIVE )
57
58 /* SERVER_STATUS - CurrentState */
59
60 #define SVCCTL_STATE_UNKNOWN            0x00000000      /* only used internally to smbd */
61 #define SVCCTL_STOPPED                  0x00000001
62 #define SVCCTL_START_PENDING            0x00000002
63 #define SVCCTL_STOP_PENDING             0x00000003
64 #define SVCCTL_RUNNING                  0x00000004
65 #define SVCCTL_CONTINUE_PENDING         0x00000005
66 #define SVCCTL_PAUSE_PENDING            0x00000006
67 #define SVCCTL_PAUSED                   0x00000007
68
69 /* SERVER_STATUS - ControlAccepted */
70
71 #define SVCCTL_ACCEPT_NONE                      0x00000000
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 /*
126  * "struct SERVICE_STATUS" comes from librpc/gen_ndr/svcctl.h
127  */
128
129 typedef struct SERVICE_STATUS SERVICE_STATUS;
130
131 typedef struct {
132         SERVICE_STATUS status;
133         uint32 process_id;
134         uint32 service_flags;
135 } SERVICE_STATUS_PROCESS;
136
137
138 typedef struct {
139         UNISTR servicename;
140         UNISTR displayname;
141         SERVICE_STATUS status;
142 } ENUM_SERVICES_STATUS;
143
144 typedef struct {
145         uint32 service_type;
146         uint32 start_type;
147         uint32 error_control;
148         UNISTR2 *executablepath;
149         UNISTR2 *loadordergroup;
150         uint32 tag_id;
151         UNISTR2 *dependencies;
152         UNISTR2 *startname;
153         UNISTR2 *displayname;
154 } SERVICE_CONFIG;
155
156 typedef struct {
157         uint32 unknown; 
158         UNISTR description;
159 } SERVICE_DESCRIPTION;
160
161 typedef struct {
162         uint32 type;
163         uint32 delay;
164 } SC_ACTION;
165
166 typedef struct {
167         uint32 reset_period;
168         UNISTR2 *rebootmsg;     /* i have no idea if these are UNISTR2's.  I can't get a good trace */
169         UNISTR2 *command;
170         uint32  num_actions;
171         SC_ACTION *actions;
172 } SERVICE_FAILURE_ACTIONS;
173
174 /* 
175  * dispatch table of functions to handle the =ServiceControl API
176  */ 
177  
178 typedef struct {
179         /* functions for enumerating subkeys and values */      
180         WERROR  (*stop_service)( const char *service, SERVICE_STATUS *status );
181         WERROR  (*start_service) ( const char *service );
182         WERROR  (*service_status)( const char *service, SERVICE_STATUS *status );
183 } SERVICE_CONTROL_OPS;
184
185 /* structure to store the service handle information  */
186
187 typedef struct _ServiceInfo {
188         uint8                   type;
189         char                    *name;
190         uint32                  access_granted;
191         SERVICE_CONTROL_OPS     *ops;
192 } SERVICE_INFO;
193
194
195 /* rpc structures */
196
197 /**************************/
198
199 typedef struct {
200         UNISTR2 *servername;
201         UNISTR2 *database; 
202         uint32 access;
203 } SVCCTL_Q_OPEN_SCMANAGER;
204
205 typedef struct {
206         POLICY_HND handle;
207         WERROR status;
208 } SVCCTL_R_OPEN_SCMANAGER;
209
210 /**************************/
211
212 typedef struct {
213         POLICY_HND handle;
214         UNISTR2 servicename;
215         uint32  display_name_len;
216 } SVCCTL_Q_GET_DISPLAY_NAME;
217
218 typedef struct {
219         UNISTR2 displayname;
220         uint32 display_name_len;
221         WERROR status;
222 } SVCCTL_R_GET_DISPLAY_NAME;
223
224 /**************************/
225
226 typedef struct {
227         POLICY_HND handle;
228         UNISTR2 servicename;
229         uint32 access;
230 } SVCCTL_Q_OPEN_SERVICE;
231
232 typedef struct {
233         POLICY_HND handle;
234         WERROR status;
235 } SVCCTL_R_OPEN_SERVICE;
236
237 /**************************/
238
239 typedef struct {
240         POLICY_HND handle;
241         uint32 parmcount;
242         UNISTR4_ARRAY *parameters;
243 } SVCCTL_Q_START_SERVICE;
244
245 typedef struct {
246         WERROR status;
247 } SVCCTL_R_START_SERVICE;
248
249 /**************************/
250
251 typedef struct {
252         POLICY_HND handle;
253         uint32 control;
254 } SVCCTL_Q_CONTROL_SERVICE;
255
256 typedef struct {
257         SERVICE_STATUS svc_status;
258         WERROR status;
259 } SVCCTL_R_CONTROL_SERVICE;
260
261 /**************************/
262
263 typedef struct {
264         POLICY_HND handle;
265 } SVCCTL_Q_QUERY_STATUS;
266
267 typedef struct {
268         SERVICE_STATUS svc_status;
269         WERROR status;
270 } SVCCTL_R_QUERY_STATUS;
271
272 /**************************/
273
274 typedef struct {
275         POLICY_HND handle;
276         uint32 type;
277         uint32 state;
278         uint32 buffer_size;
279         uint32 *resume;
280 } SVCCTL_Q_ENUM_SERVICES_STATUS;
281
282 typedef struct {
283         RPC_BUFFER buffer;
284         uint32 needed;
285         uint32 returned;
286         uint32 *resume;
287         WERROR status;
288 } SVCCTL_R_ENUM_SERVICES_STATUS;
289
290 /**************************/
291
292 typedef struct {
293         POLICY_HND handle;
294         uint32 state;
295         uint32 buffer_size;
296 } SVCCTL_Q_ENUM_DEPENDENT_SERVICES;
297
298 typedef struct {
299         RPC_BUFFER buffer;
300         uint32 needed;
301         uint32 returned;
302         WERROR status;
303 } SVCCTL_R_ENUM_DEPENDENT_SERVICES;
304
305
306 /**************************/
307
308 typedef struct {
309         POLICY_HND handle;
310         uint32 buffer_size;
311 } SVCCTL_Q_QUERY_SERVICE_CONFIG;
312
313 typedef struct {
314         SERVICE_CONFIG config;
315         uint32 needed;
316         WERROR status;
317 } SVCCTL_R_QUERY_SERVICE_CONFIG;
318
319
320 /**************************/
321
322 typedef struct {
323         POLICY_HND handle;
324         uint32 level;
325         uint32 buffer_size;
326 } SVCCTL_Q_QUERY_SERVICE_CONFIG2;
327
328 typedef struct {
329         RPC_BUFFER buffer;
330         uint32 needed;
331         WERROR status;
332 } SVCCTL_R_QUERY_SERVICE_CONFIG2;
333
334
335 /**************************/
336
337 typedef struct {
338         POLICY_HND handle;
339         uint32 level;
340         uint32 buffer_size;
341 } SVCCTL_Q_QUERY_SERVICE_STATUSEX;
342
343 typedef struct {
344         RPC_BUFFER buffer;
345         uint32 needed;
346         WERROR status;
347 } SVCCTL_R_QUERY_SERVICE_STATUSEX;
348
349
350 /**************************/
351
352 typedef struct {
353         POLICY_HND handle;
354 } SVCCTL_Q_LOCK_SERVICE_DB;
355
356 typedef struct {
357         POLICY_HND h_lock;
358         WERROR status;
359 } SVCCTL_R_LOCK_SERVICE_DB;
360
361
362 /**************************/
363
364 typedef struct {
365         POLICY_HND h_lock;
366 } SVCCTL_Q_UNLOCK_SERVICE_DB;
367
368 typedef struct {
369         WERROR status;
370 } SVCCTL_R_UNLOCK_SERVICE_DB;
371
372
373 /**************************/
374
375 typedef struct {
376         POLICY_HND handle;
377         uint32 security_flags;
378         uint32 buffer_size;     
379 } SVCCTL_Q_QUERY_SERVICE_SEC;
380
381 typedef struct {
382         RPC_BUFFER buffer;
383         uint32 needed;
384         WERROR status;
385 } SVCCTL_R_QUERY_SERVICE_SEC;
386
387 /**************************/
388
389 typedef struct {
390         POLICY_HND handle; 
391         uint32 security_flags;        
392         RPC_BUFFER buffer;
393         uint32 buffer_size;
394 } SVCCTL_Q_SET_SERVICE_SEC;
395
396 typedef struct {
397         WERROR status;
398 } SVCCTL_R_SET_SERVICE_SEC;
399
400
401 #endif /* _RPC_SVCCTL_H */
402