From feb4d82724657c5567d9ebefef7242a2a48496e2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 31 Dec 2007 03:25:54 +0100 Subject: Fix a permissions error in reg_deletekey_recursive(). Michael (This used to be commit 4a56d3d7075bd8bbd5e139c9433789ab29f6a70e) --- source3/registry/reg_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/registry') diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index bc4508ff94..bb410e646b 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -729,7 +729,7 @@ WERROR reg_deletekey_recursive_internal(TALLOC_CTX *ctx, } /* recurse through subkeys first */ - werr = reg_openkey(mem_ctx, parent, path, REG_KEY_WRITE, &key); + werr = reg_openkey(mem_ctx, parent, path, REG_KEY_ALL, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From 0240d175bf896230891a3ffadba747a0143d9232 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 12:07:02 +0100 Subject: Return existsing cache_tree if it has already been initialized. So reghook_cache_init() does not leak memory when called more than once. Also, fix the return value while we are at it. Michael (This used to be commit 25f571f40a630bff5a47bba6b01e42d4e0ffed66) --- source3/registry/reg_cachehook.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/registry') diff --git a/source3/registry/reg_cachehook.c b/source3/registry/reg_cachehook.c index 289d4e50ce..74670aac30 100644 --- a/source3/registry/reg_cachehook.c +++ b/source3/registry/reg_cachehook.c @@ -25,19 +25,21 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_REGISTRY -static SORTED_TREE *cache_tree; +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 + Initialize the cache tree if it has not been initialized yet. *********************************************************************/ bool reghook_cache_init( void ) { - cache_tree = pathtree_init( &default_hook, NULL ); + if (cache_tree == NULL) { + cache_tree = pathtree_init(&default_hook, NULL); + } - return ( cache_tree == NULL ); + return (cache_tree != NULL); } /********************************************************************** -- cgit From 5c09517d7d9fa6252e5cece990f56fcb525414e0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 4 Jan 2008 12:57:49 +0100 Subject: Fix crash bug in regdb_close() when called with no ref count. Michael, please check. Guenther (This used to be commit d6575ff5d240ec431b6e837494913dbd06e5a299) --- source3/registry/reg_db.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/registry') diff --git a/source3/registry/reg_db.c b/source3/registry/reg_db.c index 25c6557c87..19799292ff 100644 --- a/source3/registry/reg_db.c +++ b/source3/registry/reg_db.c @@ -329,6 +329,10 @@ WERROR regdb_open( void ) int regdb_close( void ) { + if (tdb_refcount == 0) { + return 0; + } + tdb_refcount--; DEBUG(10,("regdb_close: decrementing refcount (%d)\n", tdb_refcount)); -- cgit From 1c183874abaad10188c9f9bf1db2863cbd4d1cef Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 4 Jan 2008 15:20:46 +0100 Subject: Use the proper boolean constants. Michael (This used to be commit 2ba625e473e8eb23d692566d32a8ac965785df4e) --- source3/registry/reg_db.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/registry') diff --git a/source3/registry/reg_db.c b/source3/registry/reg_db.c index 19799292ff..eba220b76c 100644 --- a/source3/registry/reg_db.c +++ b/source3/registry/reg_db.c @@ -259,7 +259,7 @@ bool regdb_init( void ) uint32 vers_id; if ( tdb_reg ) - return True; + return true; if ( !(tdb_reg = tdb_wrap_open(NULL, state_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR, 0600)) ) { @@ -267,7 +267,7 @@ bool regdb_init( void ) if ( !tdb_reg ) { DEBUG(0,("regdb_init: Failed to open registry %s (%s)\n", state_path("registry.tdb"), strerror(errno) )); - return False; + return false; } DEBUG(10,("regdb_init: Successfully created registry tdb\n")); @@ -287,10 +287,10 @@ bool regdb_init( void ) if ( !init_registry_data() ) { DEBUG(0,("init_registry: Failed to initialize data in registry!\n")); - return False; + return false; } - return True; + return true; } /*********************************************************************** @@ -368,7 +368,7 @@ static bool regdb_store_keys_internal(const char *key, REGSUBKEY_CTR *ctr) uint8 *buffer = NULL; int i = 0; uint32 len, buflen; - bool ret = True; + bool ret = true; uint32 num_subkeys = regsubkey_ctr_numkeys(ctr); char *keyname = NULL; TALLOC_CTX *ctx = talloc_tos(); @@ -386,7 +386,7 @@ static bool regdb_store_keys_internal(const char *key, REGSUBKEY_CTR *ctr) /* allocate some initial memory */ if (!(buffer = (uint8 *)SMB_MALLOC(1024))) { - return False; + return false; } buflen = 1024; len = 0; @@ -403,7 +403,7 @@ static bool regdb_store_keys_internal(const char *key, REGSUBKEY_CTR *ctr) /* allocate some extra space */ if ((buffer = (uint8 *)SMB_REALLOC( buffer, len*2 )) == NULL) { DEBUG(0,("regdb_store_keys: Failed to realloc memory of size [%d]\n", len*2)); - ret = False; + ret = false; goto done; } buflen = len*2; @@ -417,7 +417,7 @@ static bool regdb_store_keys_internal(const char *key, REGSUBKEY_CTR *ctr) dbuf.dptr = buffer; dbuf.dsize = len; if ( tdb_store_bystring( tdb_reg->tdb, keyname, dbuf, TDB_REPLACE ) == -1) { - ret = False; + ret = false; goto done; } @@ -805,7 +805,7 @@ bool regdb_store_values( const char *key, REGVAL_CTR *values ) && (memcmp(old_data.dptr, data.dptr, data.dsize) == 0)) { SAFE_FREE(old_data.dptr); SAFE_FREE(data.dptr); - return True; + return true; } ret = tdb_trans_store_bystring(tdb_reg->tdb, keystr, data, TDB_REPLACE); -- cgit From 2f195e52fa0eb656c40be4b0ba5b7de4acd18c05 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 4 Jan 2008 21:35:29 +0100 Subject: Fix a DEBUG statement. Michael (This used to be commit 18360b852c662d933ceff9854725f878a5de9a7d) --- source3/registry/reg_db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/registry') diff --git a/source3/registry/reg_db.c b/source3/registry/reg_db.c index eba220b76c..f50a41816c 100644 --- a/source3/registry/reg_db.c +++ b/source3/registry/reg_db.c @@ -286,7 +286,7 @@ bool regdb_init( void ) /* always setup the necessary keys and values */ if ( !init_registry_data() ) { - DEBUG(0,("init_registry: Failed to initialize data in registry!\n")); + DEBUG(0,("regdb_init: Failed to initialize data in registry!\n")); return false; } -- cgit