]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
registry: make registry_init_smbconf() hook the registry ops onto given key.
authorMichael Adam <obnox@samba.org>
Sun, 13 Apr 2008 10:10:07 +0000 (12:10 +0200)
committerMichael Adam <obnox@samba.org>
Sun, 13 Apr 2008 13:33:47 +0000 (15:33 +0200)
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

source/lib/smbconf/smbconf_reg.c
source/registry/reg_init_smbconf.c

index 0ac49a74e5e8ff0f40143ec576b08bb6fe0ebb64..c53d275938aa6a99c07dd113e5d285c2001314d2 100644 (file)
@@ -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;
        }
index d1acd213c113ba0291751ffe3bfb644295fe3452..ff9cde749ea3a7846598dc66248251559c53ca78 100644 (file)
@@ -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;
        }