From 69cff32aff245e866e93693594bac8a466427c18 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Apr 2008 12:10:07 +0200 Subject: [PATCH] registry: make registry_init_smbconf() hook the registry ops onto given key. This still defaults to HKLM\Software\Samba\smbconf, but is interchangeable now. This allows us to open the libsmbconf registry backend on different registry keys. Michael (cherry picked from commit 8fe1a2f567afbecbe487f08825cb43b038065e99) --- source/lib/smbconf/smbconf_reg.c | 2 +- source/registry/reg_init_smbconf.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/lib/smbconf/smbconf_reg.c b/source/lib/smbconf/smbconf_reg.c index a456704e7e4..7e9d0ff1744 100644 --- a/source/lib/smbconf/smbconf_reg.c +++ b/source/lib/smbconf/smbconf_reg.c @@ -634,7 +634,7 @@ static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path) } rpd(ctx)->open = false; - if (!registry_init_smbconf()) { + if (!registry_init_smbconf(path)) { werr = WERR_REG_IO_FAILURE; goto done; } diff --git a/source/registry/reg_init_smbconf.c b/source/registry/reg_init_smbconf.c index d1acd213c11..ff9cde749ea 100644 --- a/source/registry/reg_init_smbconf.c +++ b/source/registry/reg_init_smbconf.c @@ -67,13 +67,19 @@ done: * for use in places where not the whole registry is needed, * e.g. utils/net_conf.c and loadparm.c */ -bool registry_init_smbconf(void) +bool registry_init_smbconf(const char *keyname) { bool ret = false; int saved_errno = 0; DEBUG(10, ("registry_init_smbconf called\n")); + if (keyname == NULL) { + DEBUG(10, ("registry_init_smbconf: defaulting to key '%s'\n", + KEY_SMBCONF)); + keyname = KEY_SMBCONF; + } + if (!regdb_init()) { saved_errno = errno; DEBUG(1, ("Can't open the registry")); @@ -83,13 +89,13 @@ bool registry_init_smbconf(void) DEBUGADD(1, (".\n")); goto done; } - if (!init_registry_key(KEY_SMBCONF)) { + if (!init_registry_key(keyname)) { DEBUG(1, ("Could not initialize registry key '%s'\n", - KEY_SMBCONF)); + keyname)); goto done; } reghook_cache_init(); - if (!reghook_cache_add(KEY_SMBCONF, &smbconf_reg_ops)) { + if (!reghook_cache_add(keyname, &smbconf_reg_ops)) { DEBUG(1, ("Error adding smbconf reghooks to reghook cache.\n")); goto done; } -- 2.11.4.GIT