summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/smbconf/smbconf.c66
-rw-r--r--lib/smbconf/smbconf.h2
-rw-r--r--lib/smbconf/smbconf_private.h2
-rw-r--r--lib/smbconf/smbconf_txt.c4
-rw-r--r--source3/lib/smbconf/smbconf_reg.c22
-rw-r--r--source3/utils/net_conf.c20
6 files changed, 68 insertions, 48 deletions
diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
index f429295568..68f7dfc902 100644
--- a/lib/smbconf/smbconf.c
+++ b/lib/smbconf/smbconf.c
@@ -27,12 +27,13 @@
*
**********************************************************************/
-static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
+static sbcErr smbconf_global_check(struct smbconf_ctx *ctx)
{
if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
return smbconf_create_share(ctx, GLOBAL_NAME);
}
- return WERR_OK;
+
+ return SBC_ERR_OK;
}
@@ -222,11 +223,11 @@ bool smbconf_share_exists(struct smbconf_ctx *ctx,
/**
* Add a service if it does not already exist.
*/
-WERROR smbconf_create_share(struct smbconf_ctx *ctx,
+sbcErr smbconf_create_share(struct smbconf_ctx *ctx,
const char *servicename)
{
if ((servicename != NULL) && smbconf_share_exists(ctx, servicename)) {
- return WERR_FILE_EXISTS;
+ return SBC_ERR_FILE_EXISTS;
}
return ctx->ops->create_share(ctx, servicename);
@@ -275,12 +276,14 @@ WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
const char *param, const char *val)
{
- WERROR werr;
+ WERROR werr = WERR_OK;
+ sbcErr err;
- werr = smbconf_global_check(ctx);
- if (W_ERROR_IS_OK(werr)) {
- werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
+ err = smbconf_global_check(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
+ werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
return werr;
}
@@ -312,13 +315,16 @@ WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
char **valstr)
{
WERROR werr;
+ sbcErr err;
- werr = smbconf_global_check(ctx);
- if (W_ERROR_IS_OK(werr)) {
- werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param,
- valstr);
+ err = smbconf_global_check(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
+ werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param,
+ valstr);
+
return werr;
}
@@ -340,11 +346,13 @@ WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
const char *param)
{
WERROR werr;
+ sbcErr err;
- werr = smbconf_global_check(ctx);
- if (W_ERROR_IS_OK(werr)) {
- werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param);
+ err = smbconf_global_check(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
+ werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param);
return werr;
}
@@ -363,12 +371,14 @@ WERROR smbconf_get_global_includes(struct smbconf_ctx *ctx,
uint32_t *num_includes, char ***includes)
{
WERROR werr;
+ sbcErr err;
- werr = smbconf_global_check(ctx);
- if (W_ERROR_IS_OK(werr)) {
- werr = smbconf_get_includes(ctx, mem_ctx, GLOBAL_NAME,
- num_includes, includes);
+ err = smbconf_global_check(ctx);
+ if (SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
+ werr = smbconf_get_includes(ctx, mem_ctx, GLOBAL_NAME,
+ num_includes, includes);
return werr;
}
@@ -385,12 +395,14 @@ WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
const char **includes)
{
WERROR werr;
+ sbcErr err;
- werr = smbconf_global_check(ctx);
- if (W_ERROR_IS_OK(werr)) {
- werr = smbconf_set_includes(ctx, GLOBAL_NAME,
- num_includes, includes);
+ err = smbconf_global_check(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
+ werr = smbconf_set_includes(ctx, GLOBAL_NAME,
+ num_includes, includes);
return werr;
}
@@ -404,11 +416,13 @@ WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service)
WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx)
{
WERROR werr;
+ sbcErr err;
- werr = smbconf_global_check(ctx);
- if (W_ERROR_IS_OK(werr)) {
- werr = smbconf_delete_includes(ctx, GLOBAL_NAME);
+ err = smbconf_global_check(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
+ werr = smbconf_delete_includes(ctx, GLOBAL_NAME);
return werr;
}
diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h
index af50dfb9a5..c1a82b5cf8 100644
--- a/lib/smbconf/smbconf.h
+++ b/lib/smbconf/smbconf.h
@@ -84,7 +84,7 @@ sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx,
uint32_t *num_shares,
char ***share_names);
bool smbconf_share_exists(struct smbconf_ctx *ctx, const char *servicename);
-WERROR smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename);
+sbcErr smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename);
WERROR smbconf_get_share(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h
index 4058ade2e4..222497d031 100644
--- a/lib/smbconf/smbconf_private.h
+++ b/lib/smbconf/smbconf_private.h
@@ -41,7 +41,7 @@ struct smbconf_ops {
uint32_t *num_shares,
char ***share_names);
bool (*share_exists)(struct smbconf_ctx *ctx, const char *service);
- WERROR (*create_share)(struct smbconf_ctx *ctx, const char *service);
+ sbcErr (*create_share)(struct smbconf_ctx *ctx, const char *service);
WERROR (*get_share)(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c
index 444fa08663..1be27e6bbd 100644
--- a/lib/smbconf/smbconf_txt.c
+++ b/lib/smbconf/smbconf_txt.c
@@ -385,10 +385,10 @@ static bool smbconf_txt_share_exists(struct smbconf_ctx *ctx,
/**
* Add a service if it does not already exist
*/
-static WERROR smbconf_txt_create_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_txt_create_share(struct smbconf_ctx *ctx,
const char *servicename)
{
- return WERR_NOT_SUPPORTED;
+ return SBC_ERR_NOT_SUPPORTED;
}
/**
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index f6b6d8d46b..78a3145db5 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -127,12 +127,13 @@ static bool smbconf_value_exists(struct registry_key *key, const char *param)
/**
* create a subkey of the base key (i.e. a service...)
*/
-static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
+static sbcErr smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
struct smbconf_ctx *ctx,
const char * subkeyname,
struct registry_key **newkey)
{
- WERROR werr = WERR_OK;
+ WERROR werr;
+ sbcErr err = SBC_ERR_OK;
TALLOC_CTX *create_ctx;
enum winreg_CreateAction action = REG_ACTION_NONE;
@@ -145,15 +146,16 @@ static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
REG_KEY_WRITE, newkey, &action);
if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
DEBUG(10, ("Key '%s' already exists.\n", subkeyname));
- werr = WERR_FILE_EXISTS;
+ err = SBC_ERR_FILE_EXISTS;
}
if (!W_ERROR_IS_OK(werr)) {
DEBUG(5, ("Error creating key %s: %s\n",
subkeyname, win_errstr(werr)));
+ err = SBC_ERR_UNKNOWN_FAILURE;
}
talloc_free(create_ctx);
- return werr;
+ return err;
}
/**
@@ -864,21 +866,21 @@ static bool smbconf_reg_share_exists(struct smbconf_ctx *ctx,
/**
* Add a service if it does not already exist - registry version
*/
-static WERROR smbconf_reg_create_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_create_share(struct smbconf_ctx *ctx,
const char *servicename)
{
- WERROR werr;
+ sbcErr err;
struct registry_key *key = NULL;
if (servicename == NULL) {
- return WERR_OK;
+ return SBC_ERR_OK;
}
- werr = smbconf_reg_create_service_key(talloc_tos(), ctx,
- servicename, &key);
+ err = smbconf_reg_create_service_key(talloc_tos(), ctx,
+ servicename, &key);
talloc_free(key);
- return werr;
+ return err;
}
/**
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 192088c6ba..3b6005a2b9 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -180,6 +180,7 @@ static WERROR import_process_service(struct net_context *c,
{
uint32_t idx;
WERROR werr = WERR_OK;
+ sbcErr err;
uint32_t num_includes = 0;
char **includes = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -205,8 +206,9 @@ static WERROR import_process_service(struct net_context *c,
goto done;
}
}
- werr = smbconf_create_share(conf_ctx, service->name);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, service->name);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_GENERAL_FAILURE;
goto done;
}
@@ -578,6 +580,7 @@ static int net_conf_addshare(struct net_context *c,
{
int ret = -1;
WERROR werr = WERR_OK;
+ sbcErr err;
char *sharename = NULL;
const char *path = NULL;
const char *comment = NULL;
@@ -714,10 +717,10 @@ static int net_conf_addshare(struct net_context *c,
* create the share
*/
- werr = smbconf_create_share(conf_ctx, sharename);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, sharename);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error creating share %s: %s\n"),
- sharename, win_errstr(werr));
+ sharename, sbcErrorString(err));
goto cancel;
}
@@ -820,6 +823,7 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
{
int ret = -1;
WERROR werr = WERR_OK;
+ sbcErr err;
char *service = NULL;
char *param = NULL;
const char *value_str = NULL;
@@ -855,10 +859,10 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
}
if (!smbconf_share_exists(conf_ctx, service)) {
- werr = smbconf_create_share(conf_ctx, service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, service);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error creating share '%s': %s\n"),
- service, win_errstr(werr));
+ service, sbcErrorString(err));
goto cancel;
}
}