From: Michael Adam Date: Sun, 13 Apr 2008 10:10:07 +0000 (+0200) Subject: registry: make registry_init_smbconf() hook the registry ops onto given key. X-Git-Tag: samba-3.3.0pre1~2712 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8fe1a2f567afbecbe487f08825cb43b038065e99;p=thirdparty%2Fsamba.git 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 --- diff --git a/source/lib/smbconf/smbconf_reg.c b/source/lib/smbconf/smbconf_reg.c index 0ac49a74e5e..c53d275938a 100644 --- a/source/lib/smbconf/smbconf_reg.c +++ b/source/lib/smbconf/smbconf_reg.c @@ -576,7 +576,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; }