summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/smbconf/smbconf_private.h4
-rw-r--r--lib/smbconf/smbconf_txt.c88
-rw-r--r--lib/smbconf/smbconf_txt.h2
-rw-r--r--lib/smbconf/smbconf_util.c16
-rw-r--r--source3/lib/netapi/serverinfo.c9
-rw-r--r--source3/lib/smbconf/smbconf_init.c20
-rw-r--r--source3/lib/smbconf/smbconf_init.h2
-rw-r--r--source3/lib/smbconf/smbconf_reg.c2
-rw-r--r--source3/lib/smbconf/smbconf_reg.h2
-rw-r--r--source3/lib/smbconf/testsuite.c14
-rw-r--r--source3/libnet/libnet_join.c12
-rw-r--r--source3/param/loadparm.c8
-rw-r--r--source3/utils/net_conf.c15
13 files changed, 108 insertions, 86 deletions
diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h
index e6998ad639..2b56367f6c 100644
--- a/lib/smbconf/smbconf_private.h
+++ b/lib/smbconf/smbconf_private.h
@@ -27,7 +27,7 @@
#include "lib/smbconf/smbconf.h"
struct smbconf_ops {
- WERROR (*init)(struct smbconf_ctx *ctx, const char *path);
+ sbcErr (*init)(struct smbconf_ctx *ctx, const char *path);
int (*shutdown)(struct smbconf_ctx *ctx);
bool (*requires_messaging)(struct smbconf_ctx *ctx);
bool (*is_writeable)(struct smbconf_ctx *ctx);
@@ -79,7 +79,7 @@ struct smbconf_ctx {
void *data; /* private data for use in backends */
};
-WERROR smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *path, struct smbconf_ops *ops);
WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c
index 2114841b81..f7bae4e315 100644
--- a/lib/smbconf/smbconf_txt.c
+++ b/lib/smbconf/smbconf_txt.c
@@ -165,7 +165,7 @@ static void smbconf_txt_flush_cache(struct smbconf_ctx *ctx)
pd(ctx)->cache = NULL;
}
-static WERROR smbconf_txt_init_cache(struct smbconf_ctx *ctx)
+static sbcErr smbconf_txt_init_cache(struct smbconf_ctx *ctx)
{
if (pd(ctx)->cache != NULL) {
smbconf_txt_flush_cache(ctx);
@@ -174,40 +174,40 @@ static WERROR smbconf_txt_init_cache(struct smbconf_ctx *ctx)
pd(ctx)->cache = talloc_zero(pd(ctx), struct txt_cache);
if (pd(ctx)->cache == NULL) {
- return WERR_NOMEM;
+ return SBC_ERR_NOMEM;
}
- return WERR_OK;
+ return SBC_ERR_OK;
}
-static WERROR smbconf_txt_load_file(struct smbconf_ctx *ctx)
+static sbcErr smbconf_txt_load_file(struct smbconf_ctx *ctx)
{
- WERROR werr;
+ sbcErr err;
uint64_t new_csn;
if (!file_exist(ctx->path)) {
- return WERR_BADFILE;
+ return SBC_ERR_BADFILE;
}
new_csn = (uint64_t)file_modtime(ctx->path);
if (new_csn == pd(ctx)->csn) {
- return WERR_OK;
+ return SBC_ERR_OK;
}
- werr = smbconf_txt_init_cache(ctx);
- if (!W_ERROR_IS_OK(werr)) {
- return werr;
+ err = smbconf_txt_init_cache(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return err;
}
if (!pm_process(ctx->path, smbconf_txt_do_section,
smbconf_txt_do_parameter, pd(ctx)))
{
- return WERR_CAN_NOT_COMPLETE;
+ return SBC_ERR_CAN_NOT_COMPLETE;
}
pd(ctx)->csn = new_csn;
- return WERR_OK;
+ return SBC_ERR_OK;
}
@@ -220,24 +220,24 @@ static WERROR smbconf_txt_load_file(struct smbconf_ctx *ctx)
/**
* initialize the text based smbconf backend
*/
-static WERROR smbconf_txt_init(struct smbconf_ctx *ctx, const char *path)
+static sbcErr smbconf_txt_init(struct smbconf_ctx *ctx, const char *path)
{
if (path == NULL) {
- return WERR_BADFILE;
+ return SBC_ERR_BADFILE;
}
ctx->path = talloc_strdup(ctx, path);
if (ctx->path == NULL) {
- return WERR_NOMEM;
+ return SBC_ERR_NOMEM;
}
ctx->data = talloc_zero(ctx, struct txt_private_data);
if (ctx->data == NULL) {
- return WERR_NOMEM;
+ return SBC_ERR_NOMEM;
}
pd(ctx)->verbatim = true;
- return WERR_OK;
+ return SBC_ERR_OK;
}
static int smbconf_txt_shutdown(struct smbconf_ctx *ctx)
@@ -258,7 +258,14 @@ static bool smbconf_txt_is_writeable(struct smbconf_ctx *ctx)
static WERROR smbconf_txt_open(struct smbconf_ctx *ctx)
{
- return smbconf_txt_load_file(ctx);
+ sbcErr err;
+
+ 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)
@@ -302,6 +309,7 @@ static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx,
uint32_t added_count = 0;
TALLOC_CTX *tmp_ctx = NULL;
WERROR werr = WERR_OK;
+ sbcErr err = SBC_ERR_OK;
char **tmp_share_names = NULL;
if ((num_shares == NULL) || (share_names == NULL)) {
@@ -309,9 +317,9 @@ static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx,
goto done;
}
- werr = smbconf_txt_load_file(ctx);
- if (!W_ERROR_IS_OK(werr)) {
- return werr;
+ err = smbconf_txt_load_file(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
tmp_ctx = talloc_stackframe();
@@ -371,10 +379,10 @@ done:
static bool smbconf_txt_share_exists(struct smbconf_ctx *ctx,
const char *servicename)
{
- WERROR werr;
+ sbcErr err;
- werr = smbconf_txt_load_file(ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_txt_load_file(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
return false;
}
@@ -401,14 +409,15 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
struct smbconf_service **service)
{
WERROR werr;
+ sbcErr err;
uint32_t sidx, count;
bool found;
TALLOC_CTX *tmp_ctx = NULL;
struct smbconf_service *tmp_service = NULL;
- werr = smbconf_txt_load_file(ctx);
- if (!W_ERROR_IS_OK(werr)) {
- return werr;
+ err = smbconf_txt_load_file(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
found = smbconf_find_in_array(servicename,
@@ -489,13 +498,13 @@ static WERROR smbconf_txt_get_parameter(struct smbconf_ctx *ctx,
const char *param,
char **valstr)
{
- WERROR werr;
+ sbcErr err;
bool found;
uint32_t share_index, param_index;
- werr = smbconf_txt_load_file(ctx);
- if (!W_ERROR_IS_OK(werr)) {
- return werr;
+ err = smbconf_txt_load_file(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
found = smbconf_find_in_array(service,
@@ -541,15 +550,16 @@ static WERROR smbconf_txt_get_includes(struct smbconf_ctx *ctx,
char ***includes)
{
WERROR werr;
+ sbcErr err;
bool found;
uint32_t sidx, count;
TALLOC_CTX *tmp_ctx = NULL;
uint32_t tmp_num_includes = 0;
char **tmp_includes = NULL;
- werr = smbconf_txt_load_file(ctx);
- if (!W_ERROR_IS_OK(werr)) {
- return werr;
+ err = smbconf_txt_load_file(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return WERR_GENERAL_FAILURE;
}
found = smbconf_find_in_array(service,
@@ -654,15 +664,15 @@ static struct smbconf_ops smbconf_ops_txt = {
* initialize the smbconf text backend
* the only function that is exported from this module
*/
-WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
+sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx,
struct smbconf_ctx **conf_ctx,
const char *path)
{
- WERROR werr;
+ sbcErr err;
- werr = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_txt);
- if (!W_ERROR_IS_OK(werr)) {
- return werr;
+ err = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_txt);
+ if (!SBC_ERROR_IS_OK(err)) {
+ return err;
}
return smbconf_txt_load_file(*conf_ctx);
diff --git a/lib/smbconf/smbconf_txt.h b/lib/smbconf/smbconf_txt.h
index 688bbc9d48..72d6207521 100644
--- a/lib/smbconf/smbconf_txt.h
+++ b/lib/smbconf/smbconf_txt.h
@@ -26,7 +26,7 @@ struct smbconf_ctx;
* initialization functions for the text/file backend modules
*/
-WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
+sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx,
struct smbconf_ctx **conf_ctx,
const char *path);
diff --git a/lib/smbconf/smbconf_util.c b/lib/smbconf/smbconf_util.c
index b309a3454b..63ce50d668 100644
--- a/lib/smbconf/smbconf_util.c
+++ b/lib/smbconf/smbconf_util.c
@@ -39,36 +39,36 @@ static int smbconf_destroy_ctx(struct smbconf_ctx *ctx)
* After the work with the configuration is completed, smbconf_shutdown()
* should be called.
*/
-WERROR smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *path, struct smbconf_ops *ops)
{
- WERROR werr = WERR_OK;
+ sbcErr err = SBC_ERR_OK;
struct smbconf_ctx *ctx;
if (conf_ctx == NULL) {
- return WERR_INVALID_PARAM;
+ return SBC_ERR_INVALID_PARAM;
}
ctx = talloc_zero(mem_ctx, struct smbconf_ctx);
if (ctx == NULL) {
- return WERR_NOMEM;
+ return SBC_ERR_NOMEM;
}
ctx->ops = ops;
- werr = ctx->ops->init(ctx, path);
- if (!W_ERROR_IS_OK(werr)) {
+ err = ctx->ops->init(ctx, path);
+ if (!SBC_ERROR_IS_OK(err)) {
goto fail;
}
talloc_set_destructor(ctx, smbconf_destroy_ctx);
*conf_ctx = ctx;
- return werr;
+ return err;
fail:
talloc_free(ctx);
- return werr;
+ return err;
}
diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c
index 22c7df69d1..e995bdaf47 100644
--- a/source3/lib/netapi/serverinfo.c
+++ b/source3/lib/netapi/serverinfo.c
@@ -541,6 +541,7 @@ static WERROR NetServerSetInfo_l_1005(struct libnetapi_ctx *ctx,
struct NetServerSetInfo *r)
{
WERROR werr;
+ sbcErr err;
struct smbconf_ctx *conf_ctx;
struct srvsvc_NetSrvInfo1005 *info1005;
@@ -563,8 +564,12 @@ static WERROR NetServerSetInfo_l_1005(struct libnetapi_ctx *ctx,
return WERR_NOT_SUPPORTED;
}
- werr = smbconf_init_reg(ctx, &conf_ctx, NULL);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init_reg(ctx, &conf_ctx, NULL);
+ if (!SBC_ERROR_IS_OK(err)) {
+ libnetapi_set_error_string(ctx,
+ "Could not initialize backend: %s",
+ sbcErrorString(err));
+ werr = WERR_NO_SUCH_SERVICE;
goto done;
}
diff --git a/source3/lib/smbconf/smbconf_init.c b/source3/lib/smbconf/smbconf_init.c
index 36c51de5f0..2587a4fc53 100644
--- a/source3/lib/smbconf/smbconf_init.c
+++ b/source3/lib/smbconf/smbconf_init.c
@@ -34,28 +34,28 @@
* - "registry" or "reg"
* - "txt" or "file"
*/
-WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *source)
{
- WERROR werr;
+ sbcErr err;
char *backend = NULL;
char *path = NULL;
char *sep;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
if (conf_ctx == NULL) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
if ((source == NULL) || (*source == '\0')) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
backend = talloc_strdup(tmp_ctx, source);
if (backend == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -69,16 +69,16 @@ WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
}
if (strequal(backend, "registry") || strequal(backend, "reg")) {
- werr = smbconf_init_reg(mem_ctx, conf_ctx, path);
+ err = smbconf_init_reg(mem_ctx, conf_ctx, path);
} else if (strequal(backend, "file") || strequal(backend, "txt")) {
- werr = smbconf_init_txt(mem_ctx, conf_ctx, path);
+ err = smbconf_init_txt(mem_ctx, conf_ctx, path);
} else if (sep == NULL) {
/*
* If no separator was given in the source, and the string is
* not a known backend, assume file backend and use the source
* string as a path argument.
*/
- werr = smbconf_init_txt(mem_ctx, conf_ctx, backend);
+ err = smbconf_init_txt(mem_ctx, conf_ctx, backend);
} else {
/*
* Separator was specified but this is not a known backend.
@@ -87,10 +87,10 @@ WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
* This may occur with an include directive like this:
* 'include = /path/to/file.%T'
*/
- werr = smbconf_init_txt(mem_ctx, conf_ctx, source);
+ err = smbconf_init_txt(mem_ctx, conf_ctx, source);
}
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
diff --git a/source3/lib/smbconf/smbconf_init.h b/source3/lib/smbconf/smbconf_init.h
index abd62df204..45ea809624 100644
--- a/source3/lib/smbconf/smbconf_init.h
+++ b/source3/lib/smbconf/smbconf_init.h
@@ -26,7 +26,7 @@ struct smbconf_ctx;
* intialization dispatcher function.
* takes source string in the form of "backend:path"
*/
-WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *source);
#endif /* _LIBSMBCONF_INIT_H_ */
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index 67df03cbd2..09b4682de0 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -1156,7 +1156,7 @@ struct smbconf_ops smbconf_ops_reg = {
* initialize the smbconf registry backend
* the only function that is exported from this module
*/
-WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *path)
{
return smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);
diff --git a/source3/lib/smbconf/smbconf_reg.h b/source3/lib/smbconf/smbconf_reg.h
index 7f54b6e32d..2c49057a94 100644
--- a/source3/lib/smbconf/smbconf_reg.h
+++ b/source3/lib/smbconf/smbconf_reg.h
@@ -26,7 +26,7 @@ struct smbconf_ctx;
* initialization functions for the registry backend modules
*/
-WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *path);
diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c
index 80754dd20c..5bde5e1621 100644
--- a/source3/lib/smbconf/testsuite.c
+++ b/source3/lib/smbconf/testsuite.c
@@ -204,6 +204,7 @@ static bool create_conf_file(const char *filename)
static bool torture_smbconf_txt(void)
{
WERROR werr;
+ sbcErr err;
bool ret = true;
const char *filename = "/tmp/smb.conf.smbconf_testsuite";
struct smbconf_ctx *conf_ctx = NULL;
@@ -217,9 +218,9 @@ static bool torture_smbconf_txt(void)
}
printf("TEST: init\n");
- werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename);
- if (!W_ERROR_IS_OK(werr)) {
- printf("FAIL: text backend failed: %s\n", win_errstr(werr));
+ err = smbconf_init_txt(mem_ctx, &conf_ctx, filename);
+ if (!SBC_ERROR_IS_OK(err)) {
+ printf("FAIL: text backend failed: %s\n", sbcErrorString(err));
ret = false;
goto done;
}
@@ -246,6 +247,7 @@ done:
static bool torture_smbconf_reg(void)
{
WERROR werr;
+ sbcErr err;
bool ret = true;
struct smbconf_ctx *conf_ctx = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -253,9 +255,9 @@ static bool torture_smbconf_reg(void)
printf("test: registry backend\n");
printf("TEST: init\n");
- werr = smbconf_init_reg(mem_ctx, &conf_ctx, NULL);
- if (!W_ERROR_IS_OK(werr)) {
- printf("FAIL: init failed: %s\n", win_errstr(werr));
+ err = smbconf_init_reg(mem_ctx, &conf_ctx, NULL);
+ if (!SBC_ERROR_IS_OK(err)) {
+ printf("FAIL: init failed: %s\n", sbcErrorString(err));
ret = false;
goto done;
}
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index b65bac907d..5f7f93e087 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -1456,10 +1456,12 @@ done:
static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
{
WERROR werr;
+ sbcErr err;
struct smbconf_ctx *ctx;
- werr = smbconf_init_reg(r, &ctx, NULL);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init_reg(r, &ctx, NULL);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
goto done;
}
@@ -1502,10 +1504,12 @@ static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
static WERROR do_unjoin_modify_vals_config(struct libnet_UnjoinCtx *r)
{
WERROR werr = WERR_OK;
+ sbcErr err;
struct smbconf_ctx *ctx;
- werr = smbconf_init_reg(r, &ctx, NULL);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init_reg(r, &ctx, NULL);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
goto done;
}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index bf504a41b7..53fd3dad50 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -7208,14 +7208,14 @@ bool service_ok(int iService)
static struct smbconf_ctx *lp_smbconf_ctx(void)
{
- WERROR werr;
+ sbcErr err;
static struct smbconf_ctx *conf_ctx = NULL;
if (conf_ctx == NULL) {
- werr = smbconf_init(NULL, &conf_ctx, "registry:");
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init(NULL, &conf_ctx, "registry:");
+ if (!SBC_ERROR_IS_OK(err)) {
DEBUG(1, ("error initializing registry configuration: "
- "%s\n", win_errstr(werr)));
+ "%s\n", sbcErrorString(err)));
conf_ctx = NULL;
}
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index fd00c008dd..9ed19f1fdb 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -316,6 +316,7 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
TALLOC_CTX *mem_ctx;
struct smbconf_ctx *txt_ctx;
WERROR werr;
+ sbcErr err;
if (c->display_usage)
return net_conf_import_usage(c, argc, argv);
@@ -347,10 +348,11 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_init(mem_ctx, &txt_ctx, conf_source);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init(mem_ctx, &txt_ctx, conf_source);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error loading file '%s': %s\n"), filename,
- win_errstr(werr));
+ sbcErrorString(err));
+ werr = WERR_NO_SUCH_SERVICE;
goto done;
}
@@ -1140,14 +1142,13 @@ static int net_conf_wrap_function(struct net_context *c,
int, const char **),
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct smbconf_ctx *conf_ctx;
int ret = -1;
- werr = smbconf_init(mem_ctx, &conf_ctx, "registry:");
-
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init(mem_ctx, &conf_ctx, "registry:");
+ if (!SBC_ERROR_IS_OK(err)) {
return -1;
}