diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-10-10 23:52:06 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:45 -0500 |
commit | ffa0cf3af05c82df558bb2484e04a8f2220f6ea0 (patch) | |
tree | e1abde9467ebb44e7756415ac2d70daf3e20cc32 /source4 | |
parent | 235a847e68cca679d448ba94cb7ce4e86f10df90 (diff) | |
download | samba-ffa0cf3af05c82df558bb2484e04a8f2220f6ea0.tar.gz samba-ffa0cf3af05c82df558bb2484e04a8f2220f6ea0.tar.bz2 samba-ffa0cf3af05c82df558bb2484e04a8f2220f6ea0.zip |
r2897: Fix double registration (of the registry subsystem) bug
(This used to be commit f4860afc486da9fcd43798c81181d01eb0120a59)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/registry/common/reg_interface.c | 40 |
1 files changed, 24 insertions, 16 deletions
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++; |