r14599: Pass ACLs down the registry layer.
[bbaumbach/samba-autobuild/.git] / source4 / lib / registry / registry.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Registry interface
4    Copyright (C) Gerald Carter                        2002.
5    Copyright (C) Jelmer Vernooij                                          2003-2004.
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef _REGISTRY_H /* _REGISTRY_H */
23 #define _REGISTRY_H 
24
25 #include "librpc/gen_ndr/security.h"
26 #include "auth/credentials/credentials.h"
27
28 /* Handles for the predefined keys */
29 #define HKEY_CLASSES_ROOT                0x80000000
30 #define HKEY_CURRENT_USER                0x80000001
31 #define HKEY_LOCAL_MACHINE               0x80000002
32 #define HKEY_USERS                               0x80000003
33 #define HKEY_PERFORMANCE_DATA    0x80000004
34 #define HKEY_CURRENT_CONFIG              0x80000005
35 #define HKEY_DYN_DATA                    0x80000006
36 #define HKEY_PERFORMANCE_TEXT    0x80000050
37 #define HKEY_PERFORMANCE_NLSTEXT 0x80000060
38
39 #define REG_DELETE                                                                 -1
40
41 /*
42  * The general idea here is that every backend provides a 'hive'. Combining
43  * various hives gives you a complete registry like windows has
44  */
45
46 #define REGISTRY_INTERFACE_VERSION 1
47
48 /* structure to store the registry handles */
49 struct registry_key 
50 {
51   char *name;       
52   const char *path;     
53   char *class_name; 
54   NTTIME last_mod; 
55   struct registry_hive *hive;
56   void *backend_data;
57 };
58
59 struct registry_value 
60 {
61   char *name;
62   unsigned int data_type;
63   DATA_BLOB data;
64 };
65
66 /* FIXME */
67 typedef void (*reg_key_notification_function) (void);
68 typedef void (*reg_value_notification_function) (void);
69
70 /* 
71  * Container for function pointers to enumeration routines
72  * for virtual registry view 
73  *
74  * Backends can provide :
75  *  - just one hive (example: nt4, w95)
76  *  - several hives (example: rpc).
77  * 
78  * Backends should always do case-insensitive compares 
79  * (everything is case-insensitive but case-preserving, 
80  * just like the FS)
81  *
82  * There is no save function as all operations are expected to 
83  * be atomic.
84  */ 
85
86 struct hive_operations {
87         const char *name;
88
89         /* Implement this one */
90         WERROR (*open_hive) (struct registry_hive *, struct registry_key **);
91
92         /* Or this one */
93         WERROR (*open_key) (TALLOC_CTX *, const struct registry_key *, const char *name, struct registry_key **);
94
95         WERROR (*num_subkeys) (const struct registry_key *, uint32_t *count);
96         WERROR (*num_values) (const struct registry_key *, uint32_t *count);
97         WERROR (*get_subkey_by_index) (TALLOC_CTX *, const struct registry_key *, int idx, struct registry_key **);
98
99         /* Can not contain more then one level */
100         WERROR (*get_subkey_by_name) (TALLOC_CTX *, const struct registry_key *, const char *name, struct registry_key **);
101         WERROR (*get_value_by_index) (TALLOC_CTX *, const struct registry_key *, int idx, struct registry_value **);
102
103         /* Can not contain more then one level */
104         WERROR (*get_value_by_name) (TALLOC_CTX *, const struct registry_key *, const char *name, struct registry_value **);
105
106         /* Security control */
107         WERROR (*key_get_sec_desc) (TALLOC_CTX *, const struct registry_key *, struct security_descriptor **);
108         WERROR (*key_set_sec_desc) (const struct registry_key *, const struct security_descriptor *);
109
110         /* Notification */
111         WERROR (*request_key_change_notify) (const struct registry_key *, reg_key_notification_function);
112         WERROR (*request_value_change_notify) (const struct registry_value *, reg_value_notification_function);
113
114         /* Key management */
115         WERROR (*add_key)(TALLOC_CTX *, const struct registry_key *, const char *name, uint32_t access_mask, struct security_descriptor *, struct registry_key **);
116         WERROR (*del_key)(const struct registry_key *, const char *name);
117         WERROR (*flush_key) (const struct registry_key *);
118
119         /* Value management */
120         WERROR (*set_value)(const struct registry_key *, const char *name, uint32_t type, const DATA_BLOB data); 
121         WERROR (*del_value)(const struct registry_key *, const char *valname);
122 };
123
124 struct registry_hive
125 {
126         const struct hive_operations *functions;
127         struct registry_key *root;
128         struct auth_session_info *session_info;
129         struct cli_credentials *credentials;
130         void *backend_data;
131         const char *location;
132 };
133
134 /* Handle to a full registry
135  * contains zero or more hives */
136 struct registry_context {
137     void *backend_data;
138         struct cli_credentials *credentials;
139         struct auth_session_info *session_info;
140         WERROR (*get_predefined_key) (struct registry_context *, uint32_t hkey, struct registry_key **);
141 };
142
143 struct reg_init_function_entry {
144         const struct hive_operations *hive_functions;
145         struct reg_init_function_entry *prev, *next;
146 };
147
148 struct reg_diff_value
149 {
150         char *name;
151         enum { REG_DIFF_DEL_VAL, REG_DIFF_SET_VAL } changetype;
152         uint32_t type;
153         DATA_BLOB data;
154 };
155
156 struct reg_diff_key
157 {
158         char *name;
159         enum { REG_DIFF_CHANGE_KEY, REG_DIFF_DEL_KEY } changetype;
160         uint32_t numvalues;
161         struct reg_diff_value *values;
162 };
163
164 struct reg_diff
165 {
166         char *format;
167         uint32_t numkeys;
168         struct reg_diff_key *keys;
169 };
170
171 struct auth_session_info;
172
173 #include "lib/registry/registry_proto.h"
174
175 #endif /* _REGISTRY_H */