1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

libsmbconf: Convert smbconf_open() to sbcErr.

Signed-off-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Andreas Schneider 2011-04-08 10:28:17 +02:00 committed by Michael Adam
parent 29eea4b09a
commit 9082c7cee8
4 changed files with 19 additions and 22 deletions

View File

@ -31,7 +31,7 @@ struct smbconf_ops {
int (*shutdown)(struct smbconf_ctx *ctx); int (*shutdown)(struct smbconf_ctx *ctx);
bool (*requires_messaging)(struct smbconf_ctx *ctx); bool (*requires_messaging)(struct smbconf_ctx *ctx);
bool (*is_writeable)(struct smbconf_ctx *ctx); bool (*is_writeable)(struct smbconf_ctx *ctx);
WERROR (*open_conf)(struct smbconf_ctx *ctx); sbcErr (*open_conf)(struct smbconf_ctx *ctx);
int (*close_conf)(struct smbconf_ctx *ctx); int (*close_conf)(struct smbconf_ctx *ctx);
void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn, void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
const char *service, const char *param); const char *service, const char *param);

View File

@ -256,16 +256,9 @@ static bool smbconf_txt_is_writeable(struct smbconf_ctx *ctx)
return false; return false;
} }
static WERROR smbconf_txt_open(struct smbconf_ctx *ctx) static sbcErr smbconf_txt_open(struct smbconf_ctx *ctx)
{ {
sbcErr err; return smbconf_txt_load_file(ctx);
err = smbconf_txt_load_file(ctx);
if (!SBC_ERROR_IS_OK(err)) {
return WERR_GENERAL_FAILURE;
}
return WERR_OK;
} }
static int smbconf_txt_close(struct smbconf_ctx *ctx) static int smbconf_txt_close(struct smbconf_ctx *ctx)

View File

@ -569,9 +569,10 @@ done:
/** /**
* initialize the registry smbconf backend * initialize the registry smbconf backend
*/ */
static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path) static sbcErr smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
{ {
WERROR werr = WERR_OK; WERROR werr = WERR_OK;
sbcErr err;
struct security_token *token; struct security_token *token;
if (path == NULL) { if (path == NULL) {
@ -588,17 +589,19 @@ static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token)); werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
if (!W_ERROR_IS_OK(werr)) { if (!W_ERROR_IS_OK(werr)) {
DEBUG(1, ("Error creating admin token\n")); DEBUG(1, ("Error creating admin token\n"));
err = SBC_ERR_UNKNOWN_FAILURE;
goto done; goto done;
} }
rpd(ctx)->open = false; rpd(ctx)->open = false;
werr = registry_init_smbconf(path); werr = registry_init_smbconf(path);
if (!W_ERROR_IS_OK(werr)) { if (!W_ERROR_IS_OK(werr)) {
err = SBC_ERR_BADFILE;
goto done; goto done;
} }
werr = ctx->ops->open_conf(ctx); err = ctx->ops->open_conf(ctx);
if (!W_ERROR_IS_OK(werr)) { if (!SBC_ERROR_IS_OK(err)) {
DEBUG(1, ("Error opening the registry.\n")); DEBUG(1, ("Error opening the registry.\n"));
goto done; goto done;
} }
@ -607,11 +610,12 @@ static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
KEY_ENUMERATE_SUB_KEYS | REG_KEY_WRITE, KEY_ENUMERATE_SUB_KEYS | REG_KEY_WRITE,
token, &rpd(ctx)->base_key); token, &rpd(ctx)->base_key);
if (!W_ERROR_IS_OK(werr)) { if (!W_ERROR_IS_OK(werr)) {
err = SBC_ERR_UNKNOWN_FAILURE;
goto done; goto done;
} }
done: done:
return werr; return err;
} }
static int smbconf_reg_shutdown(struct smbconf_ctx *ctx) static int smbconf_reg_shutdown(struct smbconf_ctx *ctx)
@ -640,19 +644,21 @@ static bool smbconf_reg_is_writeable(struct smbconf_ctx *ctx)
return true; return true;
} }
static WERROR smbconf_reg_open(struct smbconf_ctx *ctx) static sbcErr smbconf_reg_open(struct smbconf_ctx *ctx)
{ {
WERROR werr; WERROR werr;
if (rpd(ctx)->open) { if (rpd(ctx)->open) {
return WERR_OK; return SBC_ERR_OK;
} }
werr = regdb_open(); werr = regdb_open();
if (W_ERROR_IS_OK(werr)) { if (!W_ERROR_IS_OK(werr)) {
rpd(ctx)->open = true; return SBC_ERR_BADFILE;
} }
return werr;
rpd(ctx)->open = true;
return SBC_ERR_OK;
} }
static int smbconf_reg_close(struct smbconf_ctx *ctx) static int smbconf_reg_close(struct smbconf_ctx *ctx)
@ -682,7 +688,7 @@ static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
return; return;
} }
if (!W_ERROR_IS_OK(ctx->ops->open_conf(ctx))) { if (!SBC_ERROR_IS_OK(ctx->ops->open_conf(ctx))) {
return; return;
} }

View File

@ -203,7 +203,6 @@ static bool create_conf_file(const char *filename)
static bool torture_smbconf_txt(void) static bool torture_smbconf_txt(void)
{ {
WERROR werr;
sbcErr err; sbcErr err;
bool ret = true; bool ret = true;
const char *filename = "/tmp/smb.conf.smbconf_testsuite"; const char *filename = "/tmp/smb.conf.smbconf_testsuite";
@ -246,7 +245,6 @@ done:
static bool torture_smbconf_reg(void) static bool torture_smbconf_reg(void)
{ {
WERROR werr;
sbcErr err; sbcErr err;
bool ret = true; bool ret = true;
struct smbconf_ctx *conf_ctx = NULL; struct smbconf_ctx *conf_ctx = NULL;