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 return proxy_svcctl_call(p
, NDR_SVCCTL_OPENSCMANAGERW
);
59 /*******************************************************************
60 ********************************************************************/
62 static bool api_svcctl_open_service(pipes_struct
*p
)
64 return proxy_svcctl_call(p
, NDR_SVCCTL_OPENSERVICEW
);
67 /*******************************************************************
68 ********************************************************************/
70 static bool api_svcctl_get_display_name(pipes_struct
*p
)
72 return proxy_svcctl_call(p
, NDR_SVCCTL_GETSERVICEDISPLAYNAMEW
);
75 /*******************************************************************
76 ********************************************************************/
78 static bool api_svcctl_query_status(pipes_struct
*p
)
80 return proxy_svcctl_call(p
, NDR_SVCCTL_QUERYSERVICESTATUS
);
83 /*******************************************************************
84 ********************************************************************/
86 static bool api_svcctl_enum_services_status(pipes_struct
*p
)
88 SVCCTL_Q_ENUM_SERVICES_STATUS q_u
;
89 SVCCTL_R_ENUM_SERVICES_STATUS r_u
;
90 prs_struct
*data
= &p
->in_data
.data
;
91 prs_struct
*rdata
= &p
->out_data
.rdata
;
96 if(!svcctl_io_q_enum_services_status("", &q_u
, data
, 0))
99 r_u
.status
= _svcctl_enum_services_status(p
, &q_u
, &r_u
);
101 if(!svcctl_io_r_enum_services_status("", &r_u
, rdata
, 0))
106 /*******************************************************************
107 ********************************************************************/
109 static bool api_svcctl_query_service_status_ex(pipes_struct
*p
)
111 SVCCTL_Q_QUERY_SERVICE_STATUSEX q_u
;
112 SVCCTL_R_QUERY_SERVICE_STATUSEX r_u
;
113 prs_struct
*data
= &p
->in_data
.data
;
114 prs_struct
*rdata
= &p
->out_data
.rdata
;
119 if(!svcctl_io_q_query_service_status_ex("", &q_u
, data
, 0))
122 r_u
.status
= _svcctl_query_service_status_ex(p
, &q_u
, &r_u
);
124 if(!svcctl_io_r_query_service_status_ex("", &r_u
, rdata
, 0))
129 /*******************************************************************
130 ********************************************************************/
132 static bool api_svcctl_enum_dependent_services(pipes_struct
*p
)
134 return proxy_svcctl_call(p
, NDR_SVCCTL_ENUMDEPENDENTSERVICESW
);
137 /*******************************************************************
138 ********************************************************************/
140 static bool api_svcctl_start_service(pipes_struct
*p
)
142 return proxy_svcctl_call(p
, NDR_SVCCTL_STARTSERVICEW
);
145 /*******************************************************************
146 ********************************************************************/
148 static bool api_svcctl_control_service(pipes_struct
*p
)
150 return proxy_svcctl_call(p
, NDR_SVCCTL_CONTROLSERVICE
);
153 /*******************************************************************
154 ********************************************************************/
156 static bool api_svcctl_query_service_config(pipes_struct
*p
)
158 SVCCTL_Q_QUERY_SERVICE_CONFIG q_u
;
159 SVCCTL_R_QUERY_SERVICE_CONFIG r_u
;
160 prs_struct
*data
= &p
->in_data
.data
;
161 prs_struct
*rdata
= &p
->out_data
.rdata
;
166 if(!svcctl_io_q_query_service_config("", &q_u
, data
, 0))
169 r_u
.status
= _svcctl_query_service_config(p
, &q_u
, &r_u
);
171 if(!svcctl_io_r_query_service_config("", &r_u
, rdata
, 0))
177 /*******************************************************************
178 ********************************************************************/
180 static bool api_svcctl_query_service_config2(pipes_struct
*p
)
182 SVCCTL_Q_QUERY_SERVICE_CONFIG2 q_u
;
183 SVCCTL_R_QUERY_SERVICE_CONFIG2 r_u
;
184 prs_struct
*data
= &p
->in_data
.data
;
185 prs_struct
*rdata
= &p
->out_data
.rdata
;
190 if(!svcctl_io_q_query_service_config2("", &q_u
, data
, 0))
193 r_u
.status
= _svcctl_query_service_config2(p
, &q_u
, &r_u
);
195 if(!svcctl_io_r_query_service_config2("", &r_u
, rdata
, 0))
201 /*******************************************************************
202 ********************************************************************/
204 static bool api_svcctl_lock_service_db(pipes_struct
*p
)
206 return proxy_svcctl_call(p
, NDR_SVCCTL_LOCKSERVICEDATABASE
);
210 /*******************************************************************
211 ********************************************************************/
213 static bool api_svcctl_unlock_service_db(pipes_struct
*p
)
215 return proxy_svcctl_call(p
, NDR_SVCCTL_UNLOCKSERVICEDATABASE
);
218 /*******************************************************************
219 ********************************************************************/
221 static bool api_svcctl_query_security_sec(pipes_struct
*p
)
223 return proxy_svcctl_call(p
, NDR_SVCCTL_QUERYSERVICEOBJECTSECURITY
);
226 /*******************************************************************
227 ********************************************************************/
229 static bool api_svcctl_set_security_sec(pipes_struct
*p
)
231 return proxy_svcctl_call(p
, NDR_SVCCTL_SETSERVICEOBJECTSECURITY
);
235 /*******************************************************************
236 \PIPE\svcctl commands
237 ********************************************************************/
239 static struct api_struct api_svcctl_cmds
[] =
241 { "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE
, api_svcctl_close_service
},
242 { "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W
, api_svcctl_open_scmanager
},
243 { "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W
, api_svcctl_open_service
},
244 { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME
, api_svcctl_get_display_name
},
245 { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS
, api_svcctl_query_status
},
246 { "SVCCTL_QUERY_SERVICE_CONFIG_W" , SVCCTL_QUERY_SERVICE_CONFIG_W
, api_svcctl_query_service_config
},
247 { "SVCCTL_QUERY_SERVICE_CONFIG2_W" , SVCCTL_QUERY_SERVICE_CONFIG2_W
, api_svcctl_query_service_config2
},
248 { "SVCCTL_ENUM_SERVICES_STATUS_W" , SVCCTL_ENUM_SERVICES_STATUS_W
, api_svcctl_enum_services_status
},
249 { "SVCCTL_ENUM_DEPENDENT_SERVICES_W" , SVCCTL_ENUM_DEPENDENT_SERVICES_W
, api_svcctl_enum_dependent_services
},
250 { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W
, api_svcctl_start_service
},
251 { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE
, api_svcctl_control_service
},
252 { "SVCCTL_QUERY_SERVICE_STATUSEX_W" , SVCCTL_QUERY_SERVICE_STATUSEX_W
, api_svcctl_query_service_status_ex
},
253 { "SVCCTL_LOCK_SERVICE_DB" , SVCCTL_LOCK_SERVICE_DB
, api_svcctl_lock_service_db
},
254 { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB
, api_svcctl_unlock_service_db
},
255 { "SVCCTL_QUERY_SERVICE_SEC" , SVCCTL_QUERY_SERVICE_SEC
, api_svcctl_query_security_sec
},
256 { "SVCCTL_SET_SERVICE_SEC" , SVCCTL_SET_SERVICE_SEC
, api_svcctl_set_security_sec
}
260 void svcctl2_get_pipe_fns( struct api_struct
**fns
, int *n_fns
)
262 *fns
= api_svcctl_cmds
;
263 *n_fns
= sizeof(api_svcctl_cmds
) / sizeof(struct api_struct
);
266 NTSTATUS
rpc_svcctl2_init(void)
268 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION
,
270 &ndr_table_svcctl
.syntax_id
,
272 sizeof(api_svcctl_cmds
) / sizeof(struct api_struct
));