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/>.
21 #include "librpc/gen_ndr/srv_svcctl.h"
24 #define DBGC_CLASS DBGC_RPC_SRV
26 static bool proxy_svcctl_call(pipes_struct *p, uint8 opnum)
28 struct api_struct *fns;
31 svcctl_get_pipe_fns(&fns, &n_fns);
36 if (fns[opnum].opnum != opnum) {
37 smb_panic("SVCCTL function table not sorted\n");
40 return fns[opnum].fn(p);
44 /*******************************************************************
45 ********************************************************************/
47 static bool api_svcctl_close_service(pipes_struct *p)
49 return proxy_svcctl_call( p, NDR_SVCCTL_CLOSESERVICEHANDLE );
52 /*******************************************************************
53 ********************************************************************/
55 static bool api_svcctl_open_scmanager(pipes_struct *p)
57 return proxy_svcctl_call(p, NDR_SVCCTL_OPENSCMANAGERW);
60 /*******************************************************************
61 ********************************************************************/
63 static bool api_svcctl_open_service(pipes_struct *p)
65 return proxy_svcctl_call(p, NDR_SVCCTL_OPENSERVICEW);
68 /*******************************************************************
69 ********************************************************************/
71 static bool api_svcctl_get_display_name(pipes_struct *p)
73 return proxy_svcctl_call(p, NDR_SVCCTL_GETSERVICEDISPLAYNAMEW);
76 /*******************************************************************
77 ********************************************************************/
79 static bool api_svcctl_query_status(pipes_struct *p)
81 return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICESTATUS);
84 /*******************************************************************
85 ********************************************************************/
87 static bool api_svcctl_enum_services_status(pipes_struct *p)
89 return proxy_svcctl_call(p, NDR_SVCCTL_ENUMSERVICESSTATUSW);
92 /*******************************************************************
93 ********************************************************************/
95 static bool api_svcctl_query_service_status_ex(pipes_struct *p)
97 return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICESTATUSEX);
100 /*******************************************************************
101 ********************************************************************/
103 static bool api_svcctl_enum_dependent_services(pipes_struct *p)
105 return proxy_svcctl_call(p, NDR_SVCCTL_ENUMDEPENDENTSERVICESW);
108 /*******************************************************************
109 ********************************************************************/
111 static bool api_svcctl_start_service(pipes_struct *p)
113 return proxy_svcctl_call(p, NDR_SVCCTL_STARTSERVICEW);
116 /*******************************************************************
117 ********************************************************************/
119 static bool api_svcctl_control_service(pipes_struct *p)
121 return proxy_svcctl_call(p, NDR_SVCCTL_CONTROLSERVICE);
124 /*******************************************************************
125 ********************************************************************/
127 static bool api_svcctl_query_service_config(pipes_struct *p)
129 return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICECONFIGW);
132 /*******************************************************************
133 ********************************************************************/
135 static bool api_svcctl_query_service_config2(pipes_struct *p)
137 return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICECONFIG2W);
140 /*******************************************************************
141 ********************************************************************/
143 static bool api_svcctl_lock_service_db(pipes_struct *p)
145 return proxy_svcctl_call(p, NDR_SVCCTL_LOCKSERVICEDATABASE);
149 /*******************************************************************
150 ********************************************************************/
152 static bool api_svcctl_unlock_service_db(pipes_struct *p)
154 return proxy_svcctl_call(p, NDR_SVCCTL_UNLOCKSERVICEDATABASE);
157 /*******************************************************************
158 ********************************************************************/
160 static bool api_svcctl_query_security_sec(pipes_struct *p)
162 return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICEOBJECTSECURITY);
165 /*******************************************************************
166 ********************************************************************/
168 static bool api_svcctl_set_security_sec(pipes_struct *p)
170 return proxy_svcctl_call(p, NDR_SVCCTL_SETSERVICEOBJECTSECURITY);
174 /*******************************************************************
175 \PIPE\svcctl commands
176 ********************************************************************/
178 static struct api_struct api_svcctl_cmds[] =
180 { "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE , api_svcctl_close_service },
181 { "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W , api_svcctl_open_scmanager },
182 { "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W , api_svcctl_open_service },
183 { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME , api_svcctl_get_display_name },
184 { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS , api_svcctl_query_status },
185 { "SVCCTL_QUERY_SERVICE_CONFIG_W" , SVCCTL_QUERY_SERVICE_CONFIG_W , api_svcctl_query_service_config },
186 { "SVCCTL_QUERY_SERVICE_CONFIG2_W" , SVCCTL_QUERY_SERVICE_CONFIG2_W , api_svcctl_query_service_config2 },
187 { "SVCCTL_ENUM_SERVICES_STATUS_W" , SVCCTL_ENUM_SERVICES_STATUS_W , api_svcctl_enum_services_status },
188 { "SVCCTL_ENUM_DEPENDENT_SERVICES_W" , SVCCTL_ENUM_DEPENDENT_SERVICES_W , api_svcctl_enum_dependent_services },
189 { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W , api_svcctl_start_service },
190 { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service },
191 { "SVCCTL_QUERY_SERVICE_STATUSEX_W" , SVCCTL_QUERY_SERVICE_STATUSEX_W , api_svcctl_query_service_status_ex },
192 { "SVCCTL_LOCK_SERVICE_DB" , SVCCTL_LOCK_SERVICE_DB , api_svcctl_lock_service_db },
193 { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB , api_svcctl_unlock_service_db },
194 { "SVCCTL_QUERY_SERVICE_SEC" , SVCCTL_QUERY_SERVICE_SEC , api_svcctl_query_security_sec },
195 { "SVCCTL_SET_SERVICE_SEC" , SVCCTL_SET_SERVICE_SEC , api_svcctl_set_security_sec }
199 void svcctl2_get_pipe_fns( struct api_struct **fns, int *n_fns )
201 *fns = api_svcctl_cmds;
202 *n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct);
205 NTSTATUS rpc_svcctl2_init(void)
207 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
209 &ndr_table_svcctl.syntax_id,
211 sizeof(api_svcctl_cmds) / sizeof(struct api_struct));