updated the 3.0 branch from the head branch - ready for alpha18
[samba.git] / source3 / rpc_server / srv_reg.c
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  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *  
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *  
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26 /* This is the interface for the registry functions. */
27
28 #include "includes.h"
29
30 #undef DBGC_CLASS
31 #define DBGC_CLASS DBGC_RPC_SRV
32
33 /*******************************************************************
34  api_reg_close
35  ********************************************************************/
36
37 static BOOL api_reg_close(pipes_struct *p)
38 {
39         REG_Q_CLOSE q_u;
40         REG_R_CLOSE r_u;
41         prs_struct *data = &p->in_data.data;
42         prs_struct *rdata = &p->out_data.rdata;
43
44         ZERO_STRUCT(q_u);
45         ZERO_STRUCT(r_u);
46
47         /* grab the reg unknown 1 */
48         if(!reg_io_q_close("", &q_u, data, 0))
49                 return False;
50
51         r_u.status = _reg_close(p, &q_u, &r_u);
52
53         if(!reg_io_r_close("", &r_u, rdata, 0))
54                 return False;
55
56         return True;
57 }
58
59 /*******************************************************************
60  api_reg_open_khlm
61  ********************************************************************/
62
63 static BOOL api_reg_open_hklm(pipes_struct *p)
64 {
65         REG_Q_OPEN_HKLM q_u;
66         REG_R_OPEN_HKLM r_u;
67         prs_struct *data = &p->in_data.data;
68         prs_struct *rdata = &p->out_data.rdata;
69
70         ZERO_STRUCT(q_u);
71         ZERO_STRUCT(r_u);
72
73         /* grab the reg open */
74         if(!reg_io_q_open_hklm("", &q_u, data, 0))
75                 return False;
76
77         r_u.status = _reg_open_hklm(p, &q_u, &r_u);
78
79         if(!reg_io_r_open_hklm("", &r_u, rdata, 0))
80                 return False;
81
82         return True;
83 }
84
85 /*******************************************************************
86  api_reg_open_khlm
87  ********************************************************************/
88
89 static BOOL api_reg_open_hku(pipes_struct *p)
90 {
91         REG_Q_OPEN_HKU q_u;
92         REG_R_OPEN_HKU r_u;
93         prs_struct *data = &p->in_data.data;
94         prs_struct *rdata = &p->out_data.rdata;
95
96         ZERO_STRUCT(q_u);
97         ZERO_STRUCT(r_u);
98
99         /* grab the reg open */
100         if(!reg_io_q_open_hku("", &q_u, data, 0))
101                 return False;
102
103         r_u.status = _reg_open_hku(p, &q_u, &r_u);
104
105         if(!reg_io_r_open_hku("", &r_u, rdata, 0))
106                 return False;
107
108         return True;
109 }
110
111
112 /*******************************************************************
113  api_reg_open_entry
114  ********************************************************************/
115
116 static BOOL api_reg_open_entry(pipes_struct *p)
117 {
118         REG_Q_OPEN_ENTRY q_u;
119         REG_R_OPEN_ENTRY r_u;
120         prs_struct *data = &p->in_data.data;
121         prs_struct *rdata = &p->out_data.rdata;
122
123         ZERO_STRUCT(q_u);
124         ZERO_STRUCT(r_u);
125
126         /* grab the reg open entry */
127         if(!reg_io_q_open_entry("", &q_u, data, 0))
128                 return False;
129
130         /* construct reply. */
131         r_u.status = _reg_open_entry(p, &q_u, &r_u);
132
133         if(!reg_io_r_open_entry("", &r_u, rdata, 0))
134                 return False;
135
136         return True;
137 }
138
139 /*******************************************************************
140  api_reg_info
141  ********************************************************************/
142
143 static BOOL api_reg_info(pipes_struct *p)
144 {
145         REG_Q_INFO q_u;
146         REG_R_INFO r_u;
147         prs_struct *data = &p->in_data.data;
148         prs_struct *rdata = &p->out_data.rdata;
149
150         ZERO_STRUCT(q_u);
151         ZERO_STRUCT(r_u);
152
153         /* grab the reg unknown 0x11*/
154         if(!reg_io_q_info("", &q_u, data, 0))
155                 return False;
156
157         r_u.status = _reg_info(p, &q_u, &r_u);
158
159         if(!reg_io_r_info("", &r_u, rdata, 0))
160                 return False;
161
162         return True;
163 }
164
165 /*******************************************************************
166  api_reg_shutdown
167  ********************************************************************/
168
169 static BOOL api_reg_shutdown(pipes_struct *p)
170 {
171         REG_Q_SHUTDOWN q_u;
172         REG_R_SHUTDOWN r_u;
173         prs_struct *data = &p->in_data.data;
174         prs_struct *rdata = &p->out_data.rdata;
175
176         ZERO_STRUCT(q_u);
177         ZERO_STRUCT(r_u);
178
179         /* grab the reg shutdown */
180         if(!reg_io_q_shutdown("", &q_u, data, 0))
181                 return False;
182
183         r_u.status = _reg_shutdown(p, &q_u, &r_u);
184
185         if(!reg_io_r_shutdown("", &r_u, rdata, 0))
186                 return False;
187
188         return True;
189 }
190
191 /*******************************************************************
192  api_reg_abort_shutdown
193  ********************************************************************/
194
195 static BOOL api_reg_abort_shutdown(pipes_struct *p)
196 {
197         REG_Q_ABORT_SHUTDOWN q_u;
198         REG_R_ABORT_SHUTDOWN r_u;
199         prs_struct *data = &p->in_data.data;
200         prs_struct *rdata = &p->out_data.rdata;
201
202         ZERO_STRUCT(q_u);
203         ZERO_STRUCT(r_u);
204
205         /* grab the reg shutdown */
206         if(!reg_io_q_abort_shutdown("", &q_u, data, 0))
207                 return False;
208
209         r_u.status = _reg_abort_shutdown(p, &q_u, &r_u);
210
211         if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0))
212                 return False;
213
214         return True;
215 }
216
217
218 /*******************************************************************
219  api_reg_query_key
220  ********************************************************************/
221
222 static BOOL api_reg_query_key(pipes_struct *p)
223 {
224         REG_Q_QUERY_KEY q_u;
225         REG_R_QUERY_KEY r_u;
226         prs_struct *data = &p->in_data.data;
227         prs_struct *rdata = &p->out_data.rdata;
228
229         ZERO_STRUCT(q_u);
230         ZERO_STRUCT(r_u);
231
232         if(!reg_io_q_query_key("", &q_u, data, 0))
233                 return False;
234
235         r_u.status = _reg_query_key(p, &q_u, &r_u);
236
237         if(!reg_io_r_query_key("", &r_u, rdata, 0))
238                 return False;
239
240         return True;
241 }
242
243 /*******************************************************************
244  api_reg_unknown_1a
245  ********************************************************************/
246
247 static BOOL api_reg_unknown_1a(pipes_struct *p)
248 {
249         REG_Q_UNKNOWN_1A q_u;
250         REG_R_UNKNOWN_1A r_u;
251         prs_struct *data = &p->in_data.data;
252         prs_struct *rdata = &p->out_data.rdata;
253
254         ZERO_STRUCT(q_u);
255         ZERO_STRUCT(r_u);
256
257         if(!reg_io_q_unknown_1a("", &q_u, data, 0))
258                 return False;
259
260         r_u.status = _reg_unknown_1a(p, &q_u, &r_u);
261
262         if(!reg_io_r_unknown_1a("", &r_u, rdata, 0))
263                 return False;
264
265         return True;
266 }
267
268 /*******************************************************************
269  api_reg_enum_key
270  ********************************************************************/
271
272 static BOOL api_reg_enum_key(pipes_struct *p)
273 {
274         REG_Q_ENUM_KEY q_u;
275         REG_R_ENUM_KEY r_u;
276         prs_struct *data = &p->in_data.data;
277         prs_struct *rdata = &p->out_data.rdata;
278
279         ZERO_STRUCT(q_u);
280         ZERO_STRUCT(r_u);
281
282         if(!reg_io_q_enum_key("", &q_u, data, 0))
283                 return False;
284
285         r_u.status = _reg_enum_key(p, &q_u, &r_u);
286
287         if(!reg_io_r_enum_key("", &r_u, rdata, 0))
288                 return False;
289
290         return True;
291 }
292
293
294
295 /*******************************************************************
296  array of \PIPE\reg operations
297  ********************************************************************/
298 static struct api_struct api_reg_cmds[] =
299 {
300         { "REG_CLOSE"              , REG_CLOSE              , api_reg_close            },
301         { "REG_OPEN_ENTRY"         , REG_OPEN_ENTRY         , api_reg_open_entry       },
302         { "REG_OPEN_HKLM"          , REG_OPEN_HKLM          , api_reg_open_hklm        },
303         { "REG_OPEN_HKU"           , REG_OPEN_HKU           , api_reg_open_hku         },
304         { "REG_ENUM_KEY"           , REG_ENUM_KEY           , api_reg_enum_key         },
305         { "REG_QUERY_KEY"          , REG_QUERY_KEY          , api_reg_query_key        },
306         { "REG_INFO"               , REG_INFO               , api_reg_info             },
307         { "REG_SHUTDOWN"           , REG_SHUTDOWN           , api_reg_shutdown         },
308         { "REG_ABORT_SHUTDOWN"     , REG_ABORT_SHUTDOWN     , api_reg_abort_shutdown   },
309         { "REG_UNKNOWN_1A"         , REG_UNKNOWN_1A         , api_reg_unknown_1a       },
310         { NULL                     , 0                      , NULL                     }
311 };
312
313 /*******************************************************************
314  receives a reg pipe and responds.
315  ********************************************************************/
316
317 BOOL api_reg_rpc(pipes_struct *p)
318 {
319         return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds);
320 }