svn commit: samba r2897 - in branches/SAMBA_4_0/source/lib/registry/common: .

jelmer at samba.org jelmer at samba.org
Sun Oct 10 23:52:07 GMT 2004


Author: jelmer
Date: 2004-10-10 23:52:06 +0000 (Sun, 10 Oct 2004)
New Revision: 2897

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/lib/registry/common&rev=2897&nolog=1

Log:
Fix double registration (of the registry subsystem) bug

Modified:
   branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c	2004-10-10 23:03:12 UTC (rev 2896)
+++ branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c	2004-10-10 23:52:06 UTC (rev 2897)
@@ -37,6 +37,7 @@
 	struct reg_init_function_entry *entry = backends;
 
 	if (!functions || !functions->name) {
+		DEBUG(0, ("Invalid arguments while registering registry backend\n"));
 		return NT_STATUS_INVALID_PARAMETER;
 	}
 
@@ -56,30 +57,37 @@
 	return NT_STATUS_OK;
 }
 
+static BOOL registry_init(void)
+{
+	static BOOL initialised;
+	NTSTATUS status;
+	
+	if(initialised) {
+		return True;
+	}
+	
+	status = register_subsystem("registry", registry_register);
+	if (NT_STATUS_IS_ERR(status)) {
+		DEBUG(0, ("Error registering registry subsystem: %s\n", nt_errstr(status)));
+		return False;
+	}
+
+	initialised = True;
+	static_init_registry;
+	return True;
+}
+
 /* Find a backend in the list of available backends */
 static struct reg_init_function_entry *reg_find_backend_entry(const char *name)
 {
 	struct reg_init_function_entry *entry;
-	static BOOL reg_first_init = True;
-	NTSTATUS status;
 
-	if(reg_first_init) {
-		status = register_subsystem("registry", registry_register);
-		if (NT_STATUS_IS_ERR(status)) {
-			DEBUG(0, ("Error registering registry subsystem: %s\n", nt_errstr(status)));
-			/* Don't try the initialisation again */
-			reg_first_init = False;
-			return NULL;
-		}
+	if(registry_init() == False) return NULL;
 
-		static_init_registry;
-		reg_first_init = False;
-	}
-
 	entry = backends;
 
 	while(entry) {
-		if (strcmp(entry->functions->name, name)==0) return entry;
+		if (strcmp(entry->functions->name, name) == 0) return entry;
 		entry = entry->next;
 	}
 
@@ -186,7 +194,7 @@
 
 	ret->root->hive = ret;
 	ret->root->name = NULL;
-	ret->root->path = "";
+	ret->root->path = talloc_strdup(mem_ctx, "");
 
 	/* Add hive to context */
 	h->num_hives++;



More information about the samba-cvs mailing list