diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libnet/libnet_conf.c | 32 | ||||
-rw-r--r-- | source3/utils/net_conf.c | 5 |
2 files changed, 32 insertions, 5 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 86ef3e5517..665261723b 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -21,6 +21,11 @@ #include "includes.h" #include "libnet/libnet.h" +/* + * yuck - static variable to keep track of the registry initialization. + */ +static bool registry_initialized = false; + /********************************************************************** * * Helper functions (mostly registry related) @@ -54,6 +59,26 @@ static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, return WERR_OK; } +static WERROR libnet_conf_reg_initialize(void) +{ + WERROR werr = WERR_OK; + + if (registry_initialized) { + goto done; + } + + if (!registry_init_regdb()) { + /* proper error code? */ + werr = WERR_GENERAL_FAILURE; + goto done; + } + + registry_initialized = true; + +done: + return werr; +} + /** * Open a registry key specified by "path" */ @@ -78,6 +103,13 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx, goto done; } + werr = libnet_conf_reg_initialize(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(1, ("Error initializing registry: %s\n", + dos_errstr(werr))); + goto done; + } + token = registry_create_admin_token(tmp_ctx); if (token == NULL) { DEBUG(1, ("Error creating admin token\n")); diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c index 2d4b3f4054..a758391630 100644 --- a/source3/utils/net_conf.c +++ b/source3/utils/net_conf.c @@ -852,11 +852,6 @@ int net_conf(int argc, const char **argv) {NULL, NULL, NULL} }; - if (!registry_init_regdb()) { - d_fprintf(stderr, "Error initializing the registry!\n"); - goto done; - } - ret = net_run_function2(argc, argv, "net conf", func); regdb_close(); |