summaryrefslogtreecommitdiff
path: root/source3/lib/smbconf
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/smbconf')
-rw-r--r--source3/lib/smbconf/smbconf.c4
-rw-r--r--source3/lib/smbconf/smbconf.h3
-rw-r--r--source3/lib/smbconf/smbconf_private.h5
-rw-r--r--source3/lib/smbconf/smbconf_reg.c28
4 files changed, 26 insertions, 14 deletions
diff --git a/source3/lib/smbconf/smbconf.c b/source3/lib/smbconf/smbconf.c
index 0eee5a6c4a..756b9ec3ca 100644
--- a/source3/lib/smbconf/smbconf.c
+++ b/source3/lib/smbconf/smbconf.c
@@ -92,7 +92,7 @@ static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
* should be called.
*/
WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
- struct smbconf_ops *ops)
+ const char *path, struct smbconf_ops *ops)
{
WERROR werr = WERR_OK;
struct smbconf_ctx *ctx;
@@ -108,7 +108,7 @@ WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
ctx->ops = ops;
- werr = ctx->ops->init(ctx);
+ werr = ctx->ops->init(ctx, path);
if (!W_ERROR_IS_OK(werr)) {
goto fail;
}
diff --git a/source3/lib/smbconf/smbconf.h b/source3/lib/smbconf/smbconf.h
index 35da36795e..23b9504971 100644
--- a/source3/lib/smbconf/smbconf.h
+++ b/source3/lib/smbconf/smbconf.h
@@ -35,7 +35,8 @@ struct smbconf_csn {
* initialization functions for the available modules
* (a dispatcher might be added in the future)
*/
-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);
/*
* the smbconf API functions
diff --git a/source3/lib/smbconf/smbconf_private.h b/source3/lib/smbconf/smbconf_private.h
index 008ae97601..6250dc7339 100644
--- a/source3/lib/smbconf/smbconf_private.h
+++ b/source3/lib/smbconf/smbconf_private.h
@@ -21,7 +21,7 @@
#define __LIBSMBCONF_PRIVATE_H__
struct smbconf_ops {
- WERROR (*init)(struct smbconf_ctx *ctx);
+ WERROR (*init)(struct smbconf_ctx *ctx, const char *path);
int (*shutdown)(struct smbconf_ctx *ctx);
WERROR (*open_conf)(struct smbconf_ctx *ctx);
int (*close_conf)(struct smbconf_ctx *ctx);
@@ -55,6 +55,7 @@ struct smbconf_ops {
struct smbconf_ctx {
NT_USER_TOKEN *token;
+ const char *path;
struct smbconf_ops *ops;
};
@@ -64,6 +65,6 @@ WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
const char *string);
WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
- struct smbconf_ops *ops);
+ const char *path, struct smbconf_ops *ops);
#endif
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);
}