summaryrefslogtreecommitdiff
path: root/source3/libnet/libnet_conf.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-01-03 15:33:09 +0100
committerMichael Adam <obnox@samba.org>2008-01-03 15:33:09 +0100
commit5470f8f638505b8dccc11ca0038632aa472608d8 (patch)
treea624040d520418f7a3572ff2b93cf2fbf22a7555 /source3/libnet/libnet_conf.c
parent6dce6ba0a6551c4db29ccf51e346f20ea1f8430e (diff)
downloadsamba-5470f8f638505b8dccc11ca0038632aa472608d8.tar.gz
samba-5470f8f638505b8dccc11ca0038632aa472608d8.tar.bz2
samba-5470f8f638505b8dccc11ca0038632aa472608d8.zip
Make libnet_conf handle opening/initialization of the registry.
Open state is currently tracked by a global variable to avoid double initialization. Later, this can possibly be replaced by a conf-context created by an initialization function and passed around to the other api functions. Michael (This used to be commit 77713e776405800ac54c692a77cd4efd153042cb)
Diffstat (limited to 'source3/libnet/libnet_conf.c')
-rw-r--r--source3/libnet/libnet_conf.c32
1 files changed, 32 insertions, 0 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"));