1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
/*
* Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
* Copyright (C) Gerald Carter 2005 - 2007
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
static bool proxy_svcctl_call(pipes_struct *p, uint8 opnum)
{
struct api_struct *fns;
int n_fns;
svcctl_get_pipe_fns(&fns, &n_fns);
if (opnum >= n_fns)
return False;
if (fns[opnum].opnum != opnum) {
smb_panic("SVCCTL function table not sorted\n");
}
return fns[opnum].fn(p);
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_close_service(pipes_struct *p)
{
return proxy_svcctl_call( p, NDR_SVCCTL_CLOSESERVICEHANDLE );
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_open_scmanager(pipes_struct *p)
{
SVCCTL_Q_OPEN_SCMANAGER q_u;
SVCCTL_R_OPEN_SCMANAGER r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_open_scmanager("", &q_u, data, 0))
return False;
r_u.status = _svcctl_open_scmanager(p, &q_u, &r_u);
if(!svcctl_io_r_open_scmanager("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_open_service(pipes_struct *p)
{
SVCCTL_Q_OPEN_SERVICE q_u;
SVCCTL_R_OPEN_SERVICE r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_open_service("", &q_u, data, 0))
return False;
r_u.status = _svcctl_open_service(p, &q_u, &r_u);
if(!svcctl_io_r_open_service("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_get_display_name(pipes_struct *p)
{
SVCCTL_Q_GET_DISPLAY_NAME q_u;
SVCCTL_R_GET_DISPLAY_NAME r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_get_display_name("", &q_u, data, 0))
return False;
r_u.status = _svcctl_get_display_name(p, &q_u, &r_u);
if(!svcctl_io_r_get_display_name("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_query_status(pipes_struct *p)
{
SVCCTL_Q_QUERY_STATUS q_u;
SVCCTL_R_QUERY_STATUS r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_query_status("", &q_u, data, 0))
return False;
r_u.status = _svcctl_query_status(p, &q_u, &r_u);
if(!svcctl_io_r_query_status("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_enum_services_status(pipes_struct *p)
{
SVCCTL_Q_ENUM_SERVICES_STATUS q_u;
SVCCTL_R_ENUM_SERVICES_STATUS r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_enum_services_status("", &q_u, data, 0))
return False;
r_u.status = _svcctl_enum_services_status(p, &q_u, &r_u);
if(!svcctl_io_r_enum_services_status("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_query_service_status_ex(pipes_struct *p)
{
SVCCTL_Q_QUERY_SERVICE_STATUSEX q_u;
SVCCTL_R_QUERY_SERVICE_STATUSEX r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_query_service_status_ex("", &q_u, data, 0))
return False;
r_u.status = _svcctl_query_service_status_ex(p, &q_u, &r_u);
if(!svcctl_io_r_query_service_status_ex("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_enum_dependent_services(pipes_struct *p)
{
SVCCTL_Q_ENUM_DEPENDENT_SERVICES q_u;
SVCCTL_R_ENUM_DEPENDENT_SERVICES r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_enum_dependent_services("", &q_u, data, 0))
return False;
r_u.status = _svcctl_enum_dependent_services(p, &q_u, &r_u);
if(!svcctl_io_r_enum_dependent_services("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_start_service(pipes_struct *p)
{
SVCCTL_Q_START_SERVICE q_u;
SVCCTL_R_START_SERVICE r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_start_service("", &q_u, data, 0))
return False;
r_u.status = _svcctl_start_service(p, &q_u, &r_u);
if(!svcctl_io_r_start_service("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_control_service(pipes_struct *p)
{
SVCCTL_Q_CONTROL_SERVICE q_u;
SVCCTL_R_CONTROL_SERVICE r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_control_service("", &q_u, data, 0))
return False;
r_u.status = _svcctl_control_service(p, &q_u, &r_u);
if(!svcctl_io_r_control_service("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_query_service_config(pipes_struct *p)
{
SVCCTL_Q_QUERY_SERVICE_CONFIG q_u;
SVCCTL_R_QUERY_SERVICE_CONFIG r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_query_service_config("", &q_u, data, 0))
return False;
r_u.status = _svcctl_query_service_config(p, &q_u, &r_u);
if(!svcctl_io_r_query_service_config("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_query_service_config2(pipes_struct *p)
{
SVCCTL_Q_QUERY_SERVICE_CONFIG2 q_u;
SVCCTL_R_QUERY_SERVICE_CONFIG2 r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_query_service_config2("", &q_u, data, 0))
return False;
r_u.status = _svcctl_query_service_config2(p, &q_u, &r_u);
if(!svcctl_io_r_query_service_config2("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_lock_service_db(pipes_struct *p)
{
SVCCTL_Q_LOCK_SERVICE_DB q_u;
SVCCTL_R_LOCK_SERVICE_DB r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_lock_service_db("", &q_u, data, 0))
return False;
r_u.status = _svcctl_lock_service_db(p, &q_u, &r_u);
if(!svcctl_io_r_lock_service_db("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_unlock_service_db(pipes_struct *p)
{
SVCCTL_Q_UNLOCK_SERVICE_DB q_u;
SVCCTL_R_UNLOCK_SERVICE_DB r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_unlock_service_db("", &q_u, data, 0))
return False;
r_u.status = _svcctl_unlock_service_db(p, &q_u, &r_u);
if(!svcctl_io_r_unlock_service_db("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_query_security_sec(pipes_struct *p)
{
SVCCTL_Q_QUERY_SERVICE_SEC q_u;
SVCCTL_R_QUERY_SERVICE_SEC r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_query_service_sec("", &q_u, data, 0))
return False;
r_u.status = _svcctl_query_service_sec(p, &q_u, &r_u);
if(!svcctl_io_r_query_service_sec("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
********************************************************************/
static bool api_svcctl_set_security_sec(pipes_struct *p)
{
SVCCTL_Q_SET_SERVICE_SEC q_u;
SVCCTL_R_SET_SERVICE_SEC r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_set_service_sec("", &q_u, data, 0))
return False;
r_u.status = _svcctl_set_service_sec(p, &q_u, &r_u);
if(!svcctl_io_r_set_service_sec("", &r_u, rdata, 0))
return False;
return True;
}
/*******************************************************************
\PIPE\svcctl commands
********************************************************************/
static struct api_struct api_svcctl_cmds[] =
{
{ "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE , api_svcctl_close_service },
{ "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W , api_svcctl_open_scmanager },
{ "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W , api_svcctl_open_service },
{ "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME , api_svcctl_get_display_name },
{ "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS , api_svcctl_query_status },
{ "SVCCTL_QUERY_SERVICE_CONFIG_W" , SVCCTL_QUERY_SERVICE_CONFIG_W , api_svcctl_query_service_config },
{ "SVCCTL_QUERY_SERVICE_CONFIG2_W" , SVCCTL_QUERY_SERVICE_CONFIG2_W , api_svcctl_query_service_config2 },
{ "SVCCTL_ENUM_SERVICES_STATUS_W" , SVCCTL_ENUM_SERVICES_STATUS_W , api_svcctl_enum_services_status },
{ "SVCCTL_ENUM_DEPENDENT_SERVICES_W" , SVCCTL_ENUM_DEPENDENT_SERVICES_W , api_svcctl_enum_dependent_services },
{ "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W , api_svcctl_start_service },
{ "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service },
{ "SVCCTL_QUERY_SERVICE_STATUSEX_W" , SVCCTL_QUERY_SERVICE_STATUSEX_W , api_svcctl_query_service_status_ex },
{ "SVCCTL_LOCK_SERVICE_DB" , SVCCTL_LOCK_SERVICE_DB , api_svcctl_lock_service_db },
{ "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB , api_svcctl_unlock_service_db },
{ "SVCCTL_QUERY_SERVICE_SEC" , SVCCTL_QUERY_SERVICE_SEC , api_svcctl_query_security_sec },
{ "SVCCTL_SET_SERVICE_SEC" , SVCCTL_SET_SERVICE_SEC , api_svcctl_set_security_sec }
};
void svcctl2_get_pipe_fns( struct api_struct **fns, int *n_fns )
{
*fns = api_svcctl_cmds;
*n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct);
}
NTSTATUS rpc_svcctl2_init(void)
{
return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
"svcctl", "ntsvcs", api_svcctl_cmds,
sizeof(api_svcctl_cmds) / sizeof(struct api_struct));
}
|