summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2011-04-11 15:14:52 +0200
committerMichael Adam <obnox@samba.org>2011-05-10 19:13:22 +0200
commitd911bafea695dc36d7952bd265dfe15a3e04ac7b (patch)
treecd30e1c56152f40de4340ab4e893970859d07ad4
parent9f9711490ae743493722c997e316a31600ef02d6 (diff)
downloadsamba-d911bafea695dc36d7952bd265dfe15a3e04ac7b.tar.gz
samba-d911bafea695dc36d7952bd265dfe15a3e04ac7b.tar.bz2
samba-d911bafea695dc36d7952bd265dfe15a3e04ac7b.zip
libsmbconf: Convert smbconf_set_includes() to sbcErr.
Signed-off-by: Michael Adam <obnox@samba.org>
-rw-r--r--lib/smbconf/smbconf.c13
-rw-r--r--lib/smbconf/smbconf.h4
-rw-r--r--lib/smbconf/smbconf_private.h2
-rw-r--r--lib/smbconf/smbconf_txt.c4
-rw-r--r--source3/lib/smbconf/smbconf_reg.c28
-rw-r--r--source3/lib/smbconf/testsuite.c13
-rw-r--r--source3/utils/net_conf.c17
7 files changed, 45 insertions, 36 deletions
diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
index f23a802e7c..c3ba106d1c 100644
--- a/lib/smbconf/smbconf.c
+++ b/lib/smbconf/smbconf.c
@@ -380,28 +380,27 @@ sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx,
return err;
}
-WERROR smbconf_set_includes(struct smbconf_ctx *ctx,
+sbcErr smbconf_set_includes(struct smbconf_ctx *ctx,
const char *service,
uint32_t num_includes, const char **includes)
{
return ctx->ops->set_includes(ctx, service, num_includes, includes);
}
-WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
+sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx,
uint32_t num_includes,
const char **includes)
{
- WERROR werr;
sbcErr err;
err = smbconf_global_check(ctx);
if (!SBC_ERROR_IS_OK(err)) {
- return WERR_GENERAL_FAILURE;
+ return err;
}
- werr = smbconf_set_includes(ctx, GLOBAL_NAME,
- num_includes, includes);
+ err = smbconf_set_includes(ctx, GLOBAL_NAME,
+ num_includes, includes);
- return werr;
+ return err;
}
diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h
index 672c256480..8921af4108 100644
--- a/lib/smbconf/smbconf.h
+++ b/lib/smbconf/smbconf.h
@@ -118,10 +118,10 @@ sbcErr smbconf_get_includes(struct smbconf_ctx *ctx,
sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
uint32_t *num_includes, char ***includes);
-WERROR smbconf_set_includes(struct smbconf_ctx *ctx,
+sbcErr smbconf_set_includes(struct smbconf_ctx *ctx,
const char *service,
uint32_t num_includes, const char **includes);
-WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
+sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx,
uint32_t num_includes,
const char **includes);
WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service);
diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h
index 8fb9c84921..1cb8b88d13 100644
--- a/lib/smbconf/smbconf_private.h
+++ b/lib/smbconf/smbconf_private.h
@@ -63,7 +63,7 @@ struct smbconf_ops {
TALLOC_CTX *mem_ctx,
const char *service,
uint32_t *num_includes, char ***includes);
- WERROR (*set_includes)(struct smbconf_ctx *ctx,
+ sbcErr (*set_includes)(struct smbconf_ctx *ctx,
const char *service,
uint32_t num_includes, const char **includes);
WERROR (*delete_includes)(struct smbconf_ctx *ctx,
diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c
index 7983d925e6..5502167593 100644
--- a/lib/smbconf/smbconf_txt.c
+++ b/lib/smbconf/smbconf_txt.c
@@ -594,12 +594,12 @@ done:
return err;
}
-static WERROR smbconf_txt_set_includes(struct smbconf_ctx *ctx,
+static sbcErr smbconf_txt_set_includes(struct smbconf_ctx *ctx,
const char *service,
uint32_t num_includes,
const char **includes)
{
- return WERR_NOT_SUPPORTED;
+ return SBC_ERR_NOT_SUPPORTED;
}
static WERROR smbconf_txt_delete_includes(struct smbconf_ctx *ctx,
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index deca6ec68a..124140b178 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -236,31 +236,32 @@ done:
return err;
}
-static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
+static sbcErr smbconf_reg_set_multi_sz_value(struct registry_key *key,
const char *valname,
const uint32_t num_strings,
const char **strings)
{
WERROR werr;
+ sbcErr err = SBC_ERR_OK;
struct registry_value *value;
uint32_t count;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
const char **array;
if (strings == NULL) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
array = talloc_zero_array(tmp_ctx, const char *, num_strings + 1);
if (array == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);
if (value == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -269,13 +270,13 @@ static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
for (count = 0; count < num_strings; count++) {
array[count] = talloc_strdup(value, strings[count]);
if (array[count] == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
}
if (!push_reg_multi_sz(value, &value->data, array)) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -283,11 +284,12 @@ static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
if (!W_ERROR_IS_OK(werr)) {
DEBUG(5, ("Error adding value '%s' to key '%s': %s\n",
valname, key->key->name, win_errstr(werr)));
+ err = SBC_ERR_ACCESS_DENIED;
}
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
/**
@@ -1098,7 +1100,7 @@ done:
return err;
}
-static WERROR smbconf_reg_set_includes(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_set_includes(struct smbconf_ctx *ctx,
const char *service,
uint32_t num_includes,
const char **includes)
@@ -1111,23 +1113,27 @@ static WERROR smbconf_reg_set_includes(struct smbconf_ctx *ctx,
err = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
REG_KEY_ALL, &key);
if (!SBC_ERROR_IS_OK(err)) {
- werr = WERR_NOMEM;
goto done;
}
if (num_includes == 0) {
if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
+ err = SBC_ERR_OK;
goto done;
}
werr = reg_deletevalue(key, INCLUDES_VALNAME);
+ if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_ACCESS_DENIED;
+ goto done;
+ }
} else {
- werr = smbconf_reg_set_multi_sz_value(key, INCLUDES_VALNAME,
+ err = smbconf_reg_set_multi_sz_value(key, INCLUDES_VALNAME,
num_includes, includes);
}
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
static WERROR smbconf_reg_delete_includes(struct smbconf_ctx *ctx,
diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c
index 8a7e2d4c25..593839d88f 100644
--- a/source3/lib/smbconf/testsuite.c
+++ b/source3/lib/smbconf/testsuite.c
@@ -68,7 +68,6 @@ done:
static bool test_set_get_includes(struct smbconf_ctx *ctx)
{
- WERROR werr;
sbcErr err;
uint32_t count;
bool ret = false;
@@ -83,10 +82,10 @@ static bool test_set_get_includes(struct smbconf_ctx *ctx)
printf("TEST: set_get_includes\n");
- werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
+ if (!SBC_ERROR_IS_OK(err)) {
printf("FAIL: get_set_includes (setting includes) - %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -139,10 +138,10 @@ static bool test_delete_includes(struct smbconf_ctx *ctx)
printf("TEST: delete_includes\n");
- werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
+ if (!SBC_ERROR_IS_OK(err)) {
printf("FAIL: delete_includes (setting includes) - %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index d3c39fdb74..255f14c920 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -246,9 +246,14 @@ static WERROR import_process_service(struct net_context *c,
}
}
- werr = smbconf_set_includes(conf_ctx, service->name, num_includes,
- (const char **)includes);
+ err = smbconf_set_includes(conf_ctx, service->name, num_includes,
+ (const char **)includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
+ werr = WERR_OK;
done:
TALLOC_FREE(mem_ctx);
return werr;
@@ -1055,7 +1060,7 @@ static int net_conf_setincludes(struct net_context *c,
struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
char *service;
uint32_t num_includes;
const char **includes;
@@ -1080,9 +1085,9 @@ static int net_conf_setincludes(struct net_context *c,
includes = argv + 1;
}
- werr = smbconf_set_includes(conf_ctx, service, num_includes, includes);
- if (!W_ERROR_IS_OK(werr)) {
- d_printf(_("error setting includes: %s\n"), win_errstr(werr));
+ err = smbconf_set_includes(conf_ctx, service, num_includes, includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ d_printf(_("error setting includes: %s\n"), sbcErrorString(err));
goto done;
}