2 Samba's Internal Registry objects
4 SMB parameters and setup
5 Copyright (C) Gerald Carter 2002-2006.
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 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef _REG_OBJECTS_H /* _REG_OBJECTS_H */
22 #define _REG_OBJECTS_H
24 /* low level structure to contain registry values */
29 /* this should be encapsulated in an RPC_DATA_BLOB */
30 uint32 size
; /* in bytes */
35 * A REG_SZ string is not necessarily NULL terminated. When retrieving it from
36 * the net, we guarantee this however. A server might want to push it without
37 * the terminator though.
40 struct registry_string
{
45 struct registry_value
{
46 enum winreg_Type type
;
50 struct registry_string sz
;
59 /* container for registry values */
63 struct regval_blob
**values
;
67 /* container for registry subkey names */
73 * Macros that used to reside in rpc_reg.h
77 #define HKEY_CLASSES_ROOT 0x80000000
78 #define HKEY_CURRENT_USER 0x80000001
79 #define HKEY_LOCAL_MACHINE 0x80000002
80 #define HKEY_USERS 0x80000003
81 #define HKEY_PERFORMANCE_DATA 0x80000004
83 #define KEY_HKLM "HKLM"
85 #define KEY_HKCC "HKCC"
86 #define KEY_HKCR "HKCR"
87 #define KEY_HKPD "HKPD"
88 #define KEY_HKPT "HKPT"
89 #define KEY_HKPN "HKPN"
90 #define KEY_HKCU "HKCU"
91 #define KEY_HKDD "HKDD"
92 #define KEY_SERVICES "HKLM\\SYSTEM\\CurrentControlSet\\Services"
93 #define KEY_EVENTLOG "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
94 #define KEY_SHARES "HKLM\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares"
95 #define KEY_NETLOGON_PARAMS "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters"
96 #define KEY_TCPIP_PARAMS "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
97 #define KEY_PROD_OPTIONS "HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions"
98 #define KEY_PRINTING "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
99 #define KEY_PRINTING_2K "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers"
100 #define KEY_PRINTING_PORTS "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports"
101 #define KEY_CURRENT_VERSION "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
102 #define KEY_PERFLIB "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"
103 #define KEY_PERFLIB_009 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009"
104 #define KEY_GROUP_POLICY "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Group Policy"
105 #define KEY_WINLOGON "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"
106 #define KEY_SMBCONF "HKLM\\SOFTWARE\\Samba\\smbconf"
107 #define KEY_SAMBA_GROUP_POLICY "HKLM\\SOFTWARE\\Samba\\Group Policy"
108 #define KEY_TREE_ROOT ""
110 #define KEY_GP_MACHINE_POLICY "HKLM\\Software\\Policies"
111 #define KEY_GP_MACHINE_WIN_POLICY "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
112 #define KEY_GP_USER_POLICY "HKCU\\Software\\Policies"
113 #define KEY_GP_USER_WIN_POLICY "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
116 * Most keys are going to be GENERIC -- may need a better name?
117 * HKPD and HKPT are used by reg_perfcount.c
118 * they are special keys that contain performance data
120 #define REG_KEY_GENERIC 0
121 #define REG_KEY_HKPD 1
122 #define REG_KEY_HKPT 2
125 * container for function pointers to enumeration routines
126 * for virtual registry view
129 struct registry_ops
{
130 /* functions for enumerating subkeys and values */
131 int (*fetch_subkeys
)( const char *key
, struct regsubkey_ctr
*subkeys
);
132 int (*fetch_values
) ( const char *key
, struct regval_ctr
*val
);
133 bool (*store_subkeys
)( const char *key
, struct regsubkey_ctr
*subkeys
);
134 WERROR (*create_subkey
)(const char *key
, const char *subkey
);
135 WERROR (*delete_subkey
)(const char *key
, const char *subkey
);
136 bool (*store_values
)( const char *key
, struct regval_ctr
*val
);
137 bool (*reg_access_check
)( const char *keyname
, uint32 requested
,
139 const NT_USER_TOKEN
*token
);
140 WERROR (*get_secdesc
)(TALLOC_CTX
*mem_ctx
, const char *key
,
141 struct security_descriptor
**psecdesc
);
142 WERROR (*set_secdesc
)(const char *key
,
143 struct security_descriptor
*sec_desc
);
144 bool (*subkeys_need_update
)(struct regsubkey_ctr
*subkeys
);
145 bool (*values_need_update
)(struct regval_ctr
*values
);
149 /* structure to store the registry handles */
151 struct registry_key_handle
{
153 char *name
; /* full name of registry key */
154 uint32 access_granted
;
155 struct registry_ops
*ops
;
158 struct registry_key
{
159 struct registry_key_handle
*key
;
160 struct regsubkey_ctr
*subkeys
;
161 struct regval_ctr
*values
;
162 struct nt_user_token
*token
;
165 /* The following definitions come from registry/reg_objects.c */
167 WERROR
regsubkey_ctr_init(TALLOC_CTX
*mem_ctx
, struct regsubkey_ctr
**ctr
);
168 WERROR
regsubkey_ctr_reinit(struct regsubkey_ctr
*ctr
);
169 WERROR
regsubkey_ctr_set_seqnum(struct regsubkey_ctr
*ctr
, int seqnum
);
170 int regsubkey_ctr_get_seqnum(struct regsubkey_ctr
*ctr
);
171 WERROR
regsubkey_ctr_addkey( struct regsubkey_ctr
*ctr
, const char *keyname
);
172 WERROR
regsubkey_ctr_delkey( struct regsubkey_ctr
*ctr
, const char *keyname
);
173 bool regsubkey_ctr_key_exists( struct regsubkey_ctr
*ctr
, const char *keyname
);
174 int regsubkey_ctr_numkeys( struct regsubkey_ctr
*ctr
);
175 char* regsubkey_ctr_specific_key( struct regsubkey_ctr
*ctr
, uint32 key_index
);
176 WERROR
regval_ctr_init(TALLOC_CTX
*mem_ctx
, struct regval_ctr
**ctr
);
177 int regval_ctr_numvals(struct regval_ctr
*ctr
);
178 struct regval_blob
* dup_registry_value(struct regval_blob
*val
);
179 void free_registry_value(struct regval_blob
*val
);
180 uint8
* regval_data_p(struct regval_blob
*val
);
181 uint32
regval_size(struct regval_blob
*val
);
182 char* regval_name(struct regval_blob
*val
);
183 uint32
regval_type(struct regval_blob
*val
);
184 struct regval_blob
* regval_ctr_specific_value(struct regval_ctr
*ctr
,
186 bool regval_ctr_key_exists(struct regval_ctr
*ctr
, const char *value
);
187 struct regval_blob
*regval_compose(TALLOC_CTX
*ctx
, const char *name
,
189 const uint8
*data_p
, size_t size
);
190 int regval_ctr_addvalue(struct regval_ctr
*ctr
, const char *name
, uint16 type
,
191 const uint8
*data_p
, size_t size
);
192 int regval_ctr_addvalue_sz(struct regval_ctr
*ctr
, const char *name
, const char *data
);
193 int regval_ctr_addvalue_multi_sz(struct regval_ctr
*ctr
, const char *name
, const char **data
);
194 int regval_ctr_copyvalue(struct regval_ctr
*ctr
, struct regval_blob
*val
);
195 int regval_ctr_delvalue(struct regval_ctr
*ctr
, const char *name
);
196 struct regval_blob
* regval_ctr_getvalue(struct regval_ctr
*ctr
,
198 int regval_ctr_get_seqnum(struct regval_ctr
*ctr
);
199 WERROR
regval_ctr_set_seqnum(struct regval_ctr
*ctr
, int seqnum
);
200 uint32
regval_dword(struct regval_blob
*val
);
201 const char *regval_sz(struct regval_blob
*val
);
204 #endif /* _REG_OBJECTS_H */