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)
return WERR_NOT_SUPPORTED;
}
- werr = smbconf_init_reg(ctx, &conf_ctx);
+ werr = smbconf_init_reg(ctx, &conf_ctx, NULL);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
* 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;
ctx->ops = ops;
- werr = ctx->ops->init(ctx);
+ werr = ctx->ops->init(ctx, path);
if (!W_ERROR_IS_OK(werr)) {
goto fail;
}
* 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
#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);
struct smbconf_ctx {
NT_USER_TOKEN *token;
+ const char *path;
struct smbconf_ops *ops;
};
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
}
/**
- * 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,
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;
}
/**
- * 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);
}
}
/**
- * 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,
/**
* 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;
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;
* 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);
}
WERROR werr;
struct smbconf_ctx *ctx;
- werr = smbconf_init_reg(r, &ctx);
+ werr = smbconf_init_reg(r, &ctx, NULL);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
WERROR werr = WERR_OK;
struct smbconf_ctx *ctx;
- werr = smbconf_init_reg(r, &ctx);
+ werr = smbconf_init_reg(r, &ctx, NULL);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
if (conf_ctx == NULL) {
/* first time */
- werr = smbconf_init_reg(NULL, &conf_ctx);
+ werr = smbconf_init_reg(NULL, &conf_ctx, NULL);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
if (lp_config_backend_is_registry()) {
if (conf_ctx == NULL) {
WERROR werr;
- werr = smbconf_init_reg(NULL, &conf_ctx);
+ werr = smbconf_init_reg(NULL, &conf_ctx, NULL);
if (!W_ERROR_IS_OK(werr)) {
DEBUG(0, ("error opening configuration: %s\n",
dos_errstr(werr)));
struct smbconf_ctx *conf_ctx;
int ret = -1;
- werr = smbconf_init_reg(mem_ctx, &conf_ctx);
+ werr = smbconf_init_reg(mem_ctx, &conf_ctx, NULL);
if (!W_ERROR_IS_OK(werr)) {
return -1;