fix restart option (noticed by Stanford K. Baldwin)
[Samba.git] / source / rpc_server / srv_lsa.c
blobec7fb8f5e1a1a5839263fda0dc8831f17822b2d0
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
8 * Copyright (C) Jeremy Allison 2001.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* This is the interface to the lsa server code. */
27 #include "includes.h"
29 /***************************************************************************
30 api_lsa_open_policy2
31 ***************************************************************************/
33 static BOOL api_lsa_open_policy2(pipes_struct *p)
35 LSA_Q_OPEN_POL2 q_u;
36 LSA_R_OPEN_POL2 r_u;
37 prs_struct *data = &p->in_data.data;
38 prs_struct *rdata = &p->out_data.rdata;
40 ZERO_STRUCT(q_u);
41 ZERO_STRUCT(r_u);
43 /* grab the server, object attributes and desired access flag...*/
44 if(!lsa_io_q_open_pol2("", &q_u, data, 0)) {
45 DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n"));
46 return False;
49 r_u.status = _lsa_open_policy2(p, &q_u, &r_u);
51 /* store the response in the SMB stream */
52 if(!lsa_io_r_open_pol2("", &r_u, rdata, 0)) {
53 DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n"));
54 return False;
57 return True;
60 /***************************************************************************
61 api_lsa_open_policy
62 ***************************************************************************/
64 static BOOL api_lsa_open_policy(pipes_struct *p)
66 LSA_Q_OPEN_POL q_u;
67 LSA_R_OPEN_POL r_u;
68 prs_struct *data = &p->in_data.data;
69 prs_struct *rdata = &p->out_data.rdata;
71 ZERO_STRUCT(q_u);
72 ZERO_STRUCT(r_u);
74 /* grab the server, object attributes and desired access flag...*/
75 if(!lsa_io_q_open_pol("", &q_u, data, 0)) {
76 DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n"));
77 return False;
80 r_u.status = _lsa_open_policy(p, &q_u, &r_u);
82 /* store the response in the SMB stream */
83 if(!lsa_io_r_open_pol("", &r_u, rdata, 0)) {
84 DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n"));
85 return False;
88 return True;
91 /***************************************************************************
92 api_lsa_enum_trust_dom
93 ***************************************************************************/
95 static BOOL api_lsa_enum_trust_dom(pipes_struct *p)
97 LSA_Q_ENUM_TRUST_DOM q_u;
98 LSA_R_ENUM_TRUST_DOM r_u;
99 prs_struct *data = &p->in_data.data;
100 prs_struct *rdata = &p->out_data.rdata;
102 ZERO_STRUCT(q_u);
103 ZERO_STRUCT(r_u);
105 /* grab the enum trust domain context etc. */
106 if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0))
107 return False;
109 r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u);
111 if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0))
112 return False;
114 return True;
117 /***************************************************************************
118 api_lsa_query_info
119 ***************************************************************************/
121 static BOOL api_lsa_query_info(pipes_struct *p)
123 LSA_Q_QUERY_INFO q_u;
124 LSA_R_QUERY_INFO r_u;
125 prs_struct *data = &p->in_data.data;
126 prs_struct *rdata = &p->out_data.rdata;
128 ZERO_STRUCT(q_u);
129 ZERO_STRUCT(r_u);
131 /* grab the info class and policy handle */
132 if(!lsa_io_q_query("", &q_u, data, 0)) {
133 DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n"));
134 return False;
137 r_u.status = _lsa_query_info(p, &q_u, &r_u);
139 /* store the response in the SMB stream */
140 if(!lsa_io_r_query("", &r_u, rdata, 0)) {
141 DEBUG(0,("api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO.\n"));
142 return False;
145 return True;
148 /***************************************************************************
149 api_lsa_lookup_sids
150 ***************************************************************************/
152 static BOOL api_lsa_lookup_sids(pipes_struct *p)
154 LSA_Q_LOOKUP_SIDS q_u;
155 LSA_R_LOOKUP_SIDS r_u;
156 prs_struct *data = &p->in_data.data;
157 prs_struct *rdata = &p->out_data.rdata;
159 ZERO_STRUCT(q_u);
160 ZERO_STRUCT(r_u);
162 /* grab the info class and policy handle */
163 if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) {
164 DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n"));
165 return False;
168 r_u.status = _lsa_lookup_sids(p, &q_u, &r_u);
170 if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) {
171 DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n"));
172 return False;
175 return True;
178 /***************************************************************************
179 api_lsa_lookup_names
180 ***************************************************************************/
182 static BOOL api_lsa_lookup_names(pipes_struct *p)
184 LSA_Q_LOOKUP_NAMES q_u;
185 LSA_R_LOOKUP_NAMES r_u;
186 prs_struct *data = &p->in_data.data;
187 prs_struct *rdata = &p->out_data.rdata;
189 ZERO_STRUCT(q_u);
190 ZERO_STRUCT(r_u);
192 /* grab the info class and policy handle */
193 if(!lsa_io_q_lookup_names("", &q_u, data, 0)) {
194 DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n"));
195 return False;
198 r_u.status = _lsa_lookup_names(p, &q_u, &r_u);
200 /* store the response in the SMB stream */
201 if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) {
202 DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n"));
203 return False;
206 return True;
209 /***************************************************************************
210 api_lsa_close.
211 ***************************************************************************/
213 static BOOL api_lsa_close(pipes_struct *p)
215 LSA_Q_CLOSE q_u;
216 LSA_R_CLOSE r_u;
217 prs_struct *data = &p->in_data.data;
218 prs_struct *rdata = &p->out_data.rdata;
220 ZERO_STRUCT(q_u);
221 ZERO_STRUCT(r_u);
223 if (!lsa_io_q_close("", &q_u, data, 0)) {
224 DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n"));
225 return False;
228 r_u.status = _lsa_close(p, &q_u, &r_u);
230 /* store the response in the SMB stream */
231 if (!lsa_io_r_close("", &r_u, rdata, 0)) {
232 DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n"));
233 return False;
236 return True;
239 /***************************************************************************
240 api_lsa_open_secret.
241 ***************************************************************************/
243 static BOOL api_lsa_open_secret(pipes_struct *p)
245 LSA_Q_OPEN_SECRET q_u;
246 LSA_R_OPEN_SECRET r_u;
247 prs_struct *data = &p->in_data.data;
248 prs_struct *rdata = &p->out_data.rdata;
250 ZERO_STRUCT(q_u);
251 ZERO_STRUCT(r_u);
253 if(!lsa_io_q_open_secret("", &q_u, data, 0)) {
254 DEBUG(0,("api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET.\n"));
255 return False;
258 r_u.status = _lsa_open_secret(p, &q_u, &r_u);
260 /* store the response in the SMB stream */
261 if(!lsa_io_r_open_secret("", &r_u, rdata, 0)) {
262 DEBUG(0,("api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET.\n"));
263 return False;
266 return True;
269 /***************************************************************************
270 api_lsa_open_secret.
271 ***************************************************************************/
273 static BOOL api_lsa_enum_privs(pipes_struct *p)
275 LSA_Q_ENUM_PRIVS q_u;
276 LSA_R_ENUM_PRIVS r_u;
277 prs_struct *data = &p->in_data.data;
278 prs_struct *rdata = &p->out_data.rdata;
280 ZERO_STRUCT(q_u);
281 ZERO_STRUCT(r_u);
283 if(!lsa_io_q_enum_privs("", &q_u, data, 0)) {
284 DEBUG(0,("api_lsa_enum_privs: failed to unmarshall LSA_Q_ENUM_PRIVS.\n"));
285 return False;
288 r_u.status = _lsa_enum_privs(p, &q_u, &r_u);
290 /* store the response in the SMB stream */
291 if(!lsa_io_r_enum_privs("", &r_u, rdata, 0)) {
292 DEBUG(0,("api_lsa_enum_privs: Failed to marshall LSA_R_ENUM_PRIVS.\n"));
293 return False;
296 return True;
299 /***************************************************************************
300 api_lsa_open_secret.
301 ***************************************************************************/
303 static BOOL api_lsa_priv_get_dispname(pipes_struct *p)
305 LSA_Q_PRIV_GET_DISPNAME q_u;
306 LSA_R_PRIV_GET_DISPNAME r_u;
307 prs_struct *data = &p->in_data.data;
308 prs_struct *rdata = &p->out_data.rdata;
310 ZERO_STRUCT(q_u);
311 ZERO_STRUCT(r_u);
313 if(!lsa_io_q_priv_get_dispname("", &q_u, data, 0)) {
314 DEBUG(0,("api_lsa_priv_get_dispname: failed to unmarshall LSA_Q_PRIV_GET_DISPNAME.\n"));
315 return False;
318 r_u.status = _lsa_priv_get_dispname(p, &q_u, &r_u);
320 /* store the response in the SMB stream */
321 if(!lsa_io_r_priv_get_dispname("", &r_u, rdata, 0)) {
322 DEBUG(0,("api_lsa_priv_get_dispname: Failed to marshall LSA_R_PRIV_GET_DISPNAME.\n"));
323 return False;
326 return True;
329 #if 0
330 /***************************************************************************
331 api_lsa_open_secret.
332 ***************************************************************************/
334 static BOOL api_lsa_enum_accounts(pipes_struct *p)
336 LSA_Q_ENUM_ACCOUNTS q_u;
337 LSA_R_ENUM_ACCOUNTS r_u;
338 prs_struct *data = &p->in_data.data;
339 prs_struct *rdata = &p->out_data.rdata;
341 ZERO_STRUCT(q_u);
342 ZERO_STRUCT(r_u);
344 if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) {
345 DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n"));
346 return False;
349 r_u.status = _lsa_enum_accounts(p, &q_u, &r_u);
351 /* store the response in the SMB stream */
352 if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) {
353 DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n"));
354 return False;
357 return True;
359 #endif
361 /***************************************************************************
362 api_lsa_UNK_GET_CONNUSER
363 ***************************************************************************/
365 static BOOL api_lsa_unk_get_connuser(pipes_struct *p)
367 LSA_Q_UNK_GET_CONNUSER q_u;
368 LSA_R_UNK_GET_CONNUSER r_u;
370 prs_struct *data = &p->in_data.data;
371 prs_struct *rdata = &p->out_data.rdata;
373 ZERO_STRUCT(q_u);
374 ZERO_STRUCT(r_u);
376 if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) {
377 DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n"));
378 return False;
381 r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u);
383 /* store the response in the SMB stream */
384 if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) {
385 DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n"));
386 return False;
389 return True;
392 /***************************************************************************
393 api_lsa_open_user
394 ***************************************************************************/
396 static BOOL api_lsa_open_account(pipes_struct *p)
398 LSA_Q_OPENACCOUNT q_u;
399 LSA_R_OPENACCOUNT r_u;
401 prs_struct *data = &p->in_data.data;
402 prs_struct *rdata = &p->out_data.rdata;
404 ZERO_STRUCT(q_u);
405 ZERO_STRUCT(r_u);
407 if(!lsa_io_q_open_account("", &q_u, data, 0)) {
408 DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n"));
409 return False;
412 r_u.status = _lsa_open_account(p, &q_u, &r_u);
414 /* store the response in the SMB stream */
415 if(!lsa_io_r_open_account("", &r_u, rdata, 0)) {
416 DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n"));
417 return False;
420 return True;
423 #if 0
424 /***************************************************************************
425 api_lsa_get_privs
426 ***************************************************************************/
428 static BOOL api_lsa_enum_privsaccount(pipes_struct *p)
430 LSA_Q_ENUMPRIVSACCOUNT q_u;
431 LSA_R_ENUMPRIVSACCOUNT r_u;
433 prs_struct *data = &p->in_data.data;
434 prs_struct *rdata = &p->out_data.rdata;
436 ZERO_STRUCT(q_u);
437 ZERO_STRUCT(r_u);
439 if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) {
440 DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n"));
441 return False;
444 r_u.status = _lsa_enum_privsaccount(p, &q_u, &r_u);
446 /* store the response in the SMB stream */
447 if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) {
448 DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n"));
449 return False;
452 return True;
454 #endif
456 /***************************************************************************
457 api_lsa_getsystemaccount
458 ***************************************************************************/
460 static BOOL api_lsa_getsystemaccount(pipes_struct *p)
462 LSA_Q_GETSYSTEMACCOUNT q_u;
463 LSA_R_GETSYSTEMACCOUNT r_u;
465 prs_struct *data = &p->in_data.data;
466 prs_struct *rdata = &p->out_data.rdata;
468 ZERO_STRUCT(q_u);
469 ZERO_STRUCT(r_u);
471 if(!lsa_io_q_getsystemaccount("", &q_u, data, 0)) {
472 DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n"));
473 return False;
476 r_u.status = _lsa_getsystemaccount(p, &q_u, &r_u);
478 /* store the response in the SMB stream */
479 if(!lsa_io_r_getsystemaccount("", &r_u, rdata, 0)) {
480 DEBUG(0,("api_lsa_getsystemaccount: Failed to marshall LSA_R_GETSYSTEMACCOUNT.\n"));
481 return False;
484 return True;
488 /***************************************************************************
489 \PIPE\ntlsa commands
490 ***************************************************************************/
492 static struct api_struct api_lsa_cmds[] =
494 { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 },
495 { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy },
496 { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info },
497 { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom },
498 { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close },
499 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
500 { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids },
501 { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names },
502 { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs },
503 { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname},
504 #if 0
505 { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts },
506 #endif
507 { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser},
508 { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account },
509 #if 0
510 { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount},
511 #endif
512 { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount},
513 { NULL , 0 , NULL }
516 /***************************************************************************
517 api_ntLsarpcTNP
518 ***************************************************************************/
519 BOOL api_ntlsa_rpc(pipes_struct *p)
521 return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds);