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__
26 #include "librpc/gen_ndr/security.h"
29 * This file contains the hive API. This API is generally used for
30 * reading a specific file that contains just one hive.
32 * Good examples are .DAT (NTUSER.DAT) files.
34 * This API does not have any notification support (that
35 * should be provided by the registry implementation), nor
36 * does it understand what predefined keys are.
40 const struct hive_operations *ops;
43 struct hive_operations {
47 * Open a specific subkey
49 WERROR (*enum_key) (TALLOC_CTX *mem_ctx,
50 const struct hive_key *key, uint32_t idx,
52 const char **classname,
53 NTTIME *last_mod_time);
56 * Open a subkey by name
58 WERROR (*get_key_by_name) (TALLOC_CTX *mem_ctx,
59 const struct hive_key *key, const char *name,
60 struct hive_key **subkey);
65 WERROR (*add_key) (TALLOC_CTX *ctx,
66 const struct hive_key *parent_key, const char *name,
67 const char *classname, struct security_descriptor *desc,
68 struct hive_key **key);
70 * Remove an existing key.
72 WERROR (*del_key) (const struct hive_key *key, const char *name);
75 * Force write of a key to disk.
77 WERROR (*flush_key) (struct hive_key *key);
80 * Retrieve a registry value with a specific index.
82 WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
83 const struct hive_key *key, int idx,
84 const char **name, uint32_t *type,
88 * Retrieve a registry value with the specified name
90 WERROR (*get_value_by_name) (TALLOC_CTX *mem_ctx,
91 struct hive_key *key, const char *name,
92 uint32_t *type, DATA_BLOB *data);
95 * Set a value on the specified registry key.
97 WERROR (*set_value) (struct hive_key *key, const char *name,
98 uint32_t type, const DATA_BLOB data);
103 WERROR (*delete_value) (struct hive_key *key, const char *name);
105 /* Security Descriptors */
108 * Change the security descriptor on a registry key.
110 * This should return WERR_NOT_SUPPORTED if the underlying
111 * format does not have a mechanism for storing
112 * security descriptors.
114 WERROR (*set_sec_desc) (struct hive_key *key,
115 const struct security_descriptor *desc);
118 * Retrieve the security descriptor on a registry key.
120 * This should return WERR_NOT_SUPPORTED if the underlying
121 * format does not have a mechanism for storing
122 * security descriptors.
124 WERROR (*get_sec_desc) (TALLOC_CTX *ctx,
125 const struct hive_key *key,
126 struct security_descriptor **desc);
129 * Retrieve general information about a key.
131 WERROR (*get_key_info) (TALLOC_CTX *mem_ctx,
132 const struct hive_key *key,
133 const char **classname,
134 uint32_t *num_subkeys,
135 uint32_t *num_values,
136 NTTIME *last_change_time);
139 struct cli_credentials;
140 struct auth_session_info;
142 WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
143 struct auth_session_info *session_info,
144 struct cli_credentials *credentials,
145 struct hive_key **root);
146 WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
147 const char **classname, uint32_t *num_subkeys,
148 uint32_t *num_values,
149 NTTIME *last_change_time);
150 WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key,
151 const char *name, const char *classname, struct security_descriptor *desc,
152 struct hive_key **key);
153 _PUBLIC_ WERROR hive_key_del(const struct hive_key *key, const char *name);
154 _PUBLIC_ WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx,
155 const struct hive_key *key, const char *name,
156 struct hive_key **subkey);
157 WERROR hive_enum_key(TALLOC_CTX *mem_ctx,
158 const struct hive_key *key, uint32_t idx,
160 const char **classname,
161 NTTIME *last_mod_time);
163 WERROR hive_set_value (struct hive_key *key, const char *name,
164 uint32_t type, const DATA_BLOB data);
166 WERROR hive_get_value (TALLOC_CTX *mem_ctx,
167 struct hive_key *key, const char *name,
168 uint32_t *type, DATA_BLOB *data);
169 WERROR hive_get_value_by_index (TALLOC_CTX *mem_ctx,
170 struct hive_key *key, uint32_t idx, const char **name,
171 uint32_t *type, DATA_BLOB *data);
173 WERROR hive_del_value (struct hive_key *key, const char *name);
175 WERROR hive_key_flush(struct hive_key *key);
178 /* Individual backends */
179 WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
180 const char *location, struct hive_key **key);
181 WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
182 const char *location, struct hive_key **key);
183 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
184 struct auth_session_info *session_info,
185 struct cli_credentials *credentials,
186 struct hive_key **k);
189 WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
190 const char *location, struct hive_key **key);
191 WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
192 const char *location,
194 struct hive_key **key);
197 #endif /* __REGISTRY_HIVE_H__ */