[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-853-g9841ee7
Michael Adam
obnox at samba.org
Sat Apr 12 23:49:25 GMT 2008
The branch, v3-2-test has been updated
via 9841ee7fd429c7ff367dbb43b754cd5b6f53c065 (commit)
via c9f01aee37165216fa8a5331c64dd93963b38802 (commit)
via 3f5955d361da5278773b46dccb34c8f63eb04157 (commit)
via acb9c98dff7dac5e0688a04dbf6d63a7a7f67fd2 (commit)
via 2e762be0db7a098b6da09756a9c9dfa3931ca3c6 (commit)
via 2f9ee2f782c77ed99669af5ac2ba40cb0978f0da (commit)
from 84608e165e24c68c12d40086f81684ef37f69159 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 9841ee7fd429c7ff367dbb43b754cd5b6f53c065
Author: Michael Adam <obnox at samba.org>
Date: Sun Apr 13 01:47:16 2008 +0200
registry cachehook: add talloc failed debug messages.
Michael
commit c9f01aee37165216fa8a5331c64dd93963b38802
Author: Michael Adam <obnox at samba.org>
Date: Sun Apr 13 01:44:57 2008 +0200
registry cachehook: eliminate a couple trailing spaces (empty lines).
Michael
commit 3f5955d361da5278773b46dccb34c8f63eb04157
Author: Michael Adam <obnox at samba.org>
Date: Sun Apr 13 01:42:46 2008 +0200
registry cachehook: fix memleak (to talloc_tos()): free key at the end.
Michael
commit acb9c98dff7dac5e0688a04dbf6d63a7a7f67fd2
Author: Michael Adam <obnox at samba.org>
Date: Sun Apr 13 01:40:45 2008 +0200
registry cachehook: refactor normalization of keyname out.
Michael
commit 2e762be0db7a098b6da09756a9c9dfa3931ca3c6
Author: Michael Adam <obnox at samba.org>
Date: Sun Apr 13 01:32:51 2008 +0200
registry: adapt copied function header comments.
Michael
commit 2f9ee2f782c77ed99669af5ac2ba40cb0978f0da
Author: Michael Adam <obnox at samba.org>
Date: Sun Apr 13 00:54:44 2008 +0200
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
-----------------------------------------------------------------------
Summary of changes:
source/include/reg_objects.h | 2 +-
source/registry/reg_api.c | 16 +++---
source/registry/reg_cachehook.c | 94 ++++++++++++++++++-----------------
source/registry/reg_dispatcher.c | 41 ++++++++--------
source/registry/reg_init_full.c | 2 +-
source/registry/reg_init_smbconf.c | 3 +-
source/script/mkproto.awk | 2 +-
7 files changed, 80 insertions(+), 80 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/include/reg_objects.h b/source/include/reg_objects.h
index 1d0d0d4..d9159dd 100644
--- a/source/include/reg_objects.h
+++ b/source/include/reg_objects.h
@@ -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 {
diff --git a/source/registry/reg_api.c b/source/registry/reg_api.c
index 1a0bf2b..cbbc7dd 100644
--- a/source/registry/reg_api.c
+++ b/source/registry/reg_api.c
@@ -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;
}
diff --git a/source/registry/reg_cachehook.c b/source/registry/reg_cachehook.c
index f9851c7..eb2884f 100644
--- a/source/registry/reg_cachehook.c
+++ b/source/registry/reg_cachehook.c
@@ -27,7 +27,28 @@
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 };
+
+static char *keyname_to_path(TALLOC_CTX *mem_ctx, const char *keyname)
+{
+ char *path = NULL;
+
+ if ((keyname == NULL)) {
+ return NULL;
+ }
+
+ path = talloc_asprintf(mem_ctx, "\\%s", keyname);
+ if (path == NULL) {
+ DEBUG(0, ("talloc_asprintf failed!\n"));
+ return NULL;
+ }
+
+ path = talloc_string_sub(mem_ctx, path, "\\", "/");
+ if (path == NULL) {
+ DEBUG(0, ("talloc_string_sub_failed!\n"));
+ }
+
+ return path;
+}
/**********************************************************************
Initialize the cache tree if it has not been initialized yet.
@@ -36,7 +57,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,82 +69,63 @@ 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();
+ bool ret;
char *key = NULL;
- if (!hook) {
- return false;
- }
+ key = keyname_to_path(talloc_tos(), keyname);
- key = talloc_asprintf(ctx, "\\%s", hook->keyname);
- if (!key) {
- return false;
- }
- key = talloc_string_sub(ctx, key, "\\", "/");
- if (!key) {
+ if ((key == NULL) || (ops == NULL)) {
return false;
}
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 );
+ ret = pathtree_add(cache_tree, key, ops);
+ TALLOC_FREE(key);
+ return ret;
}
/**********************************************************************
- Initialize the cache tree
+ Find a key in the cache.
*********************************************************************/
-REGISTRY_HOOK* reghook_cache_find( const char *keyname )
+REGISTRY_OPS *reghook_cache_find(const char *keyname)
{
char *key;
- int len;
- REGISTRY_HOOK *hook;
-
- if ( !keyname )
- return NULL;
-
- /* prepend the string with a '\' character */
-
- len = strlen( keyname );
- if ( !(key = (char *)SMB_MALLOC( len + 2 )) ) {
- DEBUG(0,("reghook_cache_find: malloc failed for string [%s] !?!?!\n",
- keyname));
+ REGISTRY_OPS *ops;
+
+ key = keyname_to_path(talloc_tos(), keyname);
+
+ if (key == NULL) {
return NULL;
}
- *key = '\\';
- strncpy( key+1, keyname, len+1);
-
- /* swap to a form understood by the SORTED_TREE */
-
- string_sub( key, "\\", "/", 0 );
-
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));
-
- SAFE_FREE( key );
-
- return hook;
+ ops ? (void *)ops : 0, key));
+
+ TALLOC_FREE(key);
+
+ return ops;
}
/**********************************************************************
- Initialize the cache tree
+ Print out the cache tree structure for debugging.
*********************************************************************/
void reghook_dump_cache( int debuglevel )
{
DEBUG(debuglevel,("reghook_dump_cache: Starting cache dump now...\n"));
-
+
pathtree_print_keys( cache_tree, debuglevel );
}
diff --git a/source/registry/reg_dispatcher.c b/source/registry/reg_dispatcher.c
index cdcd045..c68ecde 100644
--- a/source/registry/reg_dispatcher.c
+++ b/source/registry/reg_dispatcher.c
@@ -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;
diff --git a/source/registry/reg_init_full.c b/source/registry/reg_init_full.c
index ad245cb..f171949 100644
--- a/source/registry/reg_init_full.c
+++ b/source/registry/reg_init_full.c
@@ -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;
}
diff --git a/source/registry/reg_init_smbconf.c b/source/registry/reg_init_smbconf.c
index f76cc2f..d1acd21 100644
--- a/source/registry/reg_init_smbconf.c
+++ b/source/registry/reg_init_smbconf.c
@@ -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;
}
diff --git a/source/script/mkproto.awk b/source/script/mkproto.awk
index e9839fe..0fcfbb1 100644
--- a/source/script/mkproto.awk
+++ b/source/script/mkproto.awk
@@ -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;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list