2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Gerald Carter 2005 - 2007
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 3 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, see <http://www.gnu.org/licenses/>.
23 #define DBGC_CLASS DBGC_RPC_SRV
25 static bool proxy_svcctl_call(pipes_struct
*p
, uint8 opnum
)
27 struct api_struct
*fns
;
30 svcctl_get_pipe_fns(&fns
, &n_fns
);
35 if (fns
[opnum
].opnum
!= opnum
) {
36 smb_panic("SVCCTL function table not sorted\n");
39 return fns
[opnum
].fn(p
);
43 /*******************************************************************
44 ********************************************************************/
46 static bool api_svcctl_close_service(pipes_struct
*p
)
48 return proxy_svcctl_call( p
, NDR_SVCCTL_CLOSESERVICEHANDLE
);
51 /*******************************************************************
52 ********************************************************************/
54 static bool api_svcctl_open_scmanager(pipes_struct
*p
)
56 SVCCTL_Q_OPEN_SCMANAGER q_u
;
57 SVCCTL_R_OPEN_SCMANAGER r_u
;
58 prs_struct
*data
= &p
->in_data
.data
;
59 prs_struct
*rdata
= &p
->out_data
.rdata
;
64 if(!svcctl_io_q_open_scmanager("", &q_u
, data
, 0))
67 r_u
.status
= _svcctl_open_scmanager(p
, &q_u
, &r_u
);
69 if(!svcctl_io_r_open_scmanager("", &r_u
, rdata
, 0))
75 /*******************************************************************
76 ********************************************************************/
78 static bool api_svcctl_open_service(pipes_struct
*p
)
80 SVCCTL_Q_OPEN_SERVICE q_u
;
81 SVCCTL_R_OPEN_SERVICE r_u
;
82 prs_struct
*data
= &p
->in_data
.data
;
83 prs_struct
*rdata
= &p
->out_data
.rdata
;
88 if(!svcctl_io_q_open_service("", &q_u
, data
, 0))
91 r_u
.status
= _svcctl_open_service(p
, &q_u
, &r_u
);
93 if(!svcctl_io_r_open_service("", &r_u
, rdata
, 0))
99 /*******************************************************************
100 ********************************************************************/
102 static bool api_svcctl_get_display_name(pipes_struct
*p
)
104 SVCCTL_Q_GET_DISPLAY_NAME q_u
;
105 SVCCTL_R_GET_DISPLAY_NAME r_u
;
106 prs_struct
*data
= &p
->in_data
.data
;
107 prs_struct
*rdata
= &p
->out_data
.rdata
;
112 if(!svcctl_io_q_get_display_name("", &q_u
, data
, 0))
115 r_u
.status
= _svcctl_get_display_name(p
, &q_u
, &r_u
);
117 if(!svcctl_io_r_get_display_name("", &r_u
, rdata
, 0))
123 /*******************************************************************
124 ********************************************************************/
126 static bool api_svcctl_query_status(pipes_struct
*p
)
128 SVCCTL_Q_QUERY_STATUS q_u
;
129 SVCCTL_R_QUERY_STATUS r_u
;
130 prs_struct
*data
= &p
->in_data
.data
;
131 prs_struct
*rdata
= &p
->out_data
.rdata
;
136 if(!svcctl_io_q_query_status("", &q_u
, data
, 0))
139 r_u
.status
= _svcctl_query_status(p
, &q_u
, &r_u
);
141 if(!svcctl_io_r_query_status("", &r_u
, rdata
, 0))
147 /*******************************************************************
148 ********************************************************************/
150 static bool api_svcctl_enum_services_status(pipes_struct
*p
)
152 SVCCTL_Q_ENUM_SERVICES_STATUS q_u
;
153 SVCCTL_R_ENUM_SERVICES_STATUS r_u
;
154 prs_struct
*data
= &p
->in_data
.data
;
155 prs_struct
*rdata
= &p
->out_data
.rdata
;
160 if(!svcctl_io_q_enum_services_status("", &q_u
, data
, 0))
163 r_u
.status
= _svcctl_enum_services_status(p
, &q_u
, &r_u
);
165 if(!svcctl_io_r_enum_services_status("", &r_u
, rdata
, 0))
170 /*******************************************************************
171 ********************************************************************/
173 static bool api_svcctl_query_service_status_ex(pipes_struct
*p
)
175 SVCCTL_Q_QUERY_SERVICE_STATUSEX q_u
;
176 SVCCTL_R_QUERY_SERVICE_STATUSEX r_u
;
177 prs_struct
*data
= &p
->in_data
.data
;
178 prs_struct
*rdata
= &p
->out_data
.rdata
;
183 if(!svcctl_io_q_query_service_status_ex("", &q_u
, data
, 0))
186 r_u
.status
= _svcctl_query_service_status_ex(p
, &q_u
, &r_u
);
188 if(!svcctl_io_r_query_service_status_ex("", &r_u
, rdata
, 0))
193 /*******************************************************************
194 ********************************************************************/
196 static bool api_svcctl_enum_dependent_services(pipes_struct
*p
)
198 SVCCTL_Q_ENUM_DEPENDENT_SERVICES q_u
;
199 SVCCTL_R_ENUM_DEPENDENT_SERVICES r_u
;
200 prs_struct
*data
= &p
->in_data
.data
;
201 prs_struct
*rdata
= &p
->out_data
.rdata
;
206 if(!svcctl_io_q_enum_dependent_services("", &q_u
, data
, 0))
209 r_u
.status
= _svcctl_enum_dependent_services(p
, &q_u
, &r_u
);
211 if(!svcctl_io_r_enum_dependent_services("", &r_u
, rdata
, 0))
217 /*******************************************************************
218 ********************************************************************/
220 static bool api_svcctl_start_service(pipes_struct
*p
)
222 SVCCTL_Q_START_SERVICE q_u
;
223 SVCCTL_R_START_SERVICE r_u
;
224 prs_struct
*data
= &p
->in_data
.data
;
225 prs_struct
*rdata
= &p
->out_data
.rdata
;
230 if(!svcctl_io_q_start_service("", &q_u
, data
, 0))
233 r_u
.status
= _svcctl_start_service(p
, &q_u
, &r_u
);
235 if(!svcctl_io_r_start_service("", &r_u
, rdata
, 0))
241 /*******************************************************************
242 ********************************************************************/
244 static bool api_svcctl_control_service(pipes_struct
*p
)
246 SVCCTL_Q_CONTROL_SERVICE q_u
;
247 SVCCTL_R_CONTROL_SERVICE r_u
;
248 prs_struct
*data
= &p
->in_data
.data
;
249 prs_struct
*rdata
= &p
->out_data
.rdata
;
254 if(!svcctl_io_q_control_service("", &q_u
, data
, 0))
257 r_u
.status
= _svcctl_control_service(p
, &q_u
, &r_u
);
259 if(!svcctl_io_r_control_service("", &r_u
, rdata
, 0))
265 /*******************************************************************
266 ********************************************************************/
268 static bool api_svcctl_query_service_config(pipes_struct
*p
)
270 SVCCTL_Q_QUERY_SERVICE_CONFIG q_u
;
271 SVCCTL_R_QUERY_SERVICE_CONFIG r_u
;
272 prs_struct
*data
= &p
->in_data
.data
;
273 prs_struct
*rdata
= &p
->out_data
.rdata
;
278 if(!svcctl_io_q_query_service_config("", &q_u
, data
, 0))
281 r_u
.status
= _svcctl_query_service_config(p
, &q_u
, &r_u
);
283 if(!svcctl_io_r_query_service_config("", &r_u
, rdata
, 0))
289 /*******************************************************************
290 ********************************************************************/
292 static bool api_svcctl_query_service_config2(pipes_struct
*p
)
294 SVCCTL_Q_QUERY_SERVICE_CONFIG2 q_u
;
295 SVCCTL_R_QUERY_SERVICE_CONFIG2 r_u
;
296 prs_struct
*data
= &p
->in_data
.data
;
297 prs_struct
*rdata
= &p
->out_data
.rdata
;
302 if(!svcctl_io_q_query_service_config2("", &q_u
, data
, 0))
305 r_u
.status
= _svcctl_query_service_config2(p
, &q_u
, &r_u
);
307 if(!svcctl_io_r_query_service_config2("", &r_u
, rdata
, 0))
313 /*******************************************************************
314 ********************************************************************/
316 static bool api_svcctl_lock_service_db(pipes_struct
*p
)
318 SVCCTL_Q_LOCK_SERVICE_DB q_u
;
319 SVCCTL_R_LOCK_SERVICE_DB r_u
;
320 prs_struct
*data
= &p
->in_data
.data
;
321 prs_struct
*rdata
= &p
->out_data
.rdata
;
326 if(!svcctl_io_q_lock_service_db("", &q_u
, data
, 0))
329 r_u
.status
= _svcctl_lock_service_db(p
, &q_u
, &r_u
);
331 if(!svcctl_io_r_lock_service_db("", &r_u
, rdata
, 0))
338 /*******************************************************************
339 ********************************************************************/
341 static bool api_svcctl_unlock_service_db(pipes_struct
*p
)
343 SVCCTL_Q_UNLOCK_SERVICE_DB q_u
;
344 SVCCTL_R_UNLOCK_SERVICE_DB r_u
;
345 prs_struct
*data
= &p
->in_data
.data
;
346 prs_struct
*rdata
= &p
->out_data
.rdata
;
351 if(!svcctl_io_q_unlock_service_db("", &q_u
, data
, 0))
354 r_u
.status
= _svcctl_unlock_service_db(p
, &q_u
, &r_u
);
356 if(!svcctl_io_r_unlock_service_db("", &r_u
, rdata
, 0))
362 /*******************************************************************
363 ********************************************************************/
365 static bool api_svcctl_query_security_sec(pipes_struct
*p
)
367 SVCCTL_Q_QUERY_SERVICE_SEC q_u
;
368 SVCCTL_R_QUERY_SERVICE_SEC r_u
;
369 prs_struct
*data
= &p
->in_data
.data
;
370 prs_struct
*rdata
= &p
->out_data
.rdata
;
375 if(!svcctl_io_q_query_service_sec("", &q_u
, data
, 0))
378 r_u
.status
= _svcctl_query_service_sec(p
, &q_u
, &r_u
);
380 if(!svcctl_io_r_query_service_sec("", &r_u
, rdata
, 0))
386 /*******************************************************************
387 ********************************************************************/
389 static bool api_svcctl_set_security_sec(pipes_struct
*p
)
391 SVCCTL_Q_SET_SERVICE_SEC q_u
;
392 SVCCTL_R_SET_SERVICE_SEC r_u
;
393 prs_struct
*data
= &p
->in_data
.data
;
394 prs_struct
*rdata
= &p
->out_data
.rdata
;
399 if(!svcctl_io_q_set_service_sec("", &q_u
, data
, 0))
402 r_u
.status
= _svcctl_set_service_sec(p
, &q_u
, &r_u
);
404 if(!svcctl_io_r_set_service_sec("", &r_u
, rdata
, 0))
411 /*******************************************************************
412 \PIPE\svcctl commands
413 ********************************************************************/
415 static struct api_struct api_svcctl_cmds
[] =
417 { "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE
, api_svcctl_close_service
},
418 { "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W
, api_svcctl_open_scmanager
},
419 { "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W
, api_svcctl_open_service
},
420 { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME
, api_svcctl_get_display_name
},
421 { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS
, api_svcctl_query_status
},
422 { "SVCCTL_QUERY_SERVICE_CONFIG_W" , SVCCTL_QUERY_SERVICE_CONFIG_W
, api_svcctl_query_service_config
},
423 { "SVCCTL_QUERY_SERVICE_CONFIG2_W" , SVCCTL_QUERY_SERVICE_CONFIG2_W
, api_svcctl_query_service_config2
},
424 { "SVCCTL_ENUM_SERVICES_STATUS_W" , SVCCTL_ENUM_SERVICES_STATUS_W
, api_svcctl_enum_services_status
},
425 { "SVCCTL_ENUM_DEPENDENT_SERVICES_W" , SVCCTL_ENUM_DEPENDENT_SERVICES_W
, api_svcctl_enum_dependent_services
},
426 { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W
, api_svcctl_start_service
},
427 { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE
, api_svcctl_control_service
},
428 { "SVCCTL_QUERY_SERVICE_STATUSEX_W" , SVCCTL_QUERY_SERVICE_STATUSEX_W
, api_svcctl_query_service_status_ex
},
429 { "SVCCTL_LOCK_SERVICE_DB" , SVCCTL_LOCK_SERVICE_DB
, api_svcctl_lock_service_db
},
430 { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB
, api_svcctl_unlock_service_db
},
431 { "SVCCTL_QUERY_SERVICE_SEC" , SVCCTL_QUERY_SERVICE_SEC
, api_svcctl_query_security_sec
},
432 { "SVCCTL_SET_SERVICE_SEC" , SVCCTL_SET_SERVICE_SEC
, api_svcctl_set_security_sec
}
436 void svcctl2_get_pipe_fns( struct api_struct
**fns
, int *n_fns
)
438 *fns
= api_svcctl_cmds
;
439 *n_fns
= sizeof(api_svcctl_cmds
) / sizeof(struct api_struct
);
442 NTSTATUS
rpc_svcctl2_init(void)
444 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION
,
445 "svcctl", "ntsvcs", api_svcctl_cmds
,
446 sizeof(api_svcctl_cmds
) / sizeof(struct api_struct
));