r7610: can successfully stop and start the 'spooler' service by setting the state...
[amitay/samba.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 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
26 /* svcctl pipe */
27
28 #define SVCCTL_CLOSE_SERVICE                    0x00
29 #define SVCCTL_CONTROL_SERVICE                  0x01
30 #define SVCCTL_QUERY_STATUS                     0x06
31 #define SVCCTL_ENUM_DEPENDENT_SERVICES_W        0x0d
32 #define SVCCTL_ENUM_SERVICES_STATUS_W           0x0e
33 #define SVCCTL_OPEN_SCMANAGER_W                 0x0f
34 #define SVCCTL_OPEN_SERVICE_W                   0x10
35 #define SVCCTL_QUERY_SERVICE_CONFIG_W           0x11
36 #define SVCCTL_START_SERVICE_W                  0x13
37 #define SVCCTL_GET_DISPLAY_NAME                 0x14
38 #define SVCCTL_QUERY_SERVICE_CONFIG2_W          0x27
39 #define SVCCTL_QUERY_SERVICE_STATUSEX_W         0x28
40
41 /* ANSI versions not implemented currently 
42 #define SVCCTL_ENUM_SERVICES_STATUS_A           0x0e
43 #define SVCCTL_OPEN_SCMANAGER_A                 0x1b
44 */
45
46 /* SERVER_STATUS - type */
47
48 #define SVCCTL_TYPE_WIN32               0x00000030
49 #define SVCCTL_TYPE_DRIVER              0x0000000f
50
51 /* SERVER_STATUS - state */
52 #define SVCCTL_STATE_ACTIVE             0x00000001
53 #define SVCCTL_STATE_INACTIVE           0x00000002
54 #define SVCCTL_STATE_ALL                ( SVCCTL_STATE_ACTIVE | SVCCTL_STATE_INACTIVE )
55
56 /* SERVER_STATUS - CurrentState */
57
58 #define SVCCTL_STATE_UNKNOWN            0x00000000      /* only used internally to smbd */
59 #define SVCCTL_STOPPED                  0x00000001
60 #define SVCCTL_START_PENDING            0x00000002
61 #define SVCCTL_STOP_PENDING             0x00000003
62 #define SVCCTL_RUNNING                  0x00000004
63 #define SVCCTL_CONTINUE_PENDING         0x00000005
64 #define SVCCTL_PAUSE_PENDING            0x00000006
65 #define SVCCTL_PAUSED                   0x00000007
66
67 /* SERVER_STATUS - ControlAccepted */
68
69 #define SVCCTL_ACCEPT_STOP                      0x00000001
70 #define SVCCTL_ACCEPT_PAUSE_CONTINUE            0x00000002
71 #define SVCCTL_ACCEPT_SHUTDOWN                  0x00000004
72 #define SVCCTL_ACCEPT_PARAMCHANGE               0x00000008
73 #define SVCCTL_ACCEPT_NETBINDCHANGE             0x00000010
74 #define SVCCTL_ACCEPT_HARDWAREPROFILECHANGE     0x00000020
75 #define SVCCTL_ACCEPT_POWEREVENT                0x00000040
76
77 /* SERVER_STATUS - ControlAccepted */
78 #define SVCCTL_SVC_ERROR_IGNORE                 0x00000000
79 #define SVCCTL_SVC_ERROR_NORMAL                 0x00000001
80 #define SVCCTL_SVC_ERROR_CRITICAL               0x00000002
81 #define SVCCTL_SVC_ERROR_SEVERE                 0x00000003
82
83 /* QueryServiceConfig2 options */
84 #define SERVICE_CONFIG_DESCRIPTION              0x00000001
85 #define SERVICE_CONFIG_FAILURE_ACTIONS          0x00000002
86
87
88 /* Service Config - values for ServiceType field*/
89
90 #define SVCCTL_KERNEL_DRVR                         0x00000001  /* doubtful we'll have these */
91 #define SVCCTL_FILE_SYSTEM_DRVR                    0x00000002  
92 #define SVCCTL_WIN32_OWN_PROC                      0x00000010
93 #define SVCCTL_WIN32_SHARED_PROC                   0x00000020
94 #define SVCCTL_WIN32_INTERACTIVE                   0x00000100 
95
96 /* Service Config - values for StartType field */
97 #define SVCCTL_BOOT_START                          0x00000000
98 #define SVCCTL_SYSTEM_START                        0x00000001
99 #define SVCCTL_AUTO_START                          0x00000002
100 #define SVCCTL_DEMAND_START                        0x00000003
101 #define SVCCTL_DISABLED                            0x00000004
102
103 /* Service Controls */
104
105 #define SVCCTL_CONTROL_STOP                     0x00000001
106 #define SVCCTL_CONTROL_PAUSE                    0x00000002
107 #define SVCCTL_CONTROL_CONTINUE                 0x00000003
108 #define SVCCTL_CONTROL_SHUTDOWN                 0x00000004
109
110 #define SVC_HANDLE_IS_SCM                       0x0000001
111 #define SVC_HANDLE_IS_SERVICE                   0x0000002
112
113 #define SVC_STATUS_PROCESS_INFO                 0x00000001
114
115 #define SVCCTL_SCRIPT_DIR  "/svcctl/"
116
117 /* utility structures for RPCs */
118
119 typedef struct {
120         uint32 type;
121         uint32 state;
122         uint32 controls_accepted;
123         uint32 win32_exit_code;
124         uint32 service_exit_code;
125         uint32 check_point;
126         uint32 wait_hint;
127 } SERVICE_STATUS;
128
129 typedef struct {
130         uint32 type;
131         uint32 state;
132         uint32 controls_accepted;
133         uint32 win32_exit_code;
134         uint32 service_exit_code;
135         uint32 check_point;
136         uint32 wait_hint;
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         UNISTR2 *description;
162 } SERVICE_DESCRIPTION;
163
164 typedef struct {
165         uint32 type;
166         uint32 delay;
167 } SC_ACTION;
168
169 typedef struct {
170         uint32 reset_period;
171         UNISTR2 *rebootmsg;
172         UNISTR2 *command;
173         uint32  nActions;
174         SC_ACTION *saActions;
175         UNISTR2 *description;
176 } SERVICE_FAILURE_ACTIONS;
177
178
179 typedef struct SCM_info_struct {
180         uint32  type;                    /* should be SVC_HANDLE_IS_SCM */
181         pstring target_server_name;      /* name of the server on which the operation is taking place */
182         pstring target_db_name;          /* name of the database that we're opening */
183 } SCM_info;
184
185 typedef struct Service_info_struct {
186         uint32  type;           /* should be SVC_HANDLE_IS_SERVICE */
187         pstring servicename;    /* the name of the service */
188         pstring servicetype;    /* internal or external */
189         pstring filename;       /* what file name we can find this in, 
190                                    as well as the "index" for what the 
191                                    service name is */
192         pstring provides;
193         pstring dependencies;
194         pstring shouldstart;
195         pstring shouldstop;
196         pstring requiredstart;
197         pstring requiredstop;
198         pstring shortdescription;
199         pstring description;
200 } Service_info;
201
202 /* 
203  * dispatch table of functions to handle the =ServiceControl API
204  */ 
205  
206 typedef struct {
207         /* functions for enumerating subkeys and values */      
208         WERROR  (*stop_service)( SERVICE_STATUS *status );
209         WERROR  (*start_service) ( void );
210         WERROR  (*service_status)( SERVICE_STATUS *status );
211 } SERVICE_CONTROL_OPS;
212
213 /* structure to store the service handle information  */
214
215 typedef struct _ServiceInfo {
216         uint8                   type;
217         char                    *name;
218         uint32                  access_granted;
219         SERVICE_CONTROL_OPS     *ops;
220 } SERVICE_INFO;
221
222
223 /* rpc structures */
224
225 /**************************/
226
227 typedef struct {
228         POLICY_HND handle;
229 } SVCCTL_Q_CLOSE_SERVICE;
230
231 typedef struct {
232         POLICY_HND handle;
233         WERROR status;
234 } SVCCTL_R_CLOSE_SERVICE;
235
236 /**************************/
237
238 typedef struct {
239         UNISTR2 *servername;
240         UNISTR2 *database; 
241         uint32 access;
242 } SVCCTL_Q_OPEN_SCMANAGER;
243
244 typedef struct {
245         POLICY_HND handle;
246         WERROR status;
247 } SVCCTL_R_OPEN_SCMANAGER;
248
249 /**************************/
250
251 typedef struct {
252         POLICY_HND handle;
253         UNISTR2 servicename;
254         uint32  display_name_len;
255 } SVCCTL_Q_GET_DISPLAY_NAME;
256
257 typedef struct {
258         UNISTR2 displayname;
259         uint32 display_name_len;
260         WERROR status;
261 } SVCCTL_R_GET_DISPLAY_NAME;
262
263 /**************************/
264
265 typedef struct {
266         POLICY_HND handle;
267         UNISTR2 servicename;
268         uint32 access;
269 } SVCCTL_Q_OPEN_SERVICE;
270
271 typedef struct {
272         POLICY_HND handle;
273         WERROR status;
274 } SVCCTL_R_OPEN_SERVICE;
275
276 /**************************/
277
278 typedef struct {
279         POLICY_HND handle;
280         uint32 parmcount;
281         UNISTR4_ARRAY *parameters;
282 } SVCCTL_Q_START_SERVICE;
283
284 typedef struct {
285         WERROR status;
286 } SVCCTL_R_START_SERVICE;
287
288 /**************************/
289
290 typedef struct {
291         POLICY_HND handle;
292         uint32 control;
293 } SVCCTL_Q_CONTROL_SERVICE;
294
295 typedef struct {
296         SERVICE_STATUS svc_status;
297         WERROR status;
298 } SVCCTL_R_CONTROL_SERVICE;
299
300 /**************************/
301
302 typedef struct {
303         POLICY_HND handle;
304 } SVCCTL_Q_QUERY_STATUS;
305
306 typedef struct {
307         SERVICE_STATUS svc_status;
308         WERROR status;
309 } SVCCTL_R_QUERY_STATUS;
310
311 /**************************/
312
313 typedef struct {
314         POLICY_HND handle;
315         uint32 type;
316         uint32 state;
317         uint32 buffer_size;
318         uint32 *resume;
319 } SVCCTL_Q_ENUM_SERVICES_STATUS;
320
321 typedef struct {
322         RPC_BUFFER buffer;
323         uint32 needed;
324         uint32 returned;
325         uint32 *resume;
326         WERROR status;
327 } SVCCTL_R_ENUM_SERVICES_STATUS;
328
329 /**************************/
330
331 typedef struct {
332         POLICY_HND handle;
333         uint32 state;
334         uint32 buffer_size;
335 } SVCCTL_Q_ENUM_DEPENDENT_SERVICES;
336
337 typedef struct {
338         RPC_BUFFER buffer;
339         uint32 needed;
340         uint32 returned;
341         WERROR status;
342 } SVCCTL_R_ENUM_DEPENDENT_SERVICES;
343
344 /**************************/
345
346 typedef struct {
347         POLICY_HND handle;
348         uint32 buffer_size;
349 } SVCCTL_Q_QUERY_SERVICE_CONFIG;
350
351 typedef struct {
352         SERVICE_CONFIG config;
353         uint32 needed;
354         WERROR status;
355 } SVCCTL_R_QUERY_SERVICE_CONFIG;
356
357 typedef struct {
358         POLICY_HND handle;
359         uint32 info_level;
360         uint32 buffer_size;
361 } SVCCTL_Q_QUERY_SERVICE_CONFIG2;
362
363 typedef struct {
364         UNISTR2 *description;
365         uint32 returned;
366         uint32 needed;
367         uint32 offset;
368         WERROR status;
369 } SVCCTL_R_QUERY_SERVICE_CONFIG2;
370
371 typedef struct {
372         POLICY_HND handle;
373         uint32 info_level;
374         uint32 buffer_size;
375 } SVCCTL_Q_QUERY_SERVICE_STATUSEX;
376
377 typedef struct {
378         RPC_BUFFER buffer;
379         uint32 returned;
380         uint32 needed;
381         WERROR status;
382 } SVCCTL_R_QUERY_SERVICE_STATUSEX;
383
384 #endif /* _RPC_SVCCTL_H */
385