r7648: adding REGISTRY_HOOK->reg_access_check() for authprization checks on RegOpenKe...
[tprouty/samba.git] / source / include / rpc_reg.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
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) Jeremy Cooper                        2004.
8    Copyright (C) Gerald Carter                   2002-2005.
9    
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.
14    
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.
19    
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.
23 */
24
25 #ifndef _RPC_REG_H /* _RPC_REG_H */
26 #define _RPC_REG_H 
27
28 #include "reg_objects.h"
29
30 /* RPC opnum */
31
32 #define REG_OPEN_HKCR           0x00
33 #define REG_OPEN_HKLM           0x02
34 #define REG_OPEN_HKPD           0x03
35 #define REG_OPEN_HKU            0x04
36 #define REG_CLOSE               0x05
37 #define REG_CREATE_KEY          0x06
38 #define REG_DELETE_KEY          0x07
39 #define REG_DELETE_VALUE        0x08
40 #define REG_ENUM_KEY            0x09
41 #define REG_ENUM_VALUE          0x0a
42 #define REG_FLUSH_KEY           0x0b
43 #define REG_GET_KEY_SEC         0x0c
44 #define REG_OPEN_ENTRY          0x0f
45 #define REG_QUERY_KEY           0x10
46 #define REG_INFO                0x11
47 #define REG_RESTORE_KEY         0x13
48 #define REG_SAVE_KEY            0x14
49 #define REG_SET_KEY_SEC         0x15
50 #define REG_SET_VALUE           0x16
51 #define REG_SHUTDOWN            0x18
52 #define REG_ABORT_SHUTDOWN      0x19
53 #define REG_GETVERSION          0x1a
54 #define REG_SHUTDOWN_EX         0x1e
55
56
57 #define HKEY_CLASSES_ROOT       0x80000000
58 #define HKEY_CURRENT_USER       0x80000001
59 #define HKEY_LOCAL_MACHINE      0x80000002
60 #define HKEY_USERS              0x80000003
61 #define HKEY_PERFORMANCE_DATA   0x80000004
62
63 #define KEY_HKLM                "HKLM"
64 #define KEY_HKU                 "HKU"
65 #define KEY_HKCR                "HKCR"
66 #define KEY_PRINTING            "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
67 #define KEY_PRINTING_2K         "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print"
68 #define KEY_PRINTING_PORTS      "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports"
69 #define KEY_EVENTLOG            "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
70 #define KEY_SHARES              "HKLM\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares"
71 #define KEY_TREE_ROOT           ""
72
73 /* Registry data types */
74
75 #define REG_NONE                       0
76 #define REG_SZ                         1
77 #define REG_EXPAND_SZ                  2
78 #define REG_BINARY                     3
79 #define REG_DWORD                      4
80 #define REG_DWORD_LE                   4        /* DWORD, little endian */
81 #define REG_DWORD_BE                   5        /* DWORD, big endian */
82 #define REG_LINK                       6
83 #define REG_MULTI_SZ                   7
84 #define REG_RESOURCE_LIST              8
85 #define REG_FULL_RESOURCE_DESCRIPTOR   9
86 #define REG_RESOURCE_REQUIREMENTS_LIST 10
87
88 /* 
89  * container for function pointers to enumeration routines
90  * for vitural registry view 
91  */ 
92  
93 typedef struct {
94         /* functions for enumerating subkeys and values */      
95         int     (*fetch_subkeys)( char *key, REGSUBKEY_CTR *subkeys);
96         int     (*fetch_values) ( char *key, REGVAL_CTR *val );
97         BOOL    (*store_subkeys)( char *key, REGSUBKEY_CTR *subkeys );
98         BOOL    (*store_values)( char *key, REGVAL_CTR *val );
99         BOOL    (*reg_access_check)( uint32 parent_granted, uint32 requested, uint32 *granted );
100 } REGISTRY_OPS;
101
102 typedef struct {
103         const char      *keyname;       /* full path to name of key */
104         REGISTRY_OPS    *ops;           /* registry function hooks */
105 } REGISTRY_HOOK;
106
107
108 /* structure to store the registry handles */
109
110 typedef struct _RegistryKey {
111
112         struct _RegistryKey *prev, *next;
113
114         /* POLICY_HND   hnd; */
115         pstring         name;   /* full name of registry key */
116         REGISTRY_HOOK   *hook;
117         
118 } REGISTRY_KEY;
119
120 /*
121  * RPC REGISTRY STRUCTURES
122  */
123
124 /***********************************************/
125
126 typedef struct {
127         uint16 *server;
128         uint32 access;     
129 } REG_Q_OPEN_HIVE;
130
131 typedef struct {
132         POLICY_HND pol;
133         WERROR status; 
134 } REG_R_OPEN_HIVE;
135
136
137 /***********************************************/
138
139 typedef struct {
140         POLICY_HND pol;
141 } REG_Q_FLUSH_KEY;
142
143 typedef struct {
144         WERROR status; 
145 } REG_R_FLUSH_KEY;
146
147
148 /***********************************************/
149
150 typedef struct {
151         POLICY_HND pol;
152         uint32 sec_info;
153         uint32 ptr; 
154         BUFHDR hdr_sec;
155         SEC_DESC_BUF *data;
156 } REG_Q_SET_KEY_SEC;
157
158 typedef struct {
159         WERROR status;
160 } REG_R_SET_KEY_SEC;
161
162
163 /***********************************************/
164
165 typedef struct {
166         POLICY_HND pol;
167         uint32 sec_info;
168         uint32 ptr; 
169         BUFHDR hdr_sec; 
170         SEC_DESC_BUF *data; 
171 } REG_Q_GET_KEY_SEC;
172
173 typedef struct {
174         uint32 sec_info; 
175         uint32 ptr; 
176         BUFHDR hdr_sec; 
177         SEC_DESC_BUF *data;
178         WERROR status;
179 } REG_R_GET_KEY_SEC;
180
181 /***********************************************/
182
183 typedef struct {
184         POLICY_HND pol;   
185         UNISTR4 name;           
186         uint32 type;  
187         RPC_DATA_BLOB value; 
188         uint32 size;
189 } REG_Q_SET_VALUE;
190
191 typedef struct { 
192         WERROR status;
193 } REG_R_SET_VALUE;
194
195 /***********************************************/
196
197 typedef struct {
198         POLICY_HND pol;
199         uint32 val_index;
200         UNISTR4 name;
201         uint32 *type;  
202         REGVAL_BUFFER *value; /* value, in byte buffer */
203         uint32 *buffer_len; 
204         uint32 *name_len; 
205 } REG_Q_ENUM_VALUE;
206
207 typedef struct { 
208         UNISTR4 name;
209         uint32 *type;
210         REGVAL_BUFFER *value;
211         uint32 *buffer_len1;
212         uint32 *buffer_len2;
213         WERROR status;
214 } REG_R_ENUM_VALUE;
215
216 /***********************************************/
217
218 typedef struct {
219         POLICY_HND handle;
220         UNISTR4 name;
221         UNISTR4 class;
222         uint32 reserved;
223         uint32 access;
224         uint32 *sec_info;
225         uint32 ptr2;
226         BUFHDR hdr_sec;
227         uint32 ptr3;
228         SEC_DESC_BUF *data;
229         uint32 unknown_2; /* 0x0000 0000 */
230 } REG_Q_CREATE_KEY;
231
232 typedef struct {
233         POLICY_HND key_pol;
234         uint32 unknown;
235         WERROR status; 
236 } REG_R_CREATE_KEY;
237
238 /***********************************************/
239
240 typedef struct {
241         POLICY_HND handle;
242         UNISTR4 name;
243 } REG_Q_DELETE_KEY;
244
245 typedef struct {
246         POLICY_HND key_pol;
247         WERROR status; 
248 } REG_R_DELETE_KEY;
249
250 /***********************************************/
251
252 typedef struct {
253         POLICY_HND handle;
254         UNISTR4 name;
255 } REG_Q_DELETE_VALUE;
256
257 typedef struct {
258         POLICY_HND key_pol;
259         WERROR status;
260 } REG_R_DELETE_VALUE;
261
262 /***********************************************/
263
264 typedef struct {
265         POLICY_HND pol;
266         UNISTR4 class;
267 } REG_Q_QUERY_KEY;
268
269 typedef struct {
270         UNISTR4 class;
271         uint32 num_subkeys;
272         uint32 max_subkeylen;
273         uint32 reserved;        /* 0x0000 0000 - according to MSDN (max_subkeysize?) */
274         uint32 num_values;
275         uint32 max_valnamelen;
276         uint32 max_valbufsize; 
277         uint32 sec_desc;        /* 0x0000 0078 */
278         NTTIME mod_time;        /* modified time */
279         WERROR status;         
280 } REG_R_QUERY_KEY;
281
282
283 /***********************************************/
284
285 typedef struct {
286         POLICY_HND pol;
287 } REG_Q_GETVERSION;
288
289 typedef struct {
290         uint32 win_version;
291         WERROR status;
292 } REG_R_GETVERSION;
293
294
295 /***********************************************/
296
297 typedef struct {
298         POLICY_HND pol; 
299         UNISTR4 filename;
300         uint32 flags;
301 } REG_Q_RESTORE_KEY;
302
303 typedef struct {
304         WERROR status;         /* return status */
305 } REG_R_RESTORE_KEY;
306
307
308 /***********************************************/
309
310
311 /* I have no idea if this is correct since I 
312    have not seen the full structure on the wire 
313    as of yet */
314    
315 typedef struct {
316         uint32 max_len;
317         uint32 len;
318         SEC_DESC *secdesc;
319 } REG_SEC_DESC_BUF;
320
321 typedef struct {
322         uint32 size;            /* size in bytes of security descriptor */
323         REG_SEC_DESC_BUF secdesc;
324         uint8  inherit;         /* see MSDN for a description */
325 } SECURITY_ATTRIBUTE;
326
327 typedef struct {
328         POLICY_HND pol; 
329         UNISTR4 filename;
330         SECURITY_ATTRIBUTE *sec_attr;
331 } REG_Q_SAVE_KEY;
332
333 typedef struct {
334         WERROR status;         /* return status */
335 } REG_R_SAVE_KEY;
336
337
338 /***********************************************/
339
340 typedef struct {
341         POLICY_HND pol; /* policy handle */
342 } REG_Q_CLOSE;
343
344 typedef struct {
345         POLICY_HND pol; 
346         WERROR status; 
347 } REG_R_CLOSE;
348
349
350 /***********************************************/
351
352 typedef struct {
353         POLICY_HND pol; 
354         uint32 key_index;       
355         uint16 key_name_len;   
356         uint16 unknown_1;       /* 0x0414 */
357         uint32 ptr1;          
358         uint32 unknown_2;       /* 0x0000 020A */
359         uint8  pad1[8];        
360         uint32 ptr2;           
361         uint8  pad2[8];        
362         uint32 ptr3;           
363         NTTIME time;           
364 } REG_Q_ENUM_KEY;
365
366 typedef struct { 
367         UNISTR4 keyname;
368         UNISTR4 *classname;
369         NTTIME *time;            
370         WERROR status;         /* return status */
371 } REG_R_ENUM_KEY;
372
373
374 /***********************************************/
375
376 typedef struct {
377         POLICY_HND pol;         /* policy handle */
378         UNISTR4  name;
379
380         uint32 ptr_reserved;    /* pointer */
381   
382         uint32 ptr_buf;         /* the next three fields follow if ptr_buf != 0 */
383         uint32 ptr_bufsize;
384         uint32 bufsize;
385         uint32 buf_unk;
386
387         uint32 unk1;
388         uint32 ptr_buflen;
389         uint32 buflen;
390   
391         uint32 ptr_buflen2;
392         uint32 buflen2;
393
394 } REG_Q_INFO;
395
396 typedef struct { 
397         uint32 *type;
398         REGVAL_BUFFER *value;   /* key value */
399         uint32 *buf_max_len;
400         uint32 *buf_len;
401         WERROR status;  /* return status */
402 } REG_R_INFO;
403
404
405 /***********************************************/
406
407 typedef struct {
408         POLICY_HND pol;
409         UNISTR4 name; 
410         uint32 unknown_0;       /* 32 bit unknown - 0x0000 0000 */
411         uint32 access; 
412 } REG_Q_OPEN_ENTRY;
413
414 typedef struct {
415         POLICY_HND pol;
416         WERROR status;
417 } REG_R_OPEN_ENTRY;
418
419 /***********************************************/
420  
421 typedef struct {
422         uint16 *server;
423         UNISTR4 *message;       
424         uint32 timeout;         /* in seconds */
425         uint8 force;            /* boolean: force shutdown */
426         uint8 reboot;           /* boolean: reboot on shutdown */               
427 } REG_Q_SHUTDOWN;
428
429 typedef struct {
430         WERROR status;          /* return status */
431 } REG_R_SHUTDOWN;
432
433 /***********************************************/
434  
435 typedef struct {
436         uint16 *server;
437         UNISTR4 *message;       
438         uint32 timeout;         /* in seconds */
439         uint8 force;            /* boolean: force shutdown */
440         uint8 reboot;           /* boolean: reboot on shutdown */
441         uint32 reason;          /* reason - must be defined code */
442 } REG_Q_SHUTDOWN_EX;
443
444 typedef struct {
445         WERROR status;
446 } REG_R_SHUTDOWN_EX;
447
448 /***********************************************/
449
450 typedef struct {
451         uint16 *server;
452 } REG_Q_ABORT_SHUTDOWN;
453
454 typedef struct { 
455         WERROR status; 
456 } REG_R_ABORT_SHUTDOWN;
457
458
459 #endif /* _RPC_REG_H */
460