2005-05-23 20:25:31 +04:00
/*
2006-09-27 23:03:54 +04:00
Samba ' s Internal Registry objects
2005-05-23 20:25:31 +04:00
SMB parameters and setup
2006-09-27 23:03:54 +04:00
Copyright ( C ) Gerald Carter 2002 - 2006.
2005-05-23 20:25:31 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2005-05-23 20:25:31 +04:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-05-23 20:25:31 +04:00
*/
# ifndef _REG_OBJECTS_H /* _REG_OBJECTS_H */
# define _REG_OBJECTS_H
2009-03-24 01:18:26 +03:00
/* low level structure to contain registry values */
2005-05-23 20:25:31 +04:00
2009-03-24 00:27:59 +03:00
struct regval_blob {
2005-05-23 20:25:31 +04:00
fstring valuename ;
uint16 type ;
2005-06-24 18:55:09 +04:00
/* this should be encapsulated in an RPC_DATA_BLOB */
2005-05-23 20:25:31 +04:00
uint32 size ; /* in bytes */
uint8 * data_p ;
2009-03-24 00:27:59 +03:00
} ;
2005-05-23 20:25:31 +04:00
2006-11-21 02:20:07 +03:00
/*
2006-11-21 05:21:45 +03:00
* A REG_SZ string is not necessarily NULL terminated . When retrieving it from
* the net , we guarantee this however . A server might want to push it without
* the terminator though .
2006-11-21 02:20:07 +03:00
*/
struct registry_string {
size_t len ;
char * str ;
} ;
struct registry_value {
enum winreg_Type type ;
union {
uint32 dword ;
uint64 qword ;
struct registry_string sz ;
struct {
uint32 num_strings ;
2006-11-21 05:21:45 +03:00
char * * strings ;
2006-11-21 02:20:07 +03:00
} multi_sz ;
DATA_BLOB binary ;
} v ;
} ;
2005-05-23 20:25:31 +04:00
/* container for registry values */
2009-03-23 20:14:17 +03:00
struct regval_ctr {
2005-05-23 20:25:31 +04:00
uint32 num_values ;
2009-03-24 00:27:59 +03:00
struct regval_blob * * values ;
2008-01-14 20:31:11 +03:00
int seqnum ;
2009-03-23 20:14:17 +03:00
} ;
2005-05-23 20:25:31 +04:00
/* container for registry subkey names */
2009-02-25 02:33:24 +03:00
struct regsubkey_ctr ;
2005-05-23 20:25:31 +04:00
2006-09-27 23:03:54 +04:00
/*
*
* Macros that used to reside in rpc_reg . h
*
*/
# define HKEY_CLASSES_ROOT 0x80000000
# define HKEY_CURRENT_USER 0x80000001
# define HKEY_LOCAL_MACHINE 0x80000002
# define HKEY_USERS 0x80000003
# define HKEY_PERFORMANCE_DATA 0x80000004
# define KEY_HKLM "HKLM"
# define KEY_HKU "HKU"
# define KEY_HKCC "HKCC"
# define KEY_HKCR "HKCR"
# define KEY_HKPD "HKPD"
# define KEY_HKPT "HKPT"
# define KEY_HKPN "HKPN"
# define KEY_HKCU "HKCU"
# define KEY_HKDD "HKDD"
# define KEY_SERVICES "HKLM\\SYSTEM\\CurrentControlSet\\Services"
# define KEY_EVENTLOG "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
# define KEY_SHARES "HKLM\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares"
2008-01-18 11:40:42 +03:00
# define KEY_NETLOGON_PARAMS "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters"
2008-01-20 01:46:13 +03:00
# define KEY_TCPIP_PARAMS "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
2008-01-20 04:23:00 +03:00
# define KEY_PROD_OPTIONS "HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions"
# define KEY_PRINTING "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
# define KEY_PRINTING_2K "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers"
# define KEY_PRINTING_PORTS "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports"
2008-01-20 05:24:13 +03:00
# define KEY_CURRENT_VERSION "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
2008-01-20 05:39:27 +03:00
# define KEY_PERFLIB "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"
# define KEY_PERFLIB_009 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009"
2008-02-29 17:46:14 +03:00
# define KEY_GROUP_POLICY "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Group Policy"
# define KEY_WINLOGON "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"
2008-01-20 04:23:00 +03:00
# define KEY_SMBCONF "HKLM\\SOFTWARE\\Samba\\smbconf"
2008-02-29 17:46:14 +03:00
# define KEY_SAMBA_GROUP_POLICY "HKLM\\SOFTWARE\\Samba\\Group Policy"
2006-09-27 23:03:54 +04:00
# define KEY_TREE_ROOT ""
2008-02-29 17:46:14 +03:00
# define KEY_GP_MACHINE_POLICY "HKLM\\Software\\Policies"
# define KEY_GP_MACHINE_WIN_POLICY "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
# define KEY_GP_USER_POLICY "HKCU\\Software\\Policies"
# define KEY_GP_USER_WIN_POLICY "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
2006-09-27 23:03:54 +04:00
/*
* Registry key types
* Most keys are going to be GENERIC - - may need a better name ?
* HKPD and HKPT are used by reg_perfcount . c
* they are special keys that contain performance data
*/
# define REG_KEY_GENERIC 0
# define REG_KEY_HKPD 1
# define REG_KEY_HKPT 2
/*
* container for function pointers to enumeration routines
* for virtual registry view
*/
2009-03-24 01:14:45 +03:00
struct registry_ops {
2006-09-27 23:03:54 +04:00
/* functions for enumerating subkeys and values */
2009-02-24 17:19:18 +03:00
int ( * fetch_subkeys ) ( const char * key , struct regsubkey_ctr * subkeys ) ;
2009-03-23 20:14:17 +03:00
int ( * fetch_values ) ( const char * key , struct regval_ctr * val ) ;
2009-02-24 17:19:18 +03:00
bool ( * store_subkeys ) ( const char * key , struct regsubkey_ctr * subkeys ) ;
2009-02-25 23:59:54 +03:00
WERROR ( * create_subkey ) ( const char * key , const char * subkey ) ;
2009-02-26 04:54:50 +03:00
WERROR ( * delete_subkey ) ( const char * key , const char * subkey ) ;
2009-03-23 20:14:17 +03:00
bool ( * store_values ) ( const char * key , struct regval_ctr * val ) ;
2007-10-19 04:40:25 +04:00
bool ( * reg_access_check ) ( const char * keyname , uint32 requested ,
2006-11-30 10:38:40 +03:00
uint32 * granted ,
const NT_USER_TOKEN * token ) ;
WERROR ( * get_secdesc ) ( TALLOC_CTX * mem_ctx , const char * key ,
struct security_descriptor * * psecdesc ) ;
WERROR ( * set_secdesc ) ( const char * key ,
struct security_descriptor * sec_desc ) ;
2009-02-24 17:19:18 +03:00
bool ( * subkeys_need_update ) ( struct regsubkey_ctr * subkeys ) ;
2009-03-23 20:14:17 +03:00
bool ( * values_need_update ) ( struct regval_ctr * values ) ;
2009-03-24 01:14:45 +03:00
} ;
2006-09-27 23:03:54 +04:00
/* structure to store the registry handles */
2009-03-24 01:02:57 +03:00
struct registry_key_handle {
2006-09-27 23:03:54 +04:00
uint32 type ;
char * name ; /* full name of registry key */
uint32 access_granted ;
2009-03-24 01:14:45 +03:00
struct registry_ops * ops ;
2009-03-24 01:02:57 +03:00
} ;
2006-09-27 23:03:54 +04:00
2006-12-01 23:01:09 +03:00
struct registry_key {
2009-03-24 01:02:57 +03:00
struct registry_key_handle * key ;
2009-02-24 17:19:18 +03:00
struct regsubkey_ctr * subkeys ;
2009-03-23 20:14:17 +03:00
struct regval_ctr * values ;
2006-12-01 23:01:09 +03:00
struct nt_user_token * token ;
} ;
2005-05-23 20:25:31 +04:00
2009-10-02 02:17:06 +04:00
/* The following definitions come from registry/reg_objects.c */
WERROR regsubkey_ctr_init ( TALLOC_CTX * mem_ctx , struct regsubkey_ctr * * ctr ) ;
WERROR regsubkey_ctr_reinit ( struct regsubkey_ctr * ctr ) ;
WERROR regsubkey_ctr_set_seqnum ( struct regsubkey_ctr * ctr , int seqnum ) ;
int regsubkey_ctr_get_seqnum ( struct regsubkey_ctr * ctr ) ;
WERROR regsubkey_ctr_addkey ( struct regsubkey_ctr * ctr , const char * keyname ) ;
WERROR regsubkey_ctr_delkey ( struct regsubkey_ctr * ctr , const char * keyname ) ;
bool regsubkey_ctr_key_exists ( struct regsubkey_ctr * ctr , const char * keyname ) ;
int regsubkey_ctr_numkeys ( struct regsubkey_ctr * ctr ) ;
char * regsubkey_ctr_specific_key ( struct regsubkey_ctr * ctr , uint32 key_index ) ;
2010-05-24 00:47:53 +04:00
WERROR regval_ctr_init ( TALLOC_CTX * mem_ctx , struct regval_ctr * * ctr ) ;
2009-10-02 02:17:06 +04:00
int regval_ctr_numvals ( struct regval_ctr * ctr ) ;
struct regval_blob * dup_registry_value ( struct regval_blob * val ) ;
void free_registry_value ( struct regval_blob * val ) ;
uint8 * regval_data_p ( struct regval_blob * val ) ;
uint32 regval_size ( struct regval_blob * val ) ;
char * regval_name ( struct regval_blob * val ) ;
uint32 regval_type ( struct regval_blob * val ) ;
struct regval_blob * regval_ctr_specific_value ( struct regval_ctr * ctr ,
uint32 idx ) ;
bool regval_ctr_key_exists ( struct regval_ctr * ctr , const char * value ) ;
struct regval_blob * regval_compose ( TALLOC_CTX * ctx , const char * name ,
uint16 type ,
2010-05-24 17:00:29 +04:00
const uint8 * data_p , size_t size ) ;
2009-10-02 02:17:06 +04:00
int regval_ctr_addvalue ( struct regval_ctr * ctr , const char * name , uint16 type ,
2010-05-24 17:15:33 +04:00
const uint8 * data_p , size_t size ) ;
2009-10-02 02:17:06 +04:00
int regval_ctr_addvalue_sz ( struct regval_ctr * ctr , const char * name , const char * data ) ;
int regval_ctr_addvalue_multi_sz ( struct regval_ctr * ctr , const char * name , const char * * data ) ;
int regval_ctr_copyvalue ( struct regval_ctr * ctr , struct regval_blob * val ) ;
int regval_ctr_delvalue ( struct regval_ctr * ctr , const char * name ) ;
struct regval_blob * regval_ctr_getvalue ( struct regval_ctr * ctr ,
const char * name ) ;
2010-05-24 00:53:44 +04:00
int regval_ctr_get_seqnum ( struct regval_ctr * ctr ) ;
2009-10-02 02:17:06 +04:00
uint32 regval_dword ( struct regval_blob * val ) ;
const char * regval_sz ( struct regval_blob * val ) ;
2006-12-01 23:01:09 +03:00
# endif /* _REG_OBJECTS_H */