summaryrefslogtreecommitdiff
path: root/source3/param/loadparm.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-05-15 01:40:11 +0200
committerMichael Adam <obnox@samba.org>2008-05-15 02:42:40 +0200
commit18b385ccef221af356c1b776aaa0c8c2f3ba4a74 (patch)
treec5c60d0ba5fb7dbec79444954c162cde8c4e8e19 /source3/param/loadparm.c
parent847d385f7bac1c02727d7655f4e277813d4fe42c (diff)
downloadsamba-18b385ccef221af356c1b776aaa0c8c2f3ba4a74.tar.gz
samba-18b385ccef221af356c1b776aaa0c8c2f3ba4a74.tar.bz2
samba-18b385ccef221af356c1b776aaa0c8c2f3ba4a74.zip
loadparm: refactor initalization of registry config out into lp_smbconf_ctx().
Michael (This used to be commit 83cd9f74d57c462ad5c8956b3ce3c81bea429b67)
Diffstat (limited to 'source3/param/loadparm.c')
-rw-r--r--source3/param/loadparm.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index b539684457..ee19a38013 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -80,7 +80,6 @@ extern userdom_struct current_user_info;
static bool in_client = False; /* Not in the client by default */
static struct smbconf_csn conf_last_csn;
-static struct smbconf_ctx *conf_ctx = NULL;
#define CONFIG_BACKEND_FILE 0
#define CONFIG_BACKEND_REGISTRY 1
@@ -6491,6 +6490,23 @@ bool service_ok(int iService)
return (bRetval);
}
+static struct smbconf_ctx *lp_smbconf_ctx(void)
+{
+ WERROR werr;
+ static struct smbconf_ctx *conf_ctx = NULL;
+
+ if (conf_ctx == NULL) {
+ werr = smbconf_init(NULL, &conf_ctx, "registry:");
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, ("error initializing registry configuration: "
+ "%s\n", dos_errstr(werr)));
+ conf_ctx = NULL;
+ }
+ }
+
+ return conf_ctx;
+}
+
/*
* process_registry_globals
*/
@@ -6500,14 +6516,11 @@ static bool process_registry_globals(void)
struct smbconf_service *service = NULL;
uint32_t count;
TALLOC_CTX *mem_ctx = talloc_stackframe();
+ struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
bool ret = false;
if (conf_ctx == NULL) {
- /* first time */
- werr = smbconf_init(NULL, &conf_ctx, "registry:");
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
+ goto done;
}
if (!smbconf_share_exists(conf_ctx, GLOBAL_NAME)) {
@@ -6613,14 +6626,10 @@ bool lp_file_list_changed(void)
DEBUG(6, ("lp_file_list_changed()\n"));
if (lp_config_backend_is_registry()) {
+ struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
+
if (conf_ctx == NULL) {
- WERROR werr;
- werr = smbconf_init(NULL, &conf_ctx, "registry:");
- if (!W_ERROR_IS_OK(werr)) {
- DEBUG(0, ("error opening configuration: %s\n",
- dos_errstr(werr)));
- return false;
- }
+ return false;
}
if (smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL)) {
DEBUGADD(6, ("registry config changed\n"));