libsmbconf: Convert smbconf_drop() to sbcErr.
authorAndreas Schneider <asn@samba.org>
Fri, 8 Apr 2011 08:40:02 +0000 (10:40 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 10 May 2011 17:13:20 +0000 (19:13 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
lib/smbconf/smbconf.c
lib/smbconf/smbconf.h
lib/smbconf/smbconf_private.h
lib/smbconf/smbconf_txt.c
source3/lib/smbconf/smbconf_reg.c
source3/utils/net_conf.c

index 5fbf52da05098bd070018e97cbc5c7068d528011..366b78dd6ec0ec21ba5d3717b8f5eae09491d9f6 100644 (file)
@@ -126,7 +126,7 @@ bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
 /**
  * Drop the whole configuration (restarting empty).
  */
-WERROR smbconf_drop(struct smbconf_ctx *ctx)
+sbcErr smbconf_drop(struct smbconf_ctx *ctx)
 {
        return ctx->ops->drop(ctx);
 }
index 11e971b5bad91880215aacc0746455483a0b81e1..535582565abaddefd6aacc3f2dfc24b42ff211e8 100644 (file)
@@ -74,7 +74,7 @@ bool smbconf_is_writeable(struct smbconf_ctx *ctx);
 void smbconf_shutdown(struct smbconf_ctx *ctx);
 bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
                     const char *service, const char *param);
-WERROR smbconf_drop(struct smbconf_ctx *ctx);
+sbcErr smbconf_drop(struct smbconf_ctx *ctx);
 WERROR smbconf_get_config(struct smbconf_ctx *ctx,
                          TALLOC_CTX *mem_ctx,
                          uint32_t *num_shares,
index 26573274ee2df6c9bb4649a3768734eaeba87fc6..3d68a05c343fea4cef5ca80453d3bc036b09760c 100644 (file)
@@ -35,7 +35,7 @@ struct smbconf_ops {
        int (*close_conf)(struct smbconf_ctx *ctx);
        void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
                        const char *service, const char *param);
-       WERROR (*drop)(struct smbconf_ctx *ctx);
+       sbcErr (*drop)(struct smbconf_ctx *ctx);
        WERROR (*get_share_names)(struct smbconf_ctx *ctx,
                                  TALLOC_CTX *mem_ctx,
                                  uint32_t *num_shares,
index 1ee855c641324e75bae9b69d082521a814a7b0dc..4b16cc23aaa54e9ea43c2941be7968636eff5ef9 100644 (file)
@@ -285,9 +285,9 @@ static void smbconf_txt_get_csn(struct smbconf_ctx *ctx,
 /**
  * Drop the whole configuration (restarting empty)
  */
-static WERROR smbconf_txt_drop(struct smbconf_ctx *ctx)
+static sbcErr smbconf_txt_drop(struct smbconf_ctx *ctx)
 {
-       return WERR_NOT_SUPPORTED;
+       return SBC_ERR_NOT_SUPPORTED;
 }
 
 /**
index 71b60c86bc1b2f5e3f3430ab7dd1bd6a94be6fb1..844a9b6b483bf218e43d7f330a3c8d7ff13aeb35 100644 (file)
@@ -698,10 +698,11 @@ static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
 /**
  * Drop the whole configuration (restarting empty) - registry version
  */
-static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
+static sbcErr smbconf_reg_drop(struct smbconf_ctx *ctx)
 {
        char *path, *p;
        WERROR werr = WERR_OK;
+       sbcErr err = SBC_ERR_OK;
        struct registry_key *parent_key = NULL;
        struct registry_key *new_key = NULL;
        TALLOC_CTX* mem_ctx = talloc_stackframe();
@@ -711,39 +712,44 @@ static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
        werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
        if (!W_ERROR_IS_OK(werr)) {
                DEBUG(1, ("Error creating admin token\n"));
+               err = SBC_ERR_UNKNOWN_FAILURE;
                goto done;
        }
 
        path = talloc_strdup(mem_ctx, ctx->path);
        if (path == NULL) {
-               werr = WERR_NOMEM;
+               err = SBC_ERR_NOMEM;
                goto done;
        }
        p = strrchr(path, '\\');
        if (p == NULL) {
-               werr = WERR_INVALID_PARAM;
+               err = SBC_ERR_INVALID_PARAM;
                goto done;
        }
        *p = '\0';
        werr = reg_open_path(mem_ctx, path, REG_KEY_WRITE, token,
                             &parent_key);
-
        if (!W_ERROR_IS_OK(werr)) {
+               err = SBC_ERR_IO_FAILURE;
                goto done;
        }
 
        werr = reg_deletekey_recursive(parent_key, p+1);
-
        if (!W_ERROR_IS_OK(werr)) {
+               err = SBC_ERR_IO_FAILURE;
                goto done;
        }
 
        werr = reg_createkey(mem_ctx, parent_key, p+1, REG_KEY_WRITE,
                             &new_key, &action);
+       if (!W_ERROR_IS_OK(werr)) {
+               err = SBC_ERR_IO_FAILURE;
+               goto done;
+       }
 
 done:
        talloc_free(mem_ctx);
-       return werr;
+       return err;
 }
 
 /**
index 9ed19f1fdb9007311c849a93263a8e9c83a324c7..c0f6e08ec2bb447def1ed15353ca194d6b9a1bb7 100644 (file)
@@ -393,8 +393,7 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
                        goto cancel;
                }
                if (!c->opt_testmode) {
-                       werr = smbconf_drop(conf_ctx);
-                       if (!W_ERROR_IS_OK(werr)) {
+                       if (!SBC_ERROR_IS_OK(smbconf_drop(conf_ctx))) {
                                goto cancel;
                        }
                }
@@ -502,17 +501,17 @@ static int net_conf_drop(struct net_context *c, struct smbconf_ctx *conf_ctx,
                         int argc, const char **argv)
 {
        int ret = -1;
-       WERROR werr;
+       sbcErr err;
 
        if (argc != 0 || c->display_usage) {
                net_conf_drop_usage(c, argc, argv);
                goto done;
        }
 
-       werr = smbconf_drop(conf_ctx);
-       if (!W_ERROR_IS_OK(werr)) {
+       err = smbconf_drop(conf_ctx);
+       if (!SBC_ERROR_IS_OK(err)) {
                d_fprintf(stderr, _("Error deleting configuration: %s\n"),
-                         win_errstr(werr));
+                         sbcErrorString(err));
                goto done;
        }