summaryrefslogtreecommitdiff
path: root/source3/lib/smbconf/smbconf_reg.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-03-21 17:55:31 +0100
committerMichael Adam <obnox@samba.org>2008-03-21 18:19:24 +0100
commit6f7cfeddd61f728e2452a7b89f5ee2ff36ca394f (patch)
treead5f91f4c72bf9a40fa897204cb36574721d562e /source3/lib/smbconf/smbconf_reg.c
parent40ea88db5e9e5dd8fd6a924bfcd1afefa538404d (diff)
downloadsamba-6f7cfeddd61f728e2452a7b89f5ee2ff36ca394f.tar.gz
samba-6f7cfeddd61f728e2452a7b89f5ee2ff36ca394f.tar.bz2
samba-6f7cfeddd61f728e2452a7b89f5ee2ff36ca394f.zip
libsmbconf: add a "path" variable to the conf context.
This is passed to the module init routines. In case of the registry, this is the path of the basekey in registry, that is to be used, defaulting to KEY_SMBCONF (HKLM\software\samba\smbconf), when NULL is given. This is the only case currently used. In order to support other keys, registry initialization for smbconf has to be changed to support different keys. Michael (This used to be commit 96434d9dc7a66773e313cc128af57493dee245a1)
Diffstat (limited to 'source3/lib/smbconf/smbconf_reg.c')
-rw-r--r--source3/lib/smbconf/smbconf_reg.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index f0a1f17f8e..beb1c20de6 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -69,7 +69,7 @@ done:
}
/**
- * Open a subkey of KEY_SMBCONF (i.e a service)
+ * Open a subkey of the base key (i.e a service)
*/
static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
struct smbconf_ctx *ctx,
@@ -86,7 +86,7 @@ static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
goto done;
}
- path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SMBCONF, servicename);
+ path = talloc_asprintf(mem_ctx, "%s\\%s", ctx->path, servicename);
if (path == NULL) {
werr = WERR_NOMEM;
goto done;
@@ -100,14 +100,14 @@ done:
}
/**
- * open the base key KEY_SMBCONF
+ * open the base key
*/
static WERROR smbconf_reg_open_base_key(TALLOC_CTX *mem_ctx,
struct smbconf_ctx *ctx,
uint32 desired_access,
struct registry_key **key)
{
- return smbconf_reg_open_path(mem_ctx, ctx, KEY_SMBCONF, desired_access,
+ return smbconf_reg_open_path(mem_ctx, ctx, ctx->path, desired_access,
key);
}
@@ -131,7 +131,7 @@ static bool smbconf_value_exists(struct registry_key *key, const char *param)
}
/**
- * create a subkey of KEY_SMBCONF
+ * create a subkey of the base key (i.e. a service...)
*/
static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
struct smbconf_ctx *ctx,
@@ -372,10 +372,19 @@ done:
/**
* initialize the registry smbconf backend
*/
-static WERROR smbconf_reg_init(struct smbconf_ctx *ctx)
+static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
{
WERROR werr = WERR_OK;
+ if (path == NULL) {
+ path = KEY_SMBCONF;
+ }
+ ctx->path = talloc_strdup(ctx, path);
+ if (ctx->path == NULL) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
+
if (!registry_init_smbconf()) {
werr = WERR_REG_IO_FAILURE;
goto done;
@@ -433,7 +442,7 @@ static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
TALLOC_CTX* mem_ctx = talloc_stackframe();
enum winreg_CreateAction action;
- path = talloc_strdup(mem_ctx, KEY_SMBCONF);
+ path = talloc_strdup(mem_ctx, ctx->path);
if (path == NULL) {
werr = WERR_NOMEM;
goto done;
@@ -742,7 +751,8 @@ struct smbconf_ops smbconf_ops_reg = {
* initialize the smbconf registry backend
* the only function that is exported from this module
*/
-WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx)
+WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+ const char *path)
{
- return smbconf_init(mem_ctx, conf_ctx, &smbconf_ops_reg);
+ return smbconf_init(mem_ctx, conf_ctx, path, &smbconf_ops_reg);
}