r395: BUG 1232: patch from landonf@opendarwin.org (Landon Fuller) to fix
[Samba/gebeck_regimport.git] / source / rpc_server / srv_reg.c
blobb780be0aff3c16677989128ed5bfd23539fb9f2d
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 * Copyright (C) Paul Ashton 1997,
7 * Copyright (C) Marc Jacobsen 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Gerald Carter 2002,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /* This is the interface for the registry functions. */
29 #include "includes.h"
31 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_RPC_SRV
34 /*******************************************************************
35 api_reg_close
36 ********************************************************************/
38 static BOOL api_reg_close(pipes_struct *p)
40 REG_Q_CLOSE q_u;
41 REG_R_CLOSE r_u;
42 prs_struct *data = &p->in_data.data;
43 prs_struct *rdata = &p->out_data.rdata;
45 ZERO_STRUCT(q_u);
46 ZERO_STRUCT(r_u);
48 /* grab the reg unknown 1 */
49 if(!reg_io_q_close("", &q_u, data, 0))
50 return False;
52 r_u.status = _reg_close(p, &q_u, &r_u);
54 if(!reg_io_r_close("", &r_u, rdata, 0))
55 return False;
57 return True;
60 /*******************************************************************
61 api_reg_open_khlm
62 ********************************************************************/
64 static BOOL api_reg_open_hklm(pipes_struct *p)
66 REG_Q_OPEN_HKLM q_u;
67 REG_R_OPEN_HKLM 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 reg open */
75 if(!reg_io_q_open_hklm("", &q_u, data, 0))
76 return False;
78 r_u.status = _reg_open_hklm(p, &q_u, &r_u);
80 if(!reg_io_r_open_hklm("", &r_u, rdata, 0))
81 return False;
83 return True;
86 /*******************************************************************
87 api_reg_open_khu
88 ********************************************************************/
90 static BOOL api_reg_open_hku(pipes_struct *p)
92 REG_Q_OPEN_HKU q_u;
93 REG_R_OPEN_HKU r_u;
94 prs_struct *data = &p->in_data.data;
95 prs_struct *rdata = &p->out_data.rdata;
97 ZERO_STRUCT(q_u);
98 ZERO_STRUCT(r_u);
100 /* grab the reg open */
101 if(!reg_io_q_open_hku("", &q_u, data, 0))
102 return False;
104 r_u.status = _reg_open_hku(p, &q_u, &r_u);
106 if(!reg_io_r_open_hku("", &r_u, rdata, 0))
107 return False;
109 return True;
112 /*******************************************************************
113 api_reg_open_khcr
114 ********************************************************************/
116 static BOOL api_reg_open_hkcr(pipes_struct *p)
118 REG_Q_OPEN_HKCR q_u;
119 REG_R_OPEN_HKCR r_u;
120 prs_struct *data = &p->in_data.data;
121 prs_struct *rdata = &p->out_data.rdata;
123 ZERO_STRUCT(q_u);
124 ZERO_STRUCT(r_u);
126 /* grab the reg open */
127 if(!reg_io_q_open_hkcr("", &q_u, data, 0))
128 return False;
130 r_u.status = _reg_open_hkcr(p, &q_u, &r_u);
132 if(!reg_io_r_open_hkcr("", &r_u, rdata, 0))
133 return False;
135 return True;
139 /*******************************************************************
140 api_reg_open_entry
141 ********************************************************************/
143 static BOOL api_reg_open_entry(pipes_struct *p)
145 REG_Q_OPEN_ENTRY q_u;
146 REG_R_OPEN_ENTRY r_u;
147 prs_struct *data = &p->in_data.data;
148 prs_struct *rdata = &p->out_data.rdata;
150 ZERO_STRUCT(q_u);
151 ZERO_STRUCT(r_u);
153 /* grab the reg open entry */
154 if(!reg_io_q_open_entry("", &q_u, data, 0))
155 return False;
157 /* construct reply. */
158 r_u.status = _reg_open_entry(p, &q_u, &r_u);
160 if(!reg_io_r_open_entry("", &r_u, rdata, 0))
161 return False;
163 return True;
166 /*******************************************************************
167 api_reg_info
168 ********************************************************************/
170 static BOOL api_reg_info(pipes_struct *p)
172 REG_Q_INFO q_u;
173 REG_R_INFO r_u;
174 prs_struct *data = &p->in_data.data;
175 prs_struct *rdata = &p->out_data.rdata;
177 ZERO_STRUCT(q_u);
178 ZERO_STRUCT(r_u);
180 /* grab the reg unknown 0x11*/
181 if(!reg_io_q_info("", &q_u, data, 0))
182 return False;
184 r_u.status = _reg_info(p, &q_u, &r_u);
186 if(!reg_io_r_info("", &r_u, rdata, 0))
187 return False;
189 return True;
192 /*******************************************************************
193 api_reg_shutdown
194 ********************************************************************/
196 static BOOL api_reg_shutdown(pipes_struct *p)
198 REG_Q_SHUTDOWN q_u;
199 REG_R_SHUTDOWN r_u;
200 prs_struct *data = &p->in_data.data;
201 prs_struct *rdata = &p->out_data.rdata;
203 ZERO_STRUCT(q_u);
204 ZERO_STRUCT(r_u);
206 /* grab the reg shutdown */
207 if(!reg_io_q_shutdown("", &q_u, data, 0))
208 return False;
210 r_u.status = _reg_shutdown(p, &q_u, &r_u);
212 if(!reg_io_r_shutdown("", &r_u, rdata, 0))
213 return False;
215 return True;
218 /*******************************************************************
219 api_reg_abort_shutdown
220 ********************************************************************/
222 static BOOL api_reg_abort_shutdown(pipes_struct *p)
224 REG_Q_ABORT_SHUTDOWN q_u;
225 REG_R_ABORT_SHUTDOWN r_u;
226 prs_struct *data = &p->in_data.data;
227 prs_struct *rdata = &p->out_data.rdata;
229 ZERO_STRUCT(q_u);
230 ZERO_STRUCT(r_u);
232 /* grab the reg shutdown */
233 if(!reg_io_q_abort_shutdown("", &q_u, data, 0))
234 return False;
236 r_u.status = _reg_abort_shutdown(p, &q_u, &r_u);
238 if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0))
239 return False;
241 return True;
245 /*******************************************************************
246 api_reg_query_key
247 ********************************************************************/
249 static BOOL api_reg_query_key(pipes_struct *p)
251 REG_Q_QUERY_KEY q_u;
252 REG_R_QUERY_KEY r_u;
253 prs_struct *data = &p->in_data.data;
254 prs_struct *rdata = &p->out_data.rdata;
256 ZERO_STRUCT(q_u);
257 ZERO_STRUCT(r_u);
259 if(!reg_io_q_query_key("", &q_u, data, 0))
260 return False;
262 r_u.status = _reg_query_key(p, &q_u, &r_u);
264 if(!reg_io_r_query_key("", &r_u, rdata, 0))
265 return False;
267 return True;
270 /*******************************************************************
271 api_reg_unknown_1a
272 ********************************************************************/
274 static BOOL api_reg_unknown_1a(pipes_struct *p)
276 REG_Q_UNKNOWN_1A q_u;
277 REG_R_UNKNOWN_1A r_u;
278 prs_struct *data = &p->in_data.data;
279 prs_struct *rdata = &p->out_data.rdata;
281 ZERO_STRUCT(q_u);
282 ZERO_STRUCT(r_u);
284 if(!reg_io_q_unknown_1a("", &q_u, data, 0))
285 return False;
287 r_u.status = _reg_unknown_1a(p, &q_u, &r_u);
289 if(!reg_io_r_unknown_1a("", &r_u, rdata, 0))
290 return False;
292 return True;
295 /*******************************************************************
296 api_reg_enum_key
297 ********************************************************************/
299 static BOOL api_reg_enum_key(pipes_struct *p)
301 REG_Q_ENUM_KEY q_u;
302 REG_R_ENUM_KEY r_u;
303 prs_struct *data = &p->in_data.data;
304 prs_struct *rdata = &p->out_data.rdata;
306 ZERO_STRUCT(q_u);
307 ZERO_STRUCT(r_u);
309 if(!reg_io_q_enum_key("", &q_u, data, 0))
310 return False;
312 r_u.status = _reg_enum_key(p, &q_u, &r_u);
314 if(!reg_io_r_enum_key("", &r_u, rdata, 0))
315 return False;
317 return True;
320 /*******************************************************************
321 api_reg_enum_value
322 ********************************************************************/
324 static BOOL api_reg_enum_value(pipes_struct *p)
326 REG_Q_ENUM_VALUE q_u;
327 REG_R_ENUM_VALUE r_u;
328 prs_struct *data = &p->in_data.data;
329 prs_struct *rdata = &p->out_data.rdata;
331 ZERO_STRUCT(q_u);
332 ZERO_STRUCT(r_u);
334 if(!reg_io_q_enum_val("", &q_u, data, 0))
335 return False;
337 r_u.status = _reg_enum_value(p, &q_u, &r_u);
339 if(!reg_io_r_enum_val("", &r_u, rdata, 0))
340 return False;
342 return True;
345 /*******************************************************************
346 api_reg_save_key
347 ********************************************************************/
349 static BOOL api_reg_save_key(pipes_struct *p)
351 REG_Q_SAVE_KEY q_u;
352 REG_R_SAVE_KEY r_u;
353 prs_struct *data = &p->in_data.data;
354 prs_struct *rdata = &p->out_data.rdata;
356 ZERO_STRUCT(q_u);
357 ZERO_STRUCT(r_u);
359 if(!reg_io_q_save_key("", &q_u, data, 0))
360 return False;
362 r_u.status = _reg_save_key(p, &q_u, &r_u);
364 if(!reg_io_r_save_key("", &r_u, rdata, 0))
365 return False;
367 return True;
370 /*******************************************************************
371 array of \PIPE\reg operations
372 ********************************************************************/
374 static struct api_struct api_reg_cmds[] =
376 { "REG_CLOSE" , REG_CLOSE , api_reg_close },
377 { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry },
378 { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr },
379 { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm },
380 { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku },
381 { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key },
382 { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value },
383 { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key },
384 { "REG_INFO" , REG_INFO , api_reg_info },
385 { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown },
386 { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown },
387 { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a },
388 { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }
391 void reg_get_pipe_fns( struct api_struct **fns, int *n_fns )
393 *fns = api_reg_cmds;
394 *n_fns = sizeof(api_reg_cmds) / sizeof(struct api_struct);
397 NTSTATUS rpc_reg_init(void)
400 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "winreg", "winreg", api_reg_cmds,
401 sizeof(api_reg_cmds) / sizeof(struct api_struct));