2 * Unix SMB/CIFS implementation.
3 * Virtual Windows Registry Layer
5 * Copyright (C) Gerald Carter 2002-2005
6 * Copyright (C) Volker Lendecke 2006
7 * Copyright (C) Michael Adam 2006-2010
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
27 * A REG_SZ string is not necessarily NULL terminated. When retrieving it from
28 * the net, we guarantee this however. A server might want to push it without
29 * the terminator though.
32 struct registry_string
{
37 struct registry_value
{
38 enum winreg_Type type
;
42 struct registry_string sz
;
51 /* forward declarations. definitions in reg_objects.c */
56 * container for function pointers to enumeration routines
57 * for virtual registry view
61 /* functions for enumerating subkeys and values */
62 int (*fetch_subkeys
)( const char *key
, struct regsubkey_ctr
*subkeys
);
63 int (*fetch_values
) ( const char *key
, struct regval_ctr
*val
);
64 bool (*store_subkeys
)( const char *key
, struct regsubkey_ctr
*subkeys
);
65 WERROR (*create_subkey
)(const char *key
, const char *subkey
);
66 WERROR (*delete_subkey
)(const char *key
, const char *subkey
);
67 bool (*store_values
)( const char *key
, struct regval_ctr
*val
);
68 bool (*reg_access_check
)( const char *keyname
, uint32 requested
,
70 const NT_USER_TOKEN
*token
);
71 WERROR (*get_secdesc
)(TALLOC_CTX
*mem_ctx
, const char *key
,
72 struct security_descriptor
**psecdesc
);
73 WERROR (*set_secdesc
)(const char *key
,
74 struct security_descriptor
*sec_desc
);
75 bool (*subkeys_need_update
)(struct regsubkey_ctr
*subkeys
);
76 bool (*values_need_update
)(struct regval_ctr
*values
);
79 /* structure to store the registry handles */
81 struct registry_key_handle
{
83 char *name
; /* full name of registry key */
84 uint32 access_granted
;
85 struct registry_ops
*ops
;
89 struct registry_key_handle
*key
;
90 struct regsubkey_ctr
*subkeys
;
91 struct regval_ctr
*values
;
92 struct nt_user_token
*token
;
98 * Macros that used to reside in rpc_reg.h
102 #define HKEY_CLASSES_ROOT 0x80000000
103 #define HKEY_CURRENT_USER 0x80000001
104 #define HKEY_LOCAL_MACHINE 0x80000002
105 #define HKEY_USERS 0x80000003
106 #define HKEY_PERFORMANCE_DATA 0x80000004
108 #define KEY_HKLM "HKLM"
109 #define KEY_HKU "HKU"
110 #define KEY_HKCC "HKCC"
111 #define KEY_HKCR "HKCR"
112 #define KEY_HKPD "HKPD"
113 #define KEY_HKPT "HKPT"
114 #define KEY_HKPN "HKPN"
115 #define KEY_HKCU "HKCU"
116 #define KEY_HKDD "HKDD"
117 #define KEY_SERVICES "HKLM\\SYSTEM\\CurrentControlSet\\Services"
118 #define KEY_EVENTLOG "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
119 #define KEY_SHARES "HKLM\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares"
120 #define KEY_NETLOGON_PARAMS "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters"
121 #define KEY_TCPIP_PARAMS "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
122 #define KEY_PROD_OPTIONS "HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions"
123 #define KEY_PRINTING "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
124 #define KEY_PRINTING_2K "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers"
125 #define KEY_PRINTING_PORTS "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports"
126 #define KEY_CURRENT_VERSION "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
127 #define KEY_PERFLIB "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"
128 #define KEY_PERFLIB_009 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009"
129 #define KEY_GROUP_POLICY "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Group Policy"
130 #define KEY_WINLOGON "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"
131 #define KEY_SMBCONF "HKLM\\SOFTWARE\\Samba\\smbconf"
132 #define KEY_SAMBA_GROUP_POLICY "HKLM\\SOFTWARE\\Samba\\Group Policy"
133 #define KEY_TREE_ROOT ""
135 #define KEY_GP_MACHINE_POLICY "HKLM\\Software\\Policies"
136 #define KEY_GP_MACHINE_WIN_POLICY "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
137 #define KEY_GP_USER_POLICY "HKCU\\Software\\Policies"
138 #define KEY_GP_USER_WIN_POLICY "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
142 * Most keys are going to be GENERIC -- may need a better name?
143 * HKPD and HKPT are used by reg_perfcount.c
144 * they are special keys that contain performance data
146 #define REG_KEY_GENERIC 0
147 #define REG_KEY_HKPD 1
148 #define REG_KEY_HKPT 2
151 /* The following definitions come from registry/reg_api.c */
153 WERROR
reg_openhive(TALLOC_CTX
*mem_ctx
, const char *hive
,
154 uint32 desired_access
,
155 const struct nt_user_token
*token
,
156 struct registry_key
**pkey
);
157 WERROR
reg_openkey(TALLOC_CTX
*mem_ctx
, struct registry_key
*parent
,
158 const char *name
, uint32 desired_access
,
159 struct registry_key
**pkey
);
160 WERROR
reg_enumkey(TALLOC_CTX
*mem_ctx
, struct registry_key
*key
,
161 uint32 idx
, char **name
, NTTIME
*last_write_time
);
162 WERROR
reg_enumvalue(TALLOC_CTX
*mem_ctx
, struct registry_key
*key
,
163 uint32 idx
, char **pname
, struct registry_value
**pval
);
164 WERROR
reg_queryvalue(TALLOC_CTX
*mem_ctx
, struct registry_key
*key
,
165 const char *name
, struct registry_value
**pval
);
166 WERROR
reg_queryinfokey(struct registry_key
*key
, uint32_t *num_subkeys
,
167 uint32_t *max_subkeylen
, uint32_t *max_subkeysize
,
168 uint32_t *num_values
, uint32_t *max_valnamelen
,
169 uint32_t *max_valbufsize
, uint32_t *secdescsize
,
170 NTTIME
*last_changed_time
);
171 WERROR
reg_createkey(TALLOC_CTX
*ctx
, struct registry_key
*parent
,
172 const char *subkeypath
, uint32 desired_access
,
173 struct registry_key
**pkey
,
174 enum winreg_CreateAction
*paction
);
175 WERROR
reg_deletekey(struct registry_key
*parent
, const char *path
);
176 WERROR
reg_setvalue(struct registry_key
*key
, const char *name
,
177 const struct registry_value
*val
);
178 WERROR
reg_deletevalue(struct registry_key
*key
, const char *name
);
179 WERROR
reg_getkeysecurity(TALLOC_CTX
*mem_ctx
, struct registry_key
*key
,
180 struct security_descriptor
**psecdesc
);
181 WERROR
reg_setkeysecurity(struct registry_key
*key
,
182 struct security_descriptor
*psecdesc
);
183 WERROR
reg_getversion(uint32_t *version
);
184 WERROR
reg_restorekey(struct registry_key
*key
, const char *fname
);
185 WERROR
reg_savekey(struct registry_key
*key
, const char *fname
);
186 WERROR
reg_deleteallvalues(struct registry_key
*key
);
187 WERROR
reg_open_path(TALLOC_CTX
*mem_ctx
, const char *orig_path
,
188 uint32 desired_access
, const struct nt_user_token
*token
,
189 struct registry_key
**pkey
);
190 WERROR
reg_deletekey_recursive(TALLOC_CTX
*ctx
,
191 struct registry_key
*parent
,
193 WERROR
reg_deletesubkeys_recursive(TALLOC_CTX
*ctx
,
194 struct registry_key
*parent
,
196 WERROR
reg_create_path(TALLOC_CTX
*mem_ctx
, const char *orig_path
,
197 uint32 desired_access
,
198 const struct nt_user_token
*token
,
199 enum winreg_CreateAction
*paction
,
200 struct registry_key
**pkey
);
201 WERROR
reg_delete_path(const struct nt_user_token
*token
,
202 const char *orig_path
);
204 /* The following definitions come from registry/reg_init_basic.c */
206 WERROR
registry_init_common(void);
207 WERROR
registry_init_basic(void);
209 /* The following definitions come from registry/reg_init_full.c */
211 WERROR
registry_init_full(void);
213 /* The following definitions come from registry/reg_init_smbconf.c */
215 WERROR
registry_init_smbconf(const char *keyname
);
217 #endif /* _REGISTRY_H */