struct reg_private_data {
NT_USER_TOKEN *token;
+ bool open; /* did _we_ open the registry? */
};
/**********************************************************************
goto done;
}
+ werr = ctx->ops->open_conf(ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, ("Error opening the registry.\n"));
+ goto done;
+ }
+
if (path == NULL) {
DEBUG(1, ("Error: NULL path string given\n"));
werr = WERR_INVALID_PARAM;
DEBUG(1, ("Error creating admin token\n"));
goto done;
}
+ rpd(ctx)->open = false;
if (!registry_init_smbconf()) {
werr = WERR_REG_IO_FAILURE;
goto done;
}
-
+ /* we know registry_init_smbconf() leaves registry open */
+ regdb_close();
done:
return werr;
static int smbconf_reg_shutdown(struct smbconf_ctx *ctx)
{
- return regdb_close();
+ return ctx->ops->close_conf(ctx);
}
static WERROR smbconf_reg_open(struct smbconf_ctx *ctx)
{
- return regdb_open();
+ WERROR werr;
+
+ if (rpd(ctx)->open) {
+ return WERR_OK;
+ }
+
+ werr = regdb_open();
+ if (W_ERROR_IS_OK(werr)) {
+ rpd(ctx)->open = true;
+ }
+ return werr;
}
static int smbconf_reg_close(struct smbconf_ctx *ctx)
{
- return regdb_close();
+ int ret;
+
+ if (!rpd(ctx)->open) {
+ return 0;
+ }
+
+ ret = regdb_close();
+ if (ret == 0) {
+ rpd(ctx)->open = false;
+ }
+ return ret;
}
/**
if (csn == NULL) {
return;
}
+
+ if (!W_ERROR_IS_OK(ctx->ops->open_conf(ctx))) {
+ return;
+ }
+
csn->csn = (uint64_t)regdb_get_seqnum();
}