libsmbconf: Convert smbconf_delete_share() to sbcErr.
authorAndreas Schneider <asn@samba.org>
Mon, 11 Apr 2011 09:39:03 +0000 (11:39 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 10 May 2011 17:13:21 +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 e374956ca32c50aa38a04913520258125b114584..c02899c0d5bdf896317fb0ba26fe72a508c0fc7d 100644 (file)
@@ -248,10 +248,10 @@ sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
 /**
  * delete a service from configuration
  */
-WERROR smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)
+sbcErr smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)
 {
        if (!smbconf_share_exists(ctx, servicename)) {
-               return WERR_NO_SUCH_SERVICE;
+               return SBC_ERR_NO_SUCH_SERVICE;
        }
 
        return ctx->ops->delete_share(ctx, servicename);
index 93f916f0e4aee92dab83f2e781c4509de641fd75..af021f95d76793ab683fa9db4349aeb93dfa9882 100644 (file)
@@ -89,7 +89,7 @@ sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
                         TALLOC_CTX *mem_ctx,
                         const char *servicename,
                         struct smbconf_service **service);
-WERROR smbconf_delete_share(struct smbconf_ctx *ctx,
+sbcErr smbconf_delete_share(struct smbconf_ctx *ctx,
                            const char *servicename);
 WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
                             const char *service,
index d1af40bf7c52f3d988e4173a9deb4dab25d4a415..0fa47e87a766d0402aa5925af171a7f3d9da881b 100644 (file)
@@ -46,7 +46,7 @@ struct smbconf_ops {
                            TALLOC_CTX *mem_ctx,
                            const char *servicename,
                            struct smbconf_service **service);
-       WERROR (*delete_share)(struct smbconf_ctx *ctx,
+       sbcErr (*delete_share)(struct smbconf_ctx *ctx,
                                    const char *servicename);
        WERROR (*set_parameter)(struct smbconf_ctx *ctx,
                                const char *service,
index e44abb154dba19971e9b6b1477c7a8feb5dd2282..1017b5a1c84ddd2ca66ed83fa9ec804339fb8331 100644 (file)
@@ -462,10 +462,10 @@ done:
 /**
  * delete a service from configuration
  */
-static WERROR smbconf_txt_delete_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_txt_delete_share(struct smbconf_ctx *ctx,
                                       const char *servicename)
 {
-       return WERR_NOT_SUPPORTED;
+       return SBC_ERR_NOT_SUPPORTED;
 }
 
 /**
index 2425180bd50080e2490d921e96418c73f0449504..e27a871a136abb7489ca0430b922efcf05d52326 100644 (file)
@@ -538,9 +538,10 @@ static bool smbconf_reg_key_has_values(struct registry_key *key)
 /**
  * delete all values from a key
  */
-static WERROR smbconf_reg_delete_values(struct registry_key *key)
+static sbcErr smbconf_reg_delete_values(struct registry_key *key)
 {
        WERROR werr;
+       sbcErr err;
        char *valname;
        struct registry_value *valvalue;
        uint32_t count;
@@ -553,6 +554,7 @@ static WERROR smbconf_reg_delete_values(struct registry_key *key)
        {
                werr = reg_deletevalue(key, valname);
                if (!W_ERROR_IS_OK(werr)) {
+                       err = SBC_ERR_ACCESS_DENIED;
                        goto done;
                }
        }
@@ -561,14 +563,15 @@ static WERROR smbconf_reg_delete_values(struct registry_key *key)
                          "Error enumerating values of %s: %s\n",
                          key->key->name,
                          win_errstr(werr)));
+               err = SBC_ERR_ACCESS_DENIED;
                goto done;
        }
 
-       werr = WERR_OK;
+       err = SBC_ERR_OK;
 
 done:
        talloc_free(mem_ctx);
-       return werr;
+       return err;
 }
 
 /**********************************************************************
@@ -934,20 +937,24 @@ done:
 /**
  * delete a service from configuration
  */
-static WERROR smbconf_reg_delete_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_delete_share(struct smbconf_ctx *ctx,
                                       const char *servicename)
 {
-       WERROR werr = WERR_OK;
+       WERROR werr;
+       sbcErr err = SBC_ERR_OK;
        TALLOC_CTX *mem_ctx = talloc_stackframe();
 
        if (servicename != NULL) {
                werr = reg_deletekey_recursive(rpd(ctx)->base_key, servicename);
+               if (!W_ERROR_IS_OK(werr)) {
+                       err = SBC_ERR_ACCESS_DENIED;
+               }
        } else {
-               werr = smbconf_reg_delete_values(rpd(ctx)->base_key);
+               err = smbconf_reg_delete_values(rpd(ctx)->base_key);
        }
 
        talloc_free(mem_ctx);
-       return werr;
+       return err;
 }
 
 /**
index d4f91c691a5836f5dd3994a095b61c28874241e7..7e166e8e37a17af71b40d3e736195e7045d4dcdb 100644 (file)
@@ -201,8 +201,9 @@ static WERROR import_process_service(struct net_context *c,
        }
 
        if (smbconf_share_exists(conf_ctx, service->name)) {
-               werr = smbconf_delete_share(conf_ctx, service->name);
-               if (!W_ERROR_IS_OK(werr)) {
+               err = smbconf_delete_share(conf_ctx, service->name);
+               if (!SBC_ERROR_IS_OK(err)) {
+                       werr = WERR_GENERAL_FAILURE;
                        goto done;
                }
        }
@@ -792,7 +793,7 @@ static int net_conf_delshare(struct net_context *c,
 {
        int ret = -1;
        const char *sharename = NULL;
-       WERROR werr = WERR_OK;
+       sbcErr err;
        TALLOC_CTX *mem_ctx = talloc_stackframe();
 
        if (argc != 1 || c->display_usage) {
@@ -805,10 +806,10 @@ static int net_conf_delshare(struct net_context *c,
                goto done;
        }
 
-       werr = smbconf_delete_share(conf_ctx, sharename);
-       if (!W_ERROR_IS_OK(werr)) {
+       err = smbconf_delete_share(conf_ctx, sharename);
+       if (!SBC_ERROR_IS_OK(err)) {
                d_fprintf(stderr, _("Error deleting share %s: %s\n"),
-                         sharename, win_errstr(werr));
+                         sharename, sbcErrorString(err));
                goto done;
        }