From ffa0cf3af05c82df558bb2484e04a8f2220f6ea0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 10 Oct 2004 23:52:06 +0000 Subject: r2897: Fix double registration (of the registry subsystem) bug (This used to be commit f4860afc486da9fcd43798c81181d01eb0120a59) --- source4/lib/registry/common/reg_interface.c | 40 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'source4/lib/registry/common') diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c index c55ecd5a41..28025e4d84 100644 --- a/source4/lib/registry/common/reg_interface.c +++ b/source4/lib/registry/common/reg_interface.c @@ -37,6 +37,7 @@ NTSTATUS registry_register(const void *_function) 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 @@ NTSTATUS registry_register(const void *_function) 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; - } - - static_init_registry; - reg_first_init = False; - } + if(registry_init() == False) return NULL; 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 @@ WERROR reg_import_hive(struct registry_context *h, const char *backend, const ch 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++; -- cgit