2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Gerald Carter 2005.
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.
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;
39 if(!svcctl_io_q_close_service("", &q_u, data, 0))
42 r_u.status = _svcctl_close_service(p, &q_u, &r_u);
44 if(!svcctl_io_r_close_service("", &r_u, rdata, 0))
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;
63 if(!svcctl_io_q_open_scmanager("", &q_u, data, 0))
66 r_u.status = _svcctl_open_scmanager(p, &q_u, &r_u);
68 if(!svcctl_io_r_open_scmanager("", &r_u, rdata, 0))
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;
87 if(!svcctl_io_q_open_service("", &q_u, data, 0))
90 r_u.status = _svcctl_open_service(p, &q_u, &r_u);
92 if(!svcctl_io_r_open_service("", &r_u, rdata, 0))
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;
111 if(!svcctl_io_q_get_display_name("", &q_u, data, 0))
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))
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;
135 if(!svcctl_io_q_query_status("", &q_u, data, 0))
138 r_u.status = _svcctl_query_status(p, &q_u, &r_u);
140 if(!svcctl_io_r_query_status("", &r_u, rdata, 0))
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;
159 if(!svcctl_io_q_enum_services_status("", &q_u, data, 0))
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))
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;
182 if(!svcctl_io_q_query_service_status_ex("", &q_u, data, 0))
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))
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;
205 if(!svcctl_io_q_enum_dependent_services("", &q_u, data, 0))
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))
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;
229 if(!svcctl_io_q_start_service("", &q_u, data, 0))
232 r_u.status = _svcctl_start_service(p, &q_u, &r_u);
234 if(!svcctl_io_r_start_service("", &r_u, rdata, 0))
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;
253 if(!svcctl_io_q_control_service("", &q_u, data, 0))
256 r_u.status = _svcctl_control_service(p, &q_u, &r_u);
258 if(!svcctl_io_r_control_service("", &r_u, rdata, 0))
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;
277 if(!svcctl_io_q_query_service_config("", &q_u, data, 0))
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))
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;
301 if(!svcctl_io_q_query_service_config2("", &q_u, data, 0))
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))
312 /*******************************************************************
313 ********************************************************************/
315 static BOOL api_svcctl_lock_service_db(pipes_struct *p)
317 SVCCTL_Q_LOCK_SERVICE_DB q_u;
318 SVCCTL_R_LOCK_SERVICE_DB r_u;
319 prs_struct *data = &p->in_data.data;
320 prs_struct *rdata = &p->out_data.rdata;
325 if(!svcctl_io_q_lock_service_db("", &q_u, data, 0))
328 r_u.status = _svcctl_lock_service_db(p, &q_u, &r_u);
330 if(!svcctl_io_r_lock_service_db("", &r_u, rdata, 0))
337 /*******************************************************************
338 ********************************************************************/
340 static BOOL api_svcctl_unlock_service_db(pipes_struct *p)
342 SVCCTL_Q_UNLOCK_SERVICE_DB q_u;
343 SVCCTL_R_UNLOCK_SERVICE_DB r_u;
344 prs_struct *data = &p->in_data.data;
345 prs_struct *rdata = &p->out_data.rdata;
350 if(!svcctl_io_q_unlock_service_db("", &q_u, data, 0))
353 r_u.status = _svcctl_unlock_service_db(p, &q_u, &r_u);
355 if(!svcctl_io_r_unlock_service_db("", &r_u, rdata, 0))
362 /*******************************************************************
363 \PIPE\svcctl commands
364 ********************************************************************/
366 static struct api_struct api_svcctl_cmds[] =
368 { "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE , api_svcctl_close_service },
369 { "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W , api_svcctl_open_scmanager },
370 { "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W , api_svcctl_open_service },
371 { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME , api_svcctl_get_display_name },
372 { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS , api_svcctl_query_status },
373 { "SVCCTL_QUERY_SERVICE_CONFIG_W" , SVCCTL_QUERY_SERVICE_CONFIG_W , api_svcctl_query_service_config },
374 { "SVCCTL_QUERY_SERVICE_CONFIG2_W" , SVCCTL_QUERY_SERVICE_CONFIG2_W , api_svcctl_query_service_config2 },
375 { "SVCCTL_ENUM_SERVICES_STATUS_W" , SVCCTL_ENUM_SERVICES_STATUS_W , api_svcctl_enum_services_status },
376 { "SVCCTL_ENUM_DEPENDENT_SERVICES_W" , SVCCTL_ENUM_DEPENDENT_SERVICES_W , api_svcctl_enum_dependent_services },
377 { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W , api_svcctl_start_service },
378 { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service },
379 { "SVCCTL_QUERY_SERVICE_STATUSEX_W" , SVCCTL_QUERY_SERVICE_STATUSEX_W , api_svcctl_query_service_status_ex },
380 { "SVCCTL_LOCK_SERVICE_DB" , SVCCTL_LOCK_SERVICE_DB , api_svcctl_lock_service_db },
381 { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB , api_svcctl_unlock_service_db }
385 void svcctl_get_pipe_fns( struct api_struct **fns, int *n_fns )
387 *fns = api_svcctl_cmds;
388 *n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct);
391 NTSTATUS rpc_svcctl_init(void)
393 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "svcctl", "ntsvcs", api_svcctl_cmds,
394 sizeof(api_svcctl_cmds) / sizeof(struct api_struct));