s3-svcctl: use pidl for _svcctl_EnumServicesStatusW.
[metze/samba/wip.git] / source3 / rpc_server / srv_svcctl.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Gerald Carter                   2005 - 2007
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 3 of the License, or
9  *  (at your option) any later version.
10  *  
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.
15  *  
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/>.
18  */
19
20 #include "includes.h"
21 #include "librpc/gen_ndr/srv_svcctl.h"
22
23 #undef DBGC_CLASS
24 #define DBGC_CLASS DBGC_RPC_SRV
25
26 static bool proxy_svcctl_call(pipes_struct *p, uint8 opnum)
27 {
28         struct api_struct *fns;
29         int n_fns;
30
31         svcctl_get_pipe_fns(&fns, &n_fns);
32
33         if (opnum >= n_fns)
34                 return False;
35
36         if (fns[opnum].opnum != opnum) {
37                 smb_panic("SVCCTL function table not sorted\n");
38         }
39
40         return fns[opnum].fn(p);
41 }
42
43
44 /*******************************************************************
45  ********************************************************************/
46
47 static bool api_svcctl_close_service(pipes_struct *p)
48 {
49         return proxy_svcctl_call( p, NDR_SVCCTL_CLOSESERVICEHANDLE );
50 }
51
52 /*******************************************************************
53  ********************************************************************/
54
55 static bool api_svcctl_open_scmanager(pipes_struct *p)
56 {
57         return proxy_svcctl_call(p, NDR_SVCCTL_OPENSCMANAGERW);
58 }
59
60 /*******************************************************************
61  ********************************************************************/
62
63 static bool api_svcctl_open_service(pipes_struct *p)
64 {
65         return proxy_svcctl_call(p, NDR_SVCCTL_OPENSERVICEW);
66 }
67
68 /*******************************************************************
69  ********************************************************************/
70
71 static bool api_svcctl_get_display_name(pipes_struct *p)
72 {
73         return proxy_svcctl_call(p, NDR_SVCCTL_GETSERVICEDISPLAYNAMEW);
74 }
75
76 /*******************************************************************
77  ********************************************************************/
78
79 static bool api_svcctl_query_status(pipes_struct *p)
80 {
81         return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICESTATUS);
82 }
83
84 /*******************************************************************
85  ********************************************************************/
86
87 static bool api_svcctl_enum_services_status(pipes_struct *p)
88 {
89         return proxy_svcctl_call(p, NDR_SVCCTL_ENUMSERVICESSTATUSW);
90 }
91
92 /*******************************************************************
93  ********************************************************************/
94
95 static bool api_svcctl_query_service_status_ex(pipes_struct *p)
96 {
97         return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICESTATUSEX);
98 }
99
100 /*******************************************************************
101  ********************************************************************/
102
103 static bool api_svcctl_enum_dependent_services(pipes_struct *p)
104 {
105         return proxy_svcctl_call(p, NDR_SVCCTL_ENUMDEPENDENTSERVICESW);
106 }
107
108 /*******************************************************************
109  ********************************************************************/
110
111 static bool api_svcctl_start_service(pipes_struct *p)
112 {
113         return proxy_svcctl_call(p, NDR_SVCCTL_STARTSERVICEW);
114 }
115
116 /*******************************************************************
117  ********************************************************************/
118
119 static bool api_svcctl_control_service(pipes_struct *p)
120 {
121         return proxy_svcctl_call(p, NDR_SVCCTL_CONTROLSERVICE);
122 }
123
124 /*******************************************************************
125  ********************************************************************/
126
127 static bool api_svcctl_query_service_config(pipes_struct *p)
128 {
129         return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICECONFIGW);
130 }
131
132 /*******************************************************************
133  ********************************************************************/
134
135 static bool api_svcctl_query_service_config2(pipes_struct *p)
136 {
137         return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICECONFIG2W);
138 }
139
140 /*******************************************************************
141  ********************************************************************/
142
143 static bool api_svcctl_lock_service_db(pipes_struct *p)
144 {
145         return proxy_svcctl_call(p, NDR_SVCCTL_LOCKSERVICEDATABASE);
146 }
147
148
149 /*******************************************************************
150  ********************************************************************/
151
152 static bool api_svcctl_unlock_service_db(pipes_struct *p)
153 {
154         return proxy_svcctl_call(p, NDR_SVCCTL_UNLOCKSERVICEDATABASE);
155 }
156
157 /*******************************************************************
158  ********************************************************************/
159
160 static bool api_svcctl_query_security_sec(pipes_struct *p)
161 {
162         return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICEOBJECTSECURITY);
163 }
164
165 /*******************************************************************
166  ********************************************************************/
167
168 static bool api_svcctl_set_security_sec(pipes_struct *p)
169 {
170         return proxy_svcctl_call(p, NDR_SVCCTL_SETSERVICEOBJECTSECURITY);
171 }
172
173
174 /*******************************************************************
175  \PIPE\svcctl commands
176  ********************************************************************/
177
178 static struct api_struct api_svcctl_cmds[] =
179 {
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 }
196 };
197
198
199 void svcctl2_get_pipe_fns( struct api_struct **fns, int *n_fns )
200 {
201         *fns = api_svcctl_cmds;
202         *n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct);
203 }
204
205 NTSTATUS rpc_svcctl2_init(void)
206 {
207         return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
208                                           "svcctl", "ntsvcs",
209                                           &ndr_table_svcctl.syntax_id,
210                                           api_svcctl_cmds,
211                                           sizeof(api_svcctl_cmds) / sizeof(struct api_struct));
212 }