From 713b2ae447716138b5c12535e9f50896e9bcbfe7 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 11 Apr 2011 14:20:32 +0200 Subject: [PATCH] libsmbconf: Convert smbconf_delete_parameter() to sbcErr. Signed-off-by: Michael Adam (cherry picked from commit 48a7ab68261d8cb4d2efa03e141cdff28deb6905) --- lib/smbconf/smbconf.c | 11 +++++------ lib/smbconf/smbconf.h | 4 ++-- lib/smbconf/smbconf_private.h | 2 +- lib/smbconf/smbconf_txt.c | 4 ++-- source3/lib/smbconf/smbconf_reg.c | 14 ++++++++------ source3/libnet/libnet_join.c | 7 +++++-- source3/utils/net_conf.c | 13 ++++++------- 7 files changed, 29 insertions(+), 26 deletions(-) diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c index 02c49cc877d..a6bb64fec88 100644 --- a/lib/smbconf/smbconf.c +++ b/lib/smbconf/smbconf.c @@ -330,7 +330,7 @@ sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx, /** * delete a parameter from configuration */ -WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx, const char *service, const char *param) { return ctx->ops->delete_parameter(ctx, service, param); @@ -341,19 +341,18 @@ WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx, * * Create [global] if it does not exist. */ -WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx, const char *param) { - WERROR werr; sbcErr err; err = smbconf_global_check(ctx); if (!SBC_ERROR_IS_OK(err)) { - return WERR_GENERAL_FAILURE; + return err; } - werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param); + err = smbconf_delete_parameter(ctx, GLOBAL_NAME, param); - return werr; + return err; } WERROR smbconf_get_includes(struct smbconf_ctx *ctx, diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h index 15476f14608..e0a3ed50545 100644 --- a/lib/smbconf/smbconf.h +++ b/lib/smbconf/smbconf.h @@ -107,9 +107,9 @@ sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, const char *param, char **valstr); -WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx, const char *service, const char *param); -WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx, +sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx, const char *param); WERROR smbconf_get_includes(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h index 9bfcbe097af..c46d30279b4 100644 --- a/lib/smbconf/smbconf_private.h +++ b/lib/smbconf/smbconf_private.h @@ -57,7 +57,7 @@ struct smbconf_ops { const char *service, const char *param, char **valstr); - WERROR (*delete_parameter)(struct smbconf_ctx *ctx, + sbcErr (*delete_parameter)(struct smbconf_ctx *ctx, const char *service, const char *param); WERROR (*get_includes)(struct smbconf_ctx *ctx, TALLOC_CTX *mem_ctx, diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c index e31009e7b26..17dee486d55 100644 --- a/lib/smbconf/smbconf_txt.c +++ b/lib/smbconf/smbconf_txt.c @@ -526,11 +526,11 @@ static sbcErr smbconf_txt_get_parameter(struct smbconf_ctx *ctx, /** * delete a parameter from configuration */ -static WERROR smbconf_txt_delete_parameter(struct smbconf_ctx *ctx, +static sbcErr smbconf_txt_delete_parameter(struct smbconf_ctx *ctx, const char *service, const char *param) { - return WERR_NOT_SUPPORTED; + return SBC_ERR_NOT_SUPPORTED; } static WERROR smbconf_txt_get_includes(struct smbconf_ctx *ctx, diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c index 42eb6d18b93..f78c3555ab5 100644 --- a/source3/lib/smbconf/smbconf_reg.c +++ b/source3/lib/smbconf/smbconf_reg.c @@ -1036,37 +1036,39 @@ done: /** * delete a parameter from configuration */ -static WERROR smbconf_reg_delete_parameter(struct smbconf_ctx *ctx, +static sbcErr smbconf_reg_delete_parameter(struct smbconf_ctx *ctx, const char *service, const char *param) { struct registry_key *key = NULL; - WERROR werr = WERR_OK; + WERROR werr; sbcErr err; TALLOC_CTX *mem_ctx = talloc_stackframe(); err = smbconf_reg_open_service_key(mem_ctx, ctx, service, REG_KEY_ALL, &key); if (!SBC_ERROR_IS_OK(err)) { - werr = WERR_NOMEM; goto done; } if (!smbconf_reg_valname_valid(param)) { - werr = WERR_INVALID_PARAM; + err = SBC_ERR_INVALID_PARAM; goto done; } if (!smbconf_value_exists(key, param)) { - werr = WERR_INVALID_PARAM; + err = SBC_ERR_CAN_NOT_COMPLETE; goto done; } werr = reg_deletevalue(key, param); + if (!W_ERROR_IS_OK(werr)) { + err = SBC_ERR_ACCESS_DENIED; + } done: talloc_free(mem_ctx); - return werr; + return err; } static WERROR smbconf_reg_get_includes(struct smbconf_ctx *ctx, diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 36175791c6f..0c5e1f082e3 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1539,8 +1539,11 @@ static WERROR do_unjoin_modify_vals_config(struct libnet_UnjoinCtx *r) goto done; } - werr = smbconf_delete_global_parameter(ctx, "workgroup"); - W_ERROR_NOT_OK_GOTO_DONE(werr); + err = smbconf_delete_global_parameter(ctx, "workgroup"); + if (!SBC_ERROR_IS_OK(err)) { + werr = WERR_NO_SUCH_SERVICE; + goto done; + } smbconf_delete_global_parameter(ctx, "realm"); } diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c index 187735027b4..bee8dd2a198 100644 --- a/source3/utils/net_conf.c +++ b/source3/utils/net_conf.c @@ -960,7 +960,7 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; - WERROR werr = WERR_OK; + sbcErr err; char *service = NULL; char *param = NULL; TALLOC_CTX *mem_ctx = talloc_stackframe(); @@ -986,21 +986,20 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx, goto done; } - werr = smbconf_delete_parameter(conf_ctx, service, param); - - if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) { + err = smbconf_delete_parameter(conf_ctx, service, param); + if (SBC_ERROR_EQUAL(err, SBC_ERR_NO_SUCH_SERVICE)) { d_fprintf(stderr, _("Error: given service '%s' does not exist.\n"), service); goto done; - } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) { + } else if (SBC_ERROR_EQUAL(err, SBC_ERR_INVALID_PARAM)) { d_fprintf(stderr, _("Error: given parameter '%s' is not set.\n"), param); goto done; - } else if (!W_ERROR_IS_OK(werr)) { + } else if (!SBC_ERROR_IS_OK(err)) { d_fprintf(stderr, _("Error deleting value '%s': %s.\n"), - param, win_errstr(werr)); + param, sbcErrorString(err)); goto done; } -- 2.11.4.GIT