r9038: Revert svn rev 414. Discussed with Jerry and Metze.
[Samba.git] / source / rpc_server / srv_svcctl.c
blob6ba26414d363a0cae3cab341e65a2cb9d828f6ad
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Gerald 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 2 of the License, or
9 * (at your option) any later version.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "includes.h"
23 #undef DBGC_CLASS
24 #define DBGC_CLASS DBGC_RPC_SRV
26 /*******************************************************************
27 ********************************************************************/
29 static BOOL api_svcctl_close_service(pipes_struct *p)
31 SVCCTL_Q_CLOSE_SERVICE q_u;
32 SVCCTL_R_CLOSE_SERVICE r_u;
33 prs_struct *data = &p->in_data.data;
34 prs_struct *rdata = &p->out_data.rdata;
36 ZERO_STRUCT(q_u);
37 ZERO_STRUCT(r_u);
39 if(!svcctl_io_q_close_service("", &q_u, data, 0))
40 return False;
42 r_u.status = _svcctl_close_service(p, &q_u, &r_u);
44 if(!svcctl_io_r_close_service("", &r_u, rdata, 0))
45 return False;
47 return True;
50 /*******************************************************************
51 ********************************************************************/
53 static BOOL api_svcctl_open_scmanager(pipes_struct *p)
55 SVCCTL_Q_OPEN_SCMANAGER q_u;
56 SVCCTL_R_OPEN_SCMANAGER r_u;
57 prs_struct *data = &p->in_data.data;
58 prs_struct *rdata = &p->out_data.rdata;
60 ZERO_STRUCT(q_u);
61 ZERO_STRUCT(r_u);
63 if(!svcctl_io_q_open_scmanager("", &q_u, data, 0))
64 return False;
66 r_u.status = _svcctl_open_scmanager(p, &q_u, &r_u);
68 if(!svcctl_io_r_open_scmanager("", &r_u, rdata, 0))
69 return False;
71 return True;
74 /*******************************************************************
75 ********************************************************************/
77 static BOOL api_svcctl_open_service(pipes_struct *p)
79 SVCCTL_Q_OPEN_SERVICE q_u;
80 SVCCTL_R_OPEN_SERVICE r_u;
81 prs_struct *data = &p->in_data.data;
82 prs_struct *rdata = &p->out_data.rdata;
84 ZERO_STRUCT(q_u);
85 ZERO_STRUCT(r_u);
87 if(!svcctl_io_q_open_service("", &q_u, data, 0))
88 return False;
90 r_u.status = _svcctl_open_service(p, &q_u, &r_u);
92 if(!svcctl_io_r_open_service("", &r_u, rdata, 0))
93 return False;
95 return True;
98 /*******************************************************************
99 ********************************************************************/
101 static BOOL api_svcctl_get_display_name(pipes_struct *p)
103 SVCCTL_Q_GET_DISPLAY_NAME q_u;
104 SVCCTL_R_GET_DISPLAY_NAME r_u;
105 prs_struct *data = &p->in_data.data;
106 prs_struct *rdata = &p->out_data.rdata;
108 ZERO_STRUCT(q_u);
109 ZERO_STRUCT(r_u);
111 if(!svcctl_io_q_get_display_name("", &q_u, data, 0))
112 return False;
114 r_u.status = _svcctl_get_display_name(p, &q_u, &r_u);
116 if(!svcctl_io_r_get_display_name("", &r_u, rdata, 0))
117 return False;
119 return True;
122 /*******************************************************************
123 ********************************************************************/
125 static BOOL api_svcctl_query_status(pipes_struct *p)
127 SVCCTL_Q_QUERY_STATUS q_u;
128 SVCCTL_R_QUERY_STATUS r_u;
129 prs_struct *data = &p->in_data.data;
130 prs_struct *rdata = &p->out_data.rdata;
132 ZERO_STRUCT(q_u);
133 ZERO_STRUCT(r_u);
135 if(!svcctl_io_q_query_status("", &q_u, data, 0))
136 return False;
138 r_u.status = _svcctl_query_status(p, &q_u, &r_u);
140 if(!svcctl_io_r_query_status("", &r_u, rdata, 0))
141 return False;
143 return True;
146 /*******************************************************************
147 ********************************************************************/
149 static BOOL api_svcctl_enum_services_status(pipes_struct *p)
151 SVCCTL_Q_ENUM_SERVICES_STATUS q_u;
152 SVCCTL_R_ENUM_SERVICES_STATUS r_u;
153 prs_struct *data = &p->in_data.data;
154 prs_struct *rdata = &p->out_data.rdata;
156 ZERO_STRUCT(q_u);
157 ZERO_STRUCT(r_u);
159 if(!svcctl_io_q_enum_services_status("", &q_u, data, 0))
160 return False;
162 r_u.status = _svcctl_enum_services_status(p, &q_u, &r_u);
164 if(!svcctl_io_r_enum_services_status("", &r_u, rdata, 0))
165 return False;
167 return True;
169 /*******************************************************************
170 ********************************************************************/
172 static BOOL api_svcctl_query_service_status_ex(pipes_struct *p)
174 SVCCTL_Q_QUERY_SERVICE_STATUSEX q_u;
175 SVCCTL_R_QUERY_SERVICE_STATUSEX r_u;
176 prs_struct *data = &p->in_data.data;
177 prs_struct *rdata = &p->out_data.rdata;
179 ZERO_STRUCT(q_u);
180 ZERO_STRUCT(r_u);
182 if(!svcctl_io_q_query_service_status_ex("", &q_u, data, 0))
183 return False;
185 r_u.status = _svcctl_query_service_status_ex(p, &q_u, &r_u);
187 if(!svcctl_io_r_query_service_status_ex("", &r_u, rdata, 0))
188 return False;
190 return True;
192 /*******************************************************************
193 ********************************************************************/
195 static BOOL api_svcctl_enum_dependent_services(pipes_struct *p)
197 SVCCTL_Q_ENUM_DEPENDENT_SERVICES q_u;
198 SVCCTL_R_ENUM_DEPENDENT_SERVICES r_u;
199 prs_struct *data = &p->in_data.data;
200 prs_struct *rdata = &p->out_data.rdata;
202 ZERO_STRUCT(q_u);
203 ZERO_STRUCT(r_u);
205 if(!svcctl_io_q_enum_dependent_services("", &q_u, data, 0))
206 return False;
208 r_u.status = _svcctl_enum_dependent_services(p, &q_u, &r_u);
210 if(!svcctl_io_r_enum_dependent_services("", &r_u, rdata, 0))
211 return False;
213 return True;
216 /*******************************************************************
217 ********************************************************************/
219 static BOOL api_svcctl_start_service(pipes_struct *p)
221 SVCCTL_Q_START_SERVICE q_u;
222 SVCCTL_R_START_SERVICE r_u;
223 prs_struct *data = &p->in_data.data;
224 prs_struct *rdata = &p->out_data.rdata;
226 ZERO_STRUCT(q_u);
227 ZERO_STRUCT(r_u);
229 if(!svcctl_io_q_start_service("", &q_u, data, 0))
230 return False;
232 r_u.status = _svcctl_start_service(p, &q_u, &r_u);
234 if(!svcctl_io_r_start_service("", &r_u, rdata, 0))
235 return False;
237 return True;
240 /*******************************************************************
241 ********************************************************************/
243 static BOOL api_svcctl_control_service(pipes_struct *p)
245 SVCCTL_Q_CONTROL_SERVICE q_u;
246 SVCCTL_R_CONTROL_SERVICE r_u;
247 prs_struct *data = &p->in_data.data;
248 prs_struct *rdata = &p->out_data.rdata;
250 ZERO_STRUCT(q_u);
251 ZERO_STRUCT(r_u);
253 if(!svcctl_io_q_control_service("", &q_u, data, 0))
254 return False;
256 r_u.status = _svcctl_control_service(p, &q_u, &r_u);
258 if(!svcctl_io_r_control_service("", &r_u, rdata, 0))
259 return False;
261 return True;
264 /*******************************************************************
265 ********************************************************************/
267 static BOOL api_svcctl_query_service_config(pipes_struct *p)
269 SVCCTL_Q_QUERY_SERVICE_CONFIG q_u;
270 SVCCTL_R_QUERY_SERVICE_CONFIG r_u;
271 prs_struct *data = &p->in_data.data;
272 prs_struct *rdata = &p->out_data.rdata;
274 ZERO_STRUCT(q_u);
275 ZERO_STRUCT(r_u);
277 if(!svcctl_io_q_query_service_config("", &q_u, data, 0))
278 return False;
280 r_u.status = _svcctl_query_service_config(p, &q_u, &r_u);
282 if(!svcctl_io_r_query_service_config("", &r_u, rdata, 0))
283 return False;
285 return True;
288 /*******************************************************************
289 ********************************************************************/
291 static BOOL api_svcctl_query_service_config2(pipes_struct *p)
293 SVCCTL_Q_QUERY_SERVICE_CONFIG2 q_u;
294 SVCCTL_R_QUERY_SERVICE_CONFIG2 r_u;
295 prs_struct *data = &p->in_data.data;
296 prs_struct *rdata = &p->out_data.rdata;
298 ZERO_STRUCT(q_u);
299 ZERO_STRUCT(r_u);
301 if(!svcctl_io_q_query_service_config2("", &q_u, data, 0))
302 return False;
304 r_u.status = _svcctl_query_service_config2(p, &q_u, &r_u);
306 if(!svcctl_io_r_query_service_config2("", &r_u, rdata, 0))
307 return False;
309 return True;
312 /*******************************************************************
313 \PIPE\svcctl commands
314 ********************************************************************/
316 static struct api_struct api_svcctl_cmds[] =
318 { "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE , api_svcctl_close_service },
319 { "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W , api_svcctl_open_scmanager },
320 { "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W , api_svcctl_open_service },
321 { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME , api_svcctl_get_display_name },
322 { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS , api_svcctl_query_status },
323 { "SVCCTL_QUERY_SERVICE_CONFIG_W", SVCCTL_QUERY_SERVICE_CONFIG_W, api_svcctl_query_service_config },
324 { "SVCCTL_QUERY_SERVICE_CONFIG2_W", SVCCTL_QUERY_SERVICE_CONFIG2_W, api_svcctl_query_service_config2 },
325 { "SVCCTL_ENUM_SERVICES_STATUS_W", SVCCTL_ENUM_SERVICES_STATUS_W, api_svcctl_enum_services_status },
326 { "SVCCTL_ENUM_DEPENDENT_SERVICES_W", SVCCTL_ENUM_DEPENDENT_SERVICES_W, api_svcctl_enum_dependent_services },
327 { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W , api_svcctl_start_service },
328 { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service },
329 { "SVCCTL_QUERY_SERVICE_STATUSEX_W", SVCCTL_QUERY_SERVICE_STATUSEX_W, api_svcctl_query_service_status_ex }
333 void svcctl_get_pipe_fns( struct api_struct **fns, int *n_fns )
335 *fns = api_svcctl_cmds;
336 *n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct);
339 NTSTATUS rpc_svcctl_init(void)
341 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "svcctl", "ntsvcs", api_svcctl_cmds,
342 sizeof(api_svcctl_cmds) / sizeof(struct api_struct));