2 Unix SMB/CIFS implementation.
3 Registry hive interface
4 Copyright (C) Jelmer Vernooij 2003-2007.
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.
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.
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.
21 #ifndef __REGISTRY_HIVE_H__
22 #define __REGISTRY_HIVE_H__
25 #include "libcli/util/werror.h"
26 #include "librpc/gen_ndr/security.h"
27 #include "libcli/util/ntstatus.h"
30 * This file contains the hive API. This API is generally used for
31 * reading a specific file that contains just one hive.
33 * Good examples are .DAT (NTUSER.DAT) files.
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.
41 const struct hive_operations *ops;
44 struct hive_operations {
48 * Open a specific subkey
50 WERROR (*enum_key) (TALLOC_CTX *mem_ctx,
51 const struct hive_key *key, uint32_t idx,
53 const char **classname,
54 NTTIME *last_mod_time);
57 * Open a subkey by name
59 WERROR (*get_key_by_name) (TALLOC_CTX *mem_ctx,
60 const struct hive_key *key, const char *name,
61 struct hive_key **subkey);
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);
72 * Remove an existing key.
74 WERROR (*del_key) (const struct hive_key *key, const char *name);
77 * Force write of a key to disk.
79 WERROR (*flush_key) (struct hive_key *key);
82 * Retrieve a registry value with a specific index.
84 WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
85 struct hive_key *key, int idx,
86 const char **name, uint32_t *type,
90 * Retrieve a registry value with the specified name
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);
97 * Set a value on the specified registry key.
99 WERROR (*set_value) (struct hive_key *key, const char *name,
100 uint32_t type, const DATA_BLOB data);
105 WERROR (*delete_value) (struct hive_key *key, const char *name);
107 /* Security Descriptors */
110 * Change the security descriptor on a registry key.
112 * This should return WERR_NOT_SUPPORTED if the underlying
113 * format does not have a mechanism for storing
114 * security descriptors.
116 WERROR (*set_sec_desc) (struct hive_key *key,
117 const struct security_descriptor *desc);
120 * Retrieve the security descriptor on a registry key.
122 * This should return WERR_NOT_SUPPORTED if the underlying
123 * format does not have a mechanism for storing
124 * security descriptors.
126 WERROR (*get_sec_desc) (TALLOC_CTX *ctx,
127 const struct hive_key *key,
128 struct security_descriptor **desc);
131 * Retrieve general information about a key.
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 uint32_t *max_subkeynamelen,
140 uint32_t *max_valnamelen,
141 uint32_t *max_valbufsize);
144 struct cli_credentials;
145 struct auth_session_info;
147 WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
148 struct auth_session_info *session_info,
149 struct cli_credentials *credentials,
150 struct loadparm_context *lp_ctx,
151 struct hive_key **root);
152 WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
153 const char **classname, uint32_t *num_subkeys,
154 uint32_t *num_values, NTTIME *last_change_time,
155 uint32_t *max_subkeynamelen,
156 uint32_t *max_valnamelen, uint32_t *max_valbufsize);
157 WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key,
158 const char *name, const char *classname,
159 struct security_descriptor *desc,
160 struct hive_key **key);
161 WERROR hive_key_del(const struct hive_key *key, const char *name);
162 WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx,
163 const struct hive_key *key, const char *name,
164 struct hive_key **subkey);
165 WERROR hive_enum_key(TALLOC_CTX *mem_ctx,
166 const struct hive_key *key, uint32_t idx,
168 const char **classname,
169 NTTIME *last_mod_time);
171 WERROR hive_key_set_value(struct hive_key *key, const char *name,
172 uint32_t type, const DATA_BLOB data);
174 WERROR hive_get_value(TALLOC_CTX *mem_ctx,
175 struct hive_key *key, const char *name,
176 uint32_t *type, DATA_BLOB *data);
177 WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
178 struct hive_key *key, uint32_t idx,
180 uint32_t *type, DATA_BLOB *data);
182 WERROR hive_key_del_value(struct hive_key *key, const char *name);
184 WERROR hive_key_flush(struct hive_key *key);
187 /* Individual backends */
188 WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
189 const char *location, struct hive_key **key);
190 WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
191 const char *location, struct loadparm_context *lp_ctx,
192 struct hive_key **key);
193 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
194 struct auth_session_info *session_info,
195 struct cli_credentials *credentials,
196 struct loadparm_context *lp_ctx,
197 struct hive_key **k);
200 WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
201 const char *location, struct hive_key **key);
202 WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
203 const char *location,
205 struct hive_key **key);
208 #endif /* __REGISTRY_HIVE_H__ */