r26565: Fix python registry bindings. 'PROVISION_PYTHON=yes make test' works now.
[jelmer/samba4-debian.git] / source / lib / registry / hive.h
1 /*
2    Unix SMB/CIFS implementation.
3    Registry hive interface
4    Copyright (C) Jelmer Vernooij                                          2003-2007.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #ifndef __REGISTRY_HIVE_H__
22 #define __REGISTRY_HIVE_H__
23
24 #include <talloc.h>
25 #include "libcli/util/werror.h"
26 #include "librpc/gen_ndr/security.h"
27 #include "libcli/util/ntstatus.h"
28
29 /**
30  * This file contains the hive API. This API is generally used for
31  * reading a specific file that contains just one hive.
32  *
33  * Good examples are .DAT (NTUSER.DAT) files.
34  *
35  * This API does not have any notification support (that
36  * should be provided by the registry implementation), nor
37  * does it understand what predefined keys are.
38  */
39
40 struct hive_key {
41         const struct hive_operations *ops;
42 };
43
44 struct hive_operations {
45         const char *name;
46
47         /**
48          * Open a specific subkey
49          */
50         WERROR (*enum_key) (TALLOC_CTX *mem_ctx,
51                             const struct hive_key *key, uint32_t idx,
52                             const char **name,
53                             const char **classname,
54                             NTTIME *last_mod_time);
55
56         /**
57          * Open a subkey by name
58          */
59         WERROR (*get_key_by_name) (TALLOC_CTX *mem_ctx,
60                                    const struct hive_key *key, const char *name,
61                                    struct hive_key **subkey);
62
63         /**
64          * Add a new key.
65          */
66         WERROR (*add_key) (TALLOC_CTX *ctx,
67                            const struct hive_key *parent_key, const char *name,
68                            const char *classname,
69                            struct security_descriptor *desc,
70                            struct hive_key **key);
71         /**
72          * Remove an existing key.
73          */
74         WERROR (*del_key) (const struct hive_key *key, const char *name);
75
76         /**
77          * Force write of a key to disk.
78          */
79         WERROR (*flush_key) (struct hive_key *key);
80
81         /**
82          * Retrieve a registry value with a specific index.
83          */
84         WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
85                               struct hive_key *key, int idx,
86                               const char **name, uint32_t *type,
87                               DATA_BLOB *data);
88
89         /**
90          * Retrieve a registry value with the specified name
91          */
92         WERROR (*get_value_by_name) (TALLOC_CTX *mem_ctx,
93                                      struct hive_key *key, const char *name,
94                                      uint32_t *type, DATA_BLOB *data);
95
96         /**
97          * Set a value on the specified registry key.
98          */
99         WERROR (*set_value) (struct hive_key *key, const char *name,
100                              uint32_t type, const DATA_BLOB data);
101
102         /**
103          * Remove a value.
104          */
105         WERROR (*delete_value) (struct hive_key *key, const char *name);
106
107         /* Security Descriptors */
108
109         /**
110          * Change the security descriptor on a registry key.
111          *
112          * This should return WERR_NOT_SUPPORTED if the underlying
113          * format does not have a mechanism for storing
114          * security descriptors.
115          */
116         WERROR (*set_sec_desc) (struct hive_key *key,
117                                 const struct security_descriptor *desc);
118
119         /**
120          * Retrieve the security descriptor on a registry key.
121          *
122          * This should return WERR_NOT_SUPPORTED if the underlying
123          * format does not have a mechanism for storing
124          * security descriptors.
125          */
126         WERROR (*get_sec_desc) (TALLOC_CTX *ctx,
127                                 const struct hive_key *key,
128                                 struct security_descriptor **desc);
129
130         /**
131          * Retrieve general information about a key.
132          */
133         WERROR (*get_key_info) (TALLOC_CTX *mem_ctx,
134                                 const struct hive_key *key,
135                                 const char **classname,
136                                 uint32_t *num_subkeys,
137                                 uint32_t *num_values,
138                                 NTTIME *last_change_time);
139 };
140
141 struct cli_credentials;
142 struct auth_session_info;
143
144 WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
145                      struct auth_session_info *session_info,
146                      struct cli_credentials *credentials,
147                      struct loadparm_context *lp_ctx,
148                      struct hive_key **root);
149 WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
150                          const char **classname, uint32_t *num_subkeys,
151                          uint32_t *num_values,
152                          NTTIME *last_change_time);
153 WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key,
154                          const char *name, const char *classname,
155                          struct security_descriptor *desc,
156                          struct hive_key **key);
157 WERROR hive_key_del(const struct hive_key *key, const char *name);
158 WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx,
159                             const struct hive_key *key, const char *name,
160                             struct hive_key **subkey);
161 WERROR hive_enum_key(TALLOC_CTX *mem_ctx,
162                      const struct hive_key *key, uint32_t idx,
163                      const char **name,
164                      const char **classname,
165                      NTTIME *last_mod_time);
166
167 WERROR hive_key_set_value(struct hive_key *key, const char *name,
168                       uint32_t type, const DATA_BLOB data);
169
170 WERROR hive_get_value(TALLOC_CTX *mem_ctx,
171                       struct hive_key *key, const char *name,
172                       uint32_t *type, DATA_BLOB *data);
173 WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
174                                struct hive_key *key, uint32_t idx,
175                                const char **name,
176                                uint32_t *type, DATA_BLOB *data);
177
178 WERROR hive_key_del_value(struct hive_key *key, const char *name);
179
180 WERROR hive_key_flush(struct hive_key *key);
181
182
183 /* Individual backends */
184 WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
185                           const char *location, struct hive_key **key);
186 WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
187                           const char *location, struct loadparm_context *lp_ctx,
188                           struct hive_key **key);
189 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
190                          struct auth_session_info *session_info,
191                          struct cli_credentials *credentials,
192                          struct loadparm_context *lp_ctx,
193                          struct hive_key **k);
194
195
196 WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
197                             const char *location, struct hive_key **key);
198 WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
199                             const char *location,
200                             int major_version,
201                             struct hive_key **key);
202
203
204 #endif /* __REGISTRY_HIVE_H__ */