mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
registry: remove the REGISTRY_HOOKS layer from the reghook cache.
There is no need to save the keyname again, we only need to
get the REGISTRY_OPS out of the pathtree.
Furthermore, this makes life easier, since we can now pass
in keynames as temporarily allocated strings.
Michael
(This used to be commit 2f9ee2f782
)
This commit is contained in:
parent
a75421b019
commit
413c2e9b0a
@ -159,7 +159,7 @@ typedef struct _RegistryKey {
|
||||
uint32 type;
|
||||
char *name; /* full name of registry key */
|
||||
uint32 access_granted;
|
||||
REGISTRY_HOOK *hook;
|
||||
REGISTRY_OPS *ops;
|
||||
} REGISTRY_KEY;
|
||||
|
||||
struct registry_key {
|
||||
|
@ -183,9 +183,9 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
|
||||
|
||||
/* Look up the table of registry I/O operations */
|
||||
|
||||
if ( !(key->hook = reghook_cache_find( key->name )) ) {
|
||||
DEBUG(0,("reg_open_onelevel: Failed to assign a "
|
||||
"REGISTRY_HOOK to [%s]\n", key->name ));
|
||||
if ( !(key->ops = reghook_cache_find( key->name )) ) {
|
||||
DEBUG(0,("reg_open_onelevel: Failed to assign "
|
||||
"REGISTRY_OPS to [%s]\n", key->name ));
|
||||
result = WERR_BADFILE;
|
||||
goto done;
|
||||
}
|
||||
@ -733,9 +733,9 @@ static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath,
|
||||
|
||||
/* initialize the REGISTRY_KEY structure */
|
||||
|
||||
registry_key.hook = reghook_cache_find(topkeypath);
|
||||
if (!registry_key.hook) {
|
||||
DEBUG(0, ("reg_load_tree: Failed to assigned a REGISTRY_HOOK "
|
||||
registry_key.ops = reghook_cache_find(topkeypath);
|
||||
if (!registry_key.ops) {
|
||||
DEBUG(0, ("reg_load_tree: Failed to assign REGISTRY_OPS "
|
||||
"to [%s]\n", topkeypath));
|
||||
return WERR_BADFILE;
|
||||
}
|
||||
@ -898,8 +898,8 @@ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath,
|
||||
return WERR_NOMEM;
|
||||
}
|
||||
|
||||
registry_key.hook = reghook_cache_find(registry_key.name);
|
||||
if (registry_key.hook == NULL) {
|
||||
registry_key.ops = reghook_cache_find(registry_key.name);
|
||||
if (registry_key.ops == NULL) {
|
||||
return WERR_BADFILE;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
static SORTED_TREE *cache_tree = NULL;
|
||||
extern REGISTRY_OPS regdb_ops; /* these are the default */
|
||||
static REGISTRY_HOOK default_hook = { KEY_TREE_ROOT, ®db_ops };
|
||||
|
||||
/**********************************************************************
|
||||
Initialize the cache tree if it has not been initialized yet.
|
||||
@ -36,7 +35,7 @@ static REGISTRY_HOOK default_hook = { KEY_TREE_ROOT, ®db_ops };
|
||||
bool reghook_cache_init( void )
|
||||
{
|
||||
if (cache_tree == NULL) {
|
||||
cache_tree = pathtree_init(&default_hook, NULL);
|
||||
cache_tree = pathtree_init(®db_ops, NULL);
|
||||
if (cache_tree !=0) {
|
||||
DEBUG(10, ("reghook_cache_init: new tree with default "
|
||||
"ops %p for key [%s]\n", (void *)®db_ops,
|
||||
@ -48,20 +47,20 @@ bool reghook_cache_init( void )
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Add a new REGISTRY_HOOK to the cache. Note that the keyname
|
||||
Add a new registry hook to the cache. Note that the keyname
|
||||
is not in the exact format that a SORTED_TREE expects.
|
||||
*********************************************************************/
|
||||
|
||||
bool reghook_cache_add( REGISTRY_HOOK *hook )
|
||||
bool reghook_cache_add(const char *keyname, REGISTRY_OPS *ops)
|
||||
{
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
char *key = NULL;
|
||||
|
||||
if (!hook) {
|
||||
if ((keyname == NULL) || (ops == NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
key = talloc_asprintf(ctx, "\\%s", hook->keyname);
|
||||
key = talloc_asprintf(ctx, "\\%s", keyname);
|
||||
if (!key) {
|
||||
return false;
|
||||
}
|
||||
@ -71,20 +70,20 @@ bool reghook_cache_add( REGISTRY_HOOK *hook )
|
||||
}
|
||||
|
||||
DEBUG(10, ("reghook_cache_add: Adding ops %p for key [%s]\n",
|
||||
(void *)hook->ops, key));
|
||||
(void *)ops, key));
|
||||
|
||||
return pathtree_add( cache_tree, key, hook );
|
||||
return pathtree_add(cache_tree, key, ops);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Initialize the cache tree
|
||||
*********************************************************************/
|
||||
|
||||
REGISTRY_HOOK* reghook_cache_find( const char *keyname )
|
||||
REGISTRY_OPS *reghook_cache_find(const char *keyname)
|
||||
{
|
||||
char *key;
|
||||
int len;
|
||||
REGISTRY_HOOK *hook;
|
||||
REGISTRY_OPS *ops;
|
||||
|
||||
if ( !keyname )
|
||||
return NULL;
|
||||
@ -107,14 +106,14 @@ REGISTRY_HOOK* reghook_cache_find( const char *keyname )
|
||||
|
||||
DEBUG(10,("reghook_cache_find: Searching for keyname [%s]\n", key));
|
||||
|
||||
hook = (REGISTRY_HOOK *)pathtree_find( cache_tree, key ) ;
|
||||
ops = (REGISTRY_OPS *)pathtree_find(cache_tree, key);
|
||||
|
||||
DEBUG(10, ("reghook_cache_find: found ops %p for key [%s]\n",
|
||||
hook ? (void *)hook->ops : 0, key));
|
||||
ops ? (void *)ops : 0, key));
|
||||
|
||||
SAFE_FREE( key );
|
||||
|
||||
return hook;
|
||||
return ops;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -86,8 +86,8 @@ static WERROR construct_registry_sd(TALLOC_CTX *ctx, SEC_DESC **psd)
|
||||
|
||||
bool store_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys )
|
||||
{
|
||||
if ( key->hook && key->hook->ops && key->hook->ops->store_subkeys )
|
||||
return key->hook->ops->store_subkeys( key->name, subkeys );
|
||||
if (key->ops && key->ops->store_subkeys)
|
||||
return key->ops->store_subkeys(key->name, subkeys);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -98,8 +98,8 @@ bool store_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys )
|
||||
|
||||
bool store_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val )
|
||||
{
|
||||
if ( key->hook && key->hook->ops && key->hook->ops->store_values )
|
||||
return key->hook->ops->store_values( key->name, val );
|
||||
if (key->ops && key->ops->store_values)
|
||||
return key->ops->store_values(key->name, val);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -113,8 +113,8 @@ int fetch_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkey_ctr )
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
if ( key->hook && key->hook->ops && key->hook->ops->fetch_subkeys )
|
||||
result = key->hook->ops->fetch_subkeys( key->name, subkey_ctr );
|
||||
if (key->ops && key->ops->fetch_subkeys)
|
||||
result = key->ops->fetch_subkeys(key->name, subkey_ctr);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -128,10 +128,10 @@ int fetch_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val )
|
||||
int result = -1;
|
||||
|
||||
DEBUG(10, ("fetch_reg_values called for key '%s' (ops %p)\n", key->name,
|
||||
(key->hook && key->hook->ops) ? (void *)key->hook->ops : NULL));
|
||||
(key->ops) ? (void *)key->ops : NULL));
|
||||
|
||||
if ( key->hook && key->hook->ops && key->hook->ops->fetch_values )
|
||||
result = key->hook->ops->fetch_values( key->name, val );
|
||||
if (key->ops && key->ops->fetch_values)
|
||||
result = key->ops->fetch_values(key->name, val);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -152,9 +152,9 @@ bool regkey_access_check( REGISTRY_KEY *key, uint32 requested, uint32 *granted,
|
||||
/* use the default security check if the backend has not defined its
|
||||
* own */
|
||||
|
||||
if (key->hook && key->hook->ops && key->hook->ops->reg_access_check) {
|
||||
return key->hook->ops->reg_access_check( key->name, requested,
|
||||
granted, token );
|
||||
if (key->ops && key->ops->reg_access_check) {
|
||||
return key->ops->reg_access_check(key->name, requested,
|
||||
granted, token);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -189,9 +189,8 @@ WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, REGISTRY_KEY *key,
|
||||
struct security_descriptor *secdesc;
|
||||
WERROR werr;
|
||||
|
||||
if (key->hook && key->hook->ops && key->hook->ops->get_secdesc) {
|
||||
werr = key->hook->ops->get_secdesc(mem_ctx, key->name,
|
||||
psecdesc);
|
||||
if (key->ops && key->ops->get_secdesc) {
|
||||
werr = key->ops->get_secdesc(mem_ctx, key->name, psecdesc);
|
||||
if (W_ERROR_IS_OK(werr)) {
|
||||
return WERR_OK;
|
||||
}
|
||||
@ -209,8 +208,8 @@ WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, REGISTRY_KEY *key,
|
||||
WERROR regkey_set_secdesc(REGISTRY_KEY *key,
|
||||
struct security_descriptor *psecdesc)
|
||||
{
|
||||
if (key->hook && key->hook->ops && key->hook->ops->set_secdesc) {
|
||||
return key->hook->ops->set_secdesc(key->name, psecdesc);
|
||||
if (key->ops && key->ops->set_secdesc) {
|
||||
return key->ops->set_secdesc(key->name, psecdesc);
|
||||
}
|
||||
|
||||
return WERR_ACCESS_DENIED;
|
||||
@ -222,9 +221,9 @@ WERROR regkey_set_secdesc(REGISTRY_KEY *key,
|
||||
*/
|
||||
bool reg_subkeys_need_update(REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys)
|
||||
{
|
||||
if (key->hook && key->hook->ops && key->hook->ops->subkeys_need_update)
|
||||
if (key->ops && key->ops->subkeys_need_update)
|
||||
{
|
||||
return key->hook->ops->subkeys_need_update(subkeys);
|
||||
return key->ops->subkeys_need_update(subkeys);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -236,9 +235,9 @@ bool reg_subkeys_need_update(REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys)
|
||||
*/
|
||||
bool reg_values_need_update(REGISTRY_KEY *key, REGVAL_CTR *values)
|
||||
{
|
||||
if (key->hook && key->hook->ops && key->hook->ops->values_need_update)
|
||||
if (key->ops && key->ops->values_need_update)
|
||||
{
|
||||
return key->hook->ops->values_need_update(values);
|
||||
return key->ops->values_need_update(values);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -86,7 +86,7 @@ bool init_registry( void )
|
||||
reghook_cache_init();
|
||||
|
||||
for ( i=0; reg_hooks[i].keyname; i++ ) {
|
||||
if ( !reghook_cache_add(®_hooks[i]) )
|
||||
if (!reghook_cache_add(reg_hooks[i].keyname, reg_hooks[i].ops))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,6 @@ bool registry_init_smbconf(void)
|
||||
{
|
||||
bool ret = false;
|
||||
int saved_errno = 0;
|
||||
static REGISTRY_HOOK smbconf_reg_hook = {KEY_SMBCONF, &smbconf_reg_ops};
|
||||
|
||||
DEBUG(10, ("registry_init_smbconf called\n"));
|
||||
|
||||
@ -90,7 +89,7 @@ bool registry_init_smbconf(void)
|
||||
goto done;
|
||||
}
|
||||
reghook_cache_init();
|
||||
if (!reghook_cache_add(&smbconf_reg_hook)) {
|
||||
if (!reghook_cache_add(KEY_SMBCONF, &smbconf_reg_ops)) {
|
||||
DEBUG(1, ("Error adding smbconf reghooks to reghook cache.\n"));
|
||||
goto done;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ END {
|
||||
gotstart = 1;
|
||||
}
|
||||
|
||||
if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_VALUE|^REGVAL_CTR|^DEVICEMODE|^PAC_DATA|^NET_USER_INFO_3|^smb_event_id_t/ ) {
|
||||
if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_OPS|^REGISTRY_VALUE|^REGVAL_CTR|^DEVICEMODE|^PAC_DATA|^NET_USER_INFO_3|^smb_event_id_t/ ) {
|
||||
gotstart = 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user