[SCM] Samba Shared Repository - branch v3-2-stable updated - release-3-2-0pre2-868-g83266da

Karolin Seeger kseeger at samba.org
Tue Apr 22 13:59:48 GMT 2008


The branch, v3-2-stable has been updated
       via  83266da7908be25bf6bdf2cad10553b13417e5f2 (commit)
       via  8924a78951dede9aab544f19643b9815117e8ec0 (commit)
       via  ea8ccc22f25d157bb4974856360aece0ac52f917 (commit)
       via  b416096f9ea4c57b4ba1fde29b0146ef006eec74 (commit)
       via  6244e354a8e1170b7d0e99a7d6ef978ddbd095ce (commit)
       via  957e6c3a4e9478746b4af7174301e0c7d9d82649 (commit)
       via  6c898b0285a2f822fe401cd0ced1e82873ec7c6d (commit)
       via  23f2dfbb5d7e09996298f24b7ad05e4a8889fb79 (commit)
       via  44018f864a40604196863c032e6f10ffbf7ee8b4 (commit)
       via  4aedb7b0dee0233043246956886d9d2c8e86f699 (commit)
       via  10ce96d7d7df5097ad90771cdb8994ce22362fbb (commit)
       via  8ffb49f8c36e9710b26c5e78a15e3ec64bcea4ed (commit)
       via  b521592b260b0851de5dfe2f36f05ceb6da93bc1 (commit)
       via  9060aba731dd1e4dad83e5b79859361e8cc6381e (commit)
       via  556242e3fe3842b6ab0c581bb9e72e5e2698d970 (commit)
       via  83fdd000e95924f3b3d8f8b0b373f7f6d91a7235 (commit)
       via  cecb0cbea645f84e4bddbe1834649b15cdf4592a (commit)
       via  cae176497ffb9da1ea40bf794953665630e7995c (commit)
       via  69cff32aff245e866e93693594bac8a466427c18 (commit)
       via  725d4c30d8a02e7d2257f9642552e26df882645f (commit)
       via  82b1a4a3d197a8f419748d8beba1f079dfe319ad (commit)
       via  86a0615206538e039b43eb777151c40446ff72b1 (commit)
       via  6afc15ae3a9cb2978eb4a97d5c6e2c3742420154 (commit)
       via  813012b0532a9a608ab43c0f1cd2c3115354f53a (commit)
       via  8fdb6f9f69d6eb617dd6bb52daeecdf6b80141fd (commit)
      from  73055f1b0e0be70c87b2637d1bb4ad47f70b09ea (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable


- Log -----------------------------------------------------------------
commit 83266da7908be25bf6bdf2cad10553b13417e5f2
Author: Günther Deschner <gd at samba.org>
Date:   Sun Apr 13 18:27:03 2008 +0200

    Fix the build of eventlogadm.
    
    Guenther
    (cherry picked from commit 57a5628abf628b6276f36da8ae1f3c15a4db4488)

commit 8924a78951dede9aab544f19643b9815117e8ec0
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 15:45:33 2008 +0200

    registry: honour the WERROR that regsubkey_ctr_addkey gives us in reg_load_tree.
    
    Michael
    (cherry picked from commit c2d9baa29edb2356f32ca19aea828184e9ac7b93)

commit ea8ccc22f25d157bb4974856360aece0ac52f917
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 15:41:07 2008 +0200

    registry: honour the WERROR that regsubkey_ctr_addkey gives in regdb_fetch_keys.
    
    Michael
    (cherry picked from commit 7dd7471da7eca2671b4aa62e8790973e3ff14177)

commit b416096f9ea4c57b4ba1fde29b0146ef006eec74
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 15:36:05 2008 +0200

    net registry: remove superfluous regdb_close().
    
    Michael
    (cherry picked from commit d4e74036d3b8c5de4ce130eab7fc775e3cb746d5)

commit 6244e354a8e1170b7d0e99a7d6ef978ddbd095ce
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 15:33:12 2008 +0200

    registry: rename init_registry() to registry_init_full() for consistency.
    
    Michael
    (cherry picked from commit 14d82708d4499b48830d3dd25a0133f00a39d030)

commit 957e6c3a4e9478746b4af7174301e0c7d9d82649
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 15:31:02 2008 +0200

    registry: change init_registry() to return WERROR instead of bool.
    
    Michael
    (cherry picked from commit 0b196095dbbc29c796cb0742fe6e57a421e9596b)

commit 6c898b0285a2f822fe401cd0ced1e82873ec7c6d
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 15:25:47 2008 +0200

    registry: change registry_init_smbconf() to return WERROR instead of bool
    
    Michael
    (cherry picked from commit 7c343c60574cda091f59861fbcb2893aefb564e9)

commit 23f2dfbb5d7e09996298f24b7ad05e4a8889fb79
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 15:21:31 2008 +0200

    registry: refactor common part of registry initialization out.
    
    into a new function registry_init_common().
    
    Michael
    (cherry picked from commit 5da52b95ac69e4abfbc44335df2447bec8f16e13)

commit 44018f864a40604196863c032e6f10ffbf7ee8b4
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 15:12:04 2008 +0200

    registry: change registry_init_basic() to return WERROR instead of bool
    
    Michael

commit 4aedb7b0dee0233043246956886d9d2c8e86f699
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 14:55:49 2008 +0200

    registry: change reghook_cache_add() to return WERROR instead of bool
    
    Michael
    (cherry picked from commit e65a999989c97c4c7b0af5093e0e89583691e9a8)

commit 10ce96d7d7df5097ad90771cdb8994ce22362fbb
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 14:49:32 2008 +0200

    registry cachehook: change helper function keyname_to_path() to return WERROR.
    
    Michael
    (cherry picked from commit 78bb005ee45e7a0be24b5222c3f878058b5cd8ea)

commit 8ffb49f8c36e9710b26c5e78a15e3ec64bcea4ed
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 14:41:44 2008 +0200

    adt_tree: change pathtree_add to return WERR instead of bool.
    
    Michael
    (cherry picked from commit da45fb92f69221758f36db4cbb7d871e3ce60718)

commit b521592b260b0851de5dfe2f36f05ceb6da93bc1
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 14:40:51 2008 +0200

    registry cachehook: revert logic to make fast path more obvious and reduce indent.
    
    Michael
    (cherry picked from commit e97d558c5660e6d235b62528f5527a62ac1252d7)

commit 9060aba731dd1e4dad83e5b79859361e8cc6381e
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 14:18:06 2008 +0200

    registry: change reghook_cache_init() to return WERROR and use it in the callers.
    
    Michael
    (cherry picked from commit 2f4ca62dce50225d67ba8643afba4199e1845c5f)

commit 556242e3fe3842b6ab0c581bb9e72e5e2698d970
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 13:41:39 2008 +0200

    registry cachehook: compare cache_tree against NULL, not 0.
    
    Michael
    (cherry picked from commit 4bfc0be55f2a436a9c687ab6ad86e704fcb753d6)

commit 83fdd000e95924f3b3d8f8b0b373f7f6d91a7235
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 13:38:44 2008 +0200

    registry: change init_registry_key() and init_registry_data() to return WERR
    
    Michael
    (cherry picked from commit e0718f04a7392695eed6cd1bf888d3af1d5d6177)

commit cecb0cbea645f84e4bddbe1834649b15cdf4592a
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 12:46:21 2008 +0200

    registry: unify debug output in the registry init functions.
    
    Michael
    (cherry picked from commit 4fd9b45ffc08e7deeae58be3129832148748af13)

commit cae176497ffb9da1ea40bf794953665630e7995c
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 12:41:34 2008 +0200

    registry: change regdb_init() to return WERROR instead of bool.
    
    Michael
    (cherry picked from commit c312852abce72bc167abee8b29fc699c4a643ca7)

commit 69cff32aff245e866e93693594bac8a466427c18
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 12:10:07 2008 +0200

    registry: make registry_init_smbconf() hook the registry ops onto given key.
    
    This still defaults to HKLM\Software\Samba\smbconf, but is interchangeable now.
    This allows us to open the libsmbconf registry backend on different registry keys.
    
    Michael
    (cherry picked from commit 8fe1a2f567afbecbe487f08825cb43b038065e99)

commit 725d4c30d8a02e7d2257f9642552e26df882645f
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 01:47:16 2008 +0200

    registry cachehook: add talloc failed debug messages.
    
    Michael
    (cherry picked from commit 9841ee7fd429c7ff367dbb43b754cd5b6f53c065)

commit 82b1a4a3d197a8f419748d8beba1f079dfe319ad
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
    (cherry picked from commit c9f01aee37165216fa8a5331c64dd93963b38802)

commit 86a0615206538e039b43eb777151c40446ff72b1
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
    (cherry picked from commit 3f5955d361da5278773b46dccb34c8f63eb04157)

commit 6afc15ae3a9cb2978eb4a97d5c6e2c3742420154
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 01:40:45 2008 +0200

    registry cachehook: refactor normalization of keyname out.
    
    Michael
    (cherry picked from commit acb9c98dff7dac5e0688a04dbf6d63a7a7f67fd2)

commit 813012b0532a9a608ab43c0f1cd2c3115354f53a
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 01:32:51 2008 +0200

    registry: adapt copied function header comments.
    
    Michael
    (cherry picked from commit 2e762be0db7a098b6da09756a9c9dfa3931ca3c6)

commit 8fdb6f9f69d6eb617dd6bb52daeecdf6b80141fd
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
    (cherry picked from commit 2f9ee2f782c77ed99669af5ac2ba40cb0978f0da)

-----------------------------------------------------------------------

Summary of changes:
 source/include/adt_tree.h          |    2 +-
 source/include/reg_objects.h       |    2 +-
 source/lib/adt_tree.c              |   12 ++--
 source/lib/smbconf/smbconf_reg.c   |    4 +-
 source/registry/reg_api.c          |   22 ++++---
 source/registry/reg_backend_db.c   |   72 ++++++++++++++-------
 source/registry/reg_cachehook.c    |  126 ++++++++++++++++++++---------------
 source/registry/reg_dispatcher.c   |   41 ++++++------
 source/registry/reg_init_basic.c   |   38 +++++++----
 source/registry/reg_init_full.c    |   25 +++----
 source/registry/reg_init_smbconf.c |   41 ++++++------
 source/script/mkproto.awk          |    2 +-
 source/smbd/server.c               |    2 +-
 source/utils/eventlogadm.c         |    2 +-
 source/utils/net_registry.c        |    4 +-
 15 files changed, 224 insertions(+), 171 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/adt_tree.h b/source/include/adt_tree.h
index 3e2f100..3acda8e 100644
--- a/source/include/adt_tree.h
+++ b/source/include/adt_tree.h
@@ -47,7 +47,7 @@ SORTED_TREE*  pathtree_init( void *data_p, int (cmp_fn)(void*, void*) );
 
 /* add a new path component */
 
-bool          pathtree_add( SORTED_TREE *tree, const char *path, void *data_p );
+WERROR        pathtree_add( SORTED_TREE *tree, const char *path, void *data_p );
 
 /* search path */
 
diff --git a/source/include/reg_objects.h b/source/include/reg_objects.h
index 3df701f..5d6c5a1 100644
--- a/source/include/reg_objects.h
+++ b/source/include/reg_objects.h
@@ -152,7 +152,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/lib/adt_tree.c b/source/lib/adt_tree.c
index ef72ba3..6ac498d 100644
--- a/source/lib/adt_tree.c
+++ b/source/lib/adt_tree.c
@@ -191,23 +191,23 @@ static TREE_NODE* pathtree_find_child( TREE_NODE *node, char* key )
  Add a new node into the tree given a key path and a blob of data
  *************************************************************************/
 
- bool pathtree_add( SORTED_TREE *tree, const char *path, void *data_p )
+ WERROR pathtree_add( SORTED_TREE *tree, const char *path, void *data_p )
 {
 	char *str, *base, *path2;
 	TREE_NODE *current, *next;
-	bool ret = True;
+	WERROR ret = WERR_OK;
 	
 	DEBUG(8,("pathtree_add: Enter\n"));
 		
 	if ( !path || *path != '/' ) {
 		DEBUG(0,("pathtree_add: Attempt to add a node with a bad path [%s]\n",
 			path ? path : "NULL" ));
-		return False;
+		return WERR_INVALID_PARAM;
 	}
 	
 	if ( !tree ) {
 		DEBUG(0,("pathtree_add: Attempt to add a node to an uninitialized tree!\n"));
-		return False;
+		return WERR_INVALID_PARAM;
 	}
 	
 	/* move past the first '/' */
@@ -216,7 +216,7 @@ static TREE_NODE* pathtree_find_child( TREE_NODE *node, char* key )
 	path2 = SMB_STRDUP( path );
 	if ( !path2 ) {
 		DEBUG(0,("pathtree_add: strdup() failed on string [%s]!?!?!\n", path));
-		return False;
+		return WERR_NOMEM;
 	}
 	
 
@@ -244,7 +244,7 @@ static TREE_NODE* pathtree_find_child( TREE_NODE *node, char* key )
 			next = pathtree_birth_child( current, base );
 			if ( !next ) {
 				DEBUG(0,("pathtree_add: Failed to create new child!\n"));
-				ret =  False;
+				ret = WERR_NOMEM;
 				goto done;
 			}
 		}
diff --git a/source/lib/smbconf/smbconf_reg.c b/source/lib/smbconf/smbconf_reg.c
index a456704..930999c 100644
--- a/source/lib/smbconf/smbconf_reg.c
+++ b/source/lib/smbconf/smbconf_reg.c
@@ -634,8 +634,8 @@ static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
 	}
 	rpd(ctx)->open = false;
 
-	if (!registry_init_smbconf()) {
-		werr = WERR_REG_IO_FAILURE;
+	werr = registry_init_smbconf(path);
+	if (!W_ERROR_IS_OK(werr)) {
 		goto done;
 	}
 
diff --git a/source/registry/reg_api.c b/source/registry/reg_api.c
index 1a0bf2b..e9a7145 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;
 	}
@@ -771,7 +771,11 @@ static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath,
 
 	key->subkey_index = 0;
 	while ((subkey = regfio_fetch_subkey( regfile, key ))) {
-		regsubkey_ctr_addkey(subkeys, subkey->keyname);
+		result = regsubkey_ctr_addkey(subkeys, subkey->keyname);
+		if (!W_ERROR_IS_OK(result)) {
+			TALLOC_FREE(subkeys);
+			return result;
+		}
 	}
 
 	/* write this key and values out */
@@ -898,8 +902,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_backend_db.c b/source/registry/reg_backend_db.c
index 2c137f4..52a0150 100644
--- a/source/registry/reg_backend_db.c
+++ b/source/registry/reg_backend_db.c
@@ -83,9 +83,9 @@ static struct builtin_regkey_value builtin_registry_values[] = {
  * Initialize a key in the registry:
  * create each component key of the specified path.
  */
-static bool init_registry_key_internal(const char *add_path)
+static WERROR init_registry_key_internal(const char *add_path)
 {
-	bool ret = false;
+	WERROR werr;
 	TALLOC_CTX *frame = talloc_stackframe();
 	char *path = NULL;
 	char *base = NULL;
@@ -100,6 +100,7 @@ static bool init_registry_key_internal(const char *add_path)
 	path = talloc_strdup(frame, add_path);
 	base = talloc_strdup(frame, "");
 	if (!path || !base) {
+		werr = WERR_NOMEM;
 		goto fail;
 	}
 	p = path;
@@ -111,11 +112,13 @@ static bool init_registry_key_internal(const char *add_path)
 		if (*base) {
 			base = talloc_asprintf(frame, "%s\\", base);
 			if (!base) {
+				werr = WERR_NOMEM;
 				goto fail;
 			}
 		}
 		base = talloc_asprintf_append(base, "%s", keyname);
 		if (!base) {
+			werr = WERR_NOMEM;
 			goto fail;
 		}
 
@@ -123,11 +126,13 @@ static bool init_registry_key_internal(const char *add_path)
 
 		subkeyname = talloc_strdup(frame, "");
 		if (!subkeyname) {
+			werr = WERR_NOMEM;
 			goto fail;
 		}
 		if (*p) {
 			remaining = talloc_strdup(frame, p);
 			if (!remaining) {
+				werr = WERR_NOMEM;
 				goto fail;
 			}
 			p2 = remaining;
@@ -137,6 +142,7 @@ static bool init_registry_key_internal(const char *add_path)
 			{
 				subkeyname = talloc_strdup(frame,p2);
 				if (!subkeyname) {
+					werr = WERR_NOMEM;
 					goto fail;
 				}
 			}
@@ -152,22 +158,28 @@ static bool init_registry_key_internal(const char *add_path)
 
 		if (!(subkeys = TALLOC_ZERO_P(frame, REGSUBKEY_CTR))) {
 			DEBUG(0,("talloc() failure!\n"));
+			werr = WERR_NOMEM;
 			goto fail;
 		}
 
 		regdb_fetch_keys(base, subkeys);
 		if (*subkeyname) {
-			regsubkey_ctr_addkey( subkeys, subkeyname);
+			werr = regsubkey_ctr_addkey(subkeys, subkeyname);
+			if (!W_ERROR_IS_OK(werr)) {
+				goto fail;
+			}
 		}
 		if (!regdb_store_keys( base, subkeys)) {
+			werr = WERR_CAN_NOT_COMPLETE;
 			goto fail;
 		}
 	}
 
-	ret = true;
+	werr = WERR_OK;
+
 fail:
 	TALLOC_FREE(frame);
-	return ret;
+	return werr;
 }
 
 /**
@@ -175,38 +187,42 @@ fail:
  * create each component key of the specified path,
  * wrapped in one db transaction.
  */
-bool init_registry_key(const char *add_path)
+WERROR init_registry_key(const char *add_path)
 {
+	WERROR werr;
+
 	if (regdb->transaction_start(regdb) != 0) {
 		DEBUG(0, ("init_registry_key: transaction_start failed\n"));
-		return false;
+		return WERR_REG_IO_FAILURE;
 	}
 
-	if (!init_registry_key_internal(add_path)) {
+	werr = init_registry_key_internal(add_path);
+	if (!W_ERROR_IS_OK(werr)) {
 		goto fail;
 	}
 
 	if (regdb->transaction_commit(regdb) != 0) {
 		DEBUG(0, ("init_registry_key: Could not commit transaction\n"));
-		return false;
+		return WERR_REG_IO_FAILURE;
 	}
 
-	return true;
+	return WERR_OK;
 
 fail:
 	if (regdb->transaction_cancel(regdb) != 0) {
 		smb_panic("init_registry_key: transaction_cancel failed\n");
 	}
 
-	return false;
+	return werr;
 }
 
 /***********************************************************************
  Open the registry data in the tdb
  ***********************************************************************/
 
-bool init_registry_data(void)
+WERROR init_registry_data(void)
 {
+	WERROR werr;
 	TALLOC_CTX *frame = NULL;
 	REGVAL_CTR *values;
 	int i;
@@ -223,13 +239,14 @@ bool init_registry_data(void)
 	if (regdb->transaction_start(regdb) != 0) {
 		DEBUG(0, ("init_registry_data: tdb_transaction_start "
 			  "failed\n"));
-		return false;
+		return WERR_REG_IO_FAILURE;
 	}
 
 	/* loop over all of the predefined paths and add each component */
 
 	for (i=0; builtin_registry_paths[i] != NULL; i++) {
-		if (!init_registry_key_internal(builtin_registry_paths[i])) {
+		werr = init_registry_key_internal(builtin_registry_paths[i]);
+		if (!W_ERROR_IS_OK(werr)) {
 			goto fail;
 		}
 	}
@@ -242,6 +259,7 @@ bool init_registry_data(void)
 
 		values = TALLOC_ZERO_P(frame, REGVAL_CTR);
 		if (values == NULL) {
+			werr = WERR_NOMEM;
 			goto fail;
 		}
 
@@ -289,10 +307,10 @@ bool init_registry_data(void)
 	if (regdb->transaction_commit(regdb) != 0) {
 		DEBUG(0, ("init_registry_data: Could not commit "
 			  "transaction\n"));
-		return false;
+		return WERR_REG_IO_FAILURE;
 	}
 
-	return true;
+	return WERR_OK;
 
  fail:
 
@@ -303,23 +321,24 @@ bool init_registry_data(void)
 			  "failed\n");
 	}
 
-	return false;
+	return werr;
 }
 
 /***********************************************************************
  Open the registry database
  ***********************************************************************/
  
-bool regdb_init(void)
+WERROR regdb_init(void)
 {
 	const char *vstring = "INFO/version";
 	uint32 vers_id;
+	WERROR werr;
 
 	if (regdb) {
 		DEBUG(10, ("regdb_init: incrementing refcount (%d)\n",
 			  regdb_refcount));
 		regdb_refcount++;
-		return true;
+		return WERR_OK;
 	}
 
 	regdb = db_open_trans(NULL, state_path("registry.tdb"), 0,
@@ -328,9 +347,10 @@ bool regdb_init(void)
 		regdb = db_open_trans(NULL, state_path("registry.tdb"), 0,
 				      REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600);
 		if (!regdb) {
+			werr = ntstatus_to_werror(map_nt_error_from_unix(errno));
 			DEBUG(0,("regdb_init: Failed to open registry %s (%s)\n",
 				state_path("registry.tdb"), strerror(errno) ));
-			return false;
+			return werr;
 		}
 		
 		DEBUG(10,("regdb_init: Successfully created registry tdb\n"));
@@ -349,14 +369,14 @@ bool regdb_init(void)
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(0, ("regdb_init: error storing %s = %d: %s\n",
 				  vstring, REGVER_V1, nt_errstr(status)));
-			return false;
+			return ntstatus_to_werror(status);
 		} else {
 			DEBUG(10, ("regdb_init: stored %s = %d\n",
 				  vstring, REGVER_V1));
 		}
 	}
 
-	return true;
+	return WERR_OK;
 }
 
 /***********************************************************************
@@ -692,6 +712,7 @@ fail:
 
 int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
 {
+	WERROR werr;
 	char *path = NULL;
 	uint32 num_items;
 	uint8 *buf;
@@ -736,7 +757,12 @@ int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
 
 	for (i=0; i<num_items; i++) {
 		len += tdb_unpack(buf+len, buflen-len, "f", subkeyname);
-		regsubkey_ctr_addkey(ctr, subkeyname);
+		werr = regsubkey_ctr_addkey(ctr, subkeyname);
+		if (!W_ERROR_IS_OK(werr)) {
+			DEBUG(5, ("regdb_fetch_keys: regsubkey_ctr_addkey "
+				  "failed: %s\n", dos_errstr(werr)));
+			goto fail;
+		}
 	}
 
 	DEBUG(11,("regdb_fetch_keys: Exit [%d] items\n", num_items));
diff --git a/source/registry/reg_cachehook.c b/source/registry/reg_cachehook.c
index f9851c7..6697a69 100644
--- a/source/registry/reg_cachehook.c
+++ b/source/registry/reg_cachehook.c
@@ -27,103 +27,121 @@
 
 static SORTED_TREE *cache_tree = NULL;
 extern REGISTRY_OPS regdb_ops;		/* these are the default */
-static REGISTRY_HOOK default_hook = { KEY_TREE_ROOT, &regdb_ops };
+
+static WERROR keyname_to_path(TALLOC_CTX *mem_ctx, const char *keyname,
+			      char **path)
+{
+	char *tmp_path = NULL;
+
+	if ((keyname == NULL) || (path == NULL)) {
+		return WERR_INVALID_PARAM;
+	}
+
+	tmp_path = talloc_asprintf(mem_ctx, "\\%s", keyname);
+	if (tmp_path == NULL) {
+		DEBUG(0, ("talloc_asprintf failed!\n"));
+		return WERR_NOMEM;
+	}
+
+	tmp_path = talloc_string_sub(mem_ctx, tmp_path, "\\", "/");
+	if (tmp_path == NULL) {
+		DEBUG(0, ("talloc_string_sub_failed!\n"));
+		return WERR_NOMEM;
+	}
+
+	*path = tmp_path;
+
+	return WERR_OK;
+}
 
 /**********************************************************************
  Initialize the cache tree if it has not been initialized yet.
  *********************************************************************/
 
-bool reghook_cache_init( void )
+WERROR reghook_cache_init(void)
 {
-	if (cache_tree == NULL) {
-		cache_tree = pathtree_init(&default_hook, NULL);
-		if (cache_tree !=0) {
-			DEBUG(10, ("reghook_cache_init: new tree with default "
-				   "ops %p for key [%s]\n", (void *)&regdb_ops,
-				   KEY_TREE_ROOT));
-		}
+	if (cache_tree != NULL) {
+		return WERR_OK;
 	}
 
-	return (cache_tree != NULL);
+	cache_tree = pathtree_init(&regdb_ops, NULL);
+	if (cache_tree == NULL) {
+		return WERR_NOMEM;
+	}
+	DEBUG(10, ("reghook_cache_init: new tree with default "
+		   "ops %p for key [%s]\n", (void *)&regdb_ops,
+		   KEY_TREE_ROOT));
+	return WERR_OK;
 }
 
 /**********************************************************************
- 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 )
+WERROR reghook_cache_add(const char *keyname, REGISTRY_OPS *ops)
 {
-	TALLOC_CTX *ctx = talloc_tos();
+	WERROR werr;
 	char *key = NULL;
 
-	if (!hook) {
-		return false;
+	if ((keyname == NULL) || (ops == NULL)) {
+		return WERR_INVALID_PARAM;
 	}
 
-	key = talloc_asprintf(ctx, "\\%s", hook->keyname);
-	if (!key) {
-		return false;
-	}
-	key = talloc_string_sub(ctx, key, "\\", "/");
-	if (!key) {
-		return false;
+	werr = keyname_to_path(talloc_tos(), keyname, &key);
+	if (!W_ERROR_IS_OK(werr)) {
+		goto done;
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list