summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2011-04-08 17:20:35 +0200
committerMichael Adam <obnox@samba.org>2011-05-10 19:13:21 +0200
commit7f355e05f9ca41f9ba2bc7c9f14046a283ebd1d1 (patch)
treef7710cbcb4ee444daf7be9d5a27d2f7b8e69306a
parent7af2876e4526d348a1e601f2d14776e08d4668cb (diff)
downloadsamba-7f355e05f9ca41f9ba2bc7c9f14046a283ebd1d1.tar.gz
samba-7f355e05f9ca41f9ba2bc7c9f14046a283ebd1d1.tar.bz2
samba-7f355e05f9ca41f9ba2bc7c9f14046a283ebd1d1.zip
libsmbconf: Convert smbconf_get_share() to sbcErr.
Signed-off-by: Michael Adam <obnox@samba.org>
-rw-r--r--lib/smbconf/smbconf.c11
-rw-r--r--lib/smbconf/smbconf.h2
-rw-r--r--lib/smbconf/smbconf_private.h2
-rw-r--r--lib/smbconf/smbconf_txt.c15
-rw-r--r--source3/lib/smbconf/smbconf_reg.c129
-rw-r--r--source3/param/loadparm.c6
-rw-r--r--source3/utils/net_conf.c16
7 files changed, 98 insertions, 83 deletions
diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
index 68f7dfc902..e374956ca3 100644
--- a/lib/smbconf/smbconf.c
+++ b/lib/smbconf/smbconf.c
@@ -177,10 +177,11 @@ WERROR smbconf_get_config(struct smbconf_ctx *ctx,
}
for (count = 0; count < tmp_num_shares; count++) {
- werr = smbconf_get_share(ctx, tmp_services,
- tmp_share_names[count],
- &tmp_services[count]);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(ctx, tmp_services,
+ tmp_share_names[count],
+ &tmp_services[count]);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_GENERAL_FAILURE;
goto done;
}
}
@@ -236,7 +237,7 @@ sbcErr smbconf_create_share(struct smbconf_ctx *ctx,
/**
* get a definition of a share (service) from configuration.
*/
-WERROR smbconf_get_share(struct smbconf_ctx *ctx,
+sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
struct smbconf_service **service)
diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h
index c1a82b5cf8..93f916f0e4 100644
--- a/lib/smbconf/smbconf.h
+++ b/lib/smbconf/smbconf.h
@@ -85,7 +85,7 @@ sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx,
char ***share_names);
bool smbconf_share_exists(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,
+sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
struct smbconf_service **service);
diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h
index 222497d031..d1af40bf7c 100644
--- a/lib/smbconf/smbconf_private.h
+++ b/lib/smbconf/smbconf_private.h
@@ -42,7 +42,7 @@ struct smbconf_ops {
char ***share_names);
bool (*share_exists)(struct smbconf_ctx *ctx, const char *service);
sbcErr (*create_share)(struct smbconf_ctx *ctx, const char *service);
- WERROR (*get_share)(struct smbconf_ctx *ctx,
+ sbcErr (*get_share)(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
struct smbconf_service **service);
diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c
index 1be27e6bbd..e44abb154d 100644
--- a/lib/smbconf/smbconf_txt.c
+++ b/lib/smbconf/smbconf_txt.c
@@ -394,12 +394,11 @@ static sbcErr smbconf_txt_create_share(struct smbconf_ctx *ctx,
/**
* get a definition of a share (service) from configuration.
*/
-static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_txt_get_share(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
struct smbconf_service **service)
{
- WERROR werr;
sbcErr err;
uint32_t sidx, count;
bool found;
@@ -408,7 +407,7 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
err = smbconf_txt_load_file(ctx);
if (!SBC_ERROR_IS_OK(err)) {
- return WERR_GENERAL_FAILURE;
+ return err;
}
found = smbconf_find_in_array(servicename,
@@ -416,21 +415,21 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
pd(ctx)->cache->num_shares,
&sidx);
if (!found) {
- return WERR_NO_SUCH_SERVICE;
+ return SBC_ERR_NO_SUCH_SERVICE;
}
tmp_ctx = talloc_stackframe();
tmp_service = talloc_zero(tmp_ctx, struct smbconf_service);
if (tmp_service == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
if (servicename != NULL) {
tmp_service->name = talloc_strdup(tmp_service, servicename);
if (tmp_service->name == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
}
@@ -441,7 +440,6 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
count,
pd(ctx)->cache->param_names[sidx][count]);
if (!SBC_ERROR_IS_OK(err)) {
- werr = WERR_NOMEM;
goto done;
}
err = smbconf_add_string_to_array(tmp_service,
@@ -449,7 +447,6 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
count,
pd(ctx)->cache->param_values[sidx][count]);
if (!SBC_ERROR_IS_OK(err)) {
- werr = WERR_NOMEM;
goto done;
}
}
@@ -459,7 +456,7 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
/**
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index 78a3145db5..2425180bd5 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -83,7 +83,7 @@ static bool smbconf_reg_valname_valid(const char *valname)
/**
* Open a subkey of the base key (i.e a service)
*/
-static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
+static sbcErr smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
struct smbconf_ctx *ctx,
const char *servicename,
uint32 desired_access,
@@ -93,16 +93,18 @@ static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
if (servicename == NULL) {
*key = rpd(ctx)->base_key;
- return WERR_OK;
+ return SBC_ERR_OK;
}
werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
desired_access, key);
-
if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
- werr = WERR_NO_SUCH_SERVICE;
+ return SBC_ERR_NO_SUCH_SERVICE;
+ }
+ if (!W_ERROR_IS_OK(werr)) {
+ return SBC_ERR_NOMEM;
}
- return werr;
+ return SBC_ERR_OK;
}
/**
@@ -344,7 +346,7 @@ static char *smbconf_format_registry_value(TALLOC_CTX *mem_ctx,
return result;
}
-static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
+static sbcErr smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
struct registry_key *key,
uint32_t *num_includes,
char ***includes)
@@ -361,22 +363,24 @@ static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
/* no includes */
*num_includes = 0;
*includes = NULL;
- werr = WERR_OK;
+ err = SBC_ERR_OK;
goto done;
}
werr = reg_queryvalue(tmp_ctx, key, INCLUDES_VALNAME, &value);
if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_ACCESS_DENIED;
goto done;
}
if (value->type != REG_MULTI_SZ) {
/* wrong type -- ignore */
+ err = SBC_ERR_OK;
goto done;
}
if (!pull_reg_multi_sz(tmp_ctx, &value->data, &array)) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -394,7 +398,7 @@ static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
if (count > 0) {
*includes = talloc_move(mem_ctx, &tmp_includes);
if (*includes == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
*num_includes = count;
@@ -405,14 +409,14 @@ static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
/**
* Get the values of a key as a list of value names
* and a list of value strings (ordered)
*/
-static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
+static sbcErr smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
struct registry_key *key,
uint32_t *num_values,
char ***value_names,
@@ -433,7 +437,7 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
if ((num_values == NULL) || (value_names == NULL) ||
(value_strings == NULL))
{
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
@@ -454,7 +458,6 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
&tmp_valnames,
tmp_num_values, valname);
if (!SBC_ERROR_IS_OK(err)) {
- werr = WERR_NOMEM;
goto done;
}
@@ -462,26 +465,26 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
err = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
tmp_num_values, valstring);
if (!SBC_ERROR_IS_OK(err)) {
- werr = WERR_NOMEM;
goto done;
}
tmp_num_values++;
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ err = SBC_ERR_NOMEM;
goto done;
}
/* now add the includes at the end */
- werr = smbconf_reg_get_includes_internal(tmp_ctx, key, &num_includes,
+ err = smbconf_reg_get_includes_internal(tmp_ctx, key, &num_includes,
&includes);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
+
for (count = 0; count < num_includes; count++) {
err = smbconf_add_string_to_array(tmp_ctx, &tmp_valnames,
tmp_num_values, "include");
if (!SBC_ERROR_IS_OK(err)) {
- werr = WERR_NOMEM;
goto done;
}
@@ -489,7 +492,6 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
tmp_num_values,
includes[count]);
if (!SBC_ERROR_IS_OK(err)) {
- werr = WERR_NOMEM;
goto done;
}
@@ -507,7 +509,7 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
static bool smbconf_reg_key_has_values(struct registry_key *key)
@@ -849,13 +851,13 @@ static bool smbconf_reg_share_exists(struct smbconf_ctx *ctx,
const char *servicename)
{
bool ret = false;
- WERROR werr = WERR_OK;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct registry_key *key = NULL;
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, servicename,
- REG_KEY_READ, &key);
- if (W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(mem_ctx, ctx, servicename,
+ REG_KEY_READ, &key);
+ if (SBC_ERROR_IS_OK(err)) {
ret = true;
}
@@ -886,48 +888,47 @@ static sbcErr smbconf_reg_create_share(struct smbconf_ctx *ctx,
/**
* get a definition of a share (service) from configuration.
*/
-static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_get_share(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
struct smbconf_service **service)
{
- WERROR werr = WERR_OK;
+ sbcErr err;
struct registry_key *key = NULL;
struct smbconf_service *tmp_service = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
- REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
+ REG_KEY_READ, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
tmp_service = TALLOC_ZERO_P(tmp_ctx, struct smbconf_service);
if (tmp_service == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
if (servicename != NULL) {
tmp_service->name = talloc_strdup(tmp_service, servicename);
if (tmp_service->name == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
}
- werr = smbconf_reg_get_values(tmp_service, key,
- &(tmp_service->num_params),
- &(tmp_service->param_names),
- &(tmp_service->param_values));
-
- if (W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_get_values(tmp_service, key,
+ &(tmp_service->num_params),
+ &(tmp_service->param_names),
+ &(tmp_service->param_values));
+ if (SBC_ERROR_IS_OK(err)) {
*service = talloc_move(mem_ctx, &tmp_service);
}
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
/**
@@ -958,12 +959,14 @@ static WERROR smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
const char *valstr)
{
WERROR werr;
+ sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
- REG_KEY_WRITE, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_WRITE, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NOMEM;
goto done;
}
@@ -984,12 +987,14 @@ static WERROR smbconf_reg_get_parameter(struct smbconf_ctx *ctx,
char **valstr)
{
WERROR werr = WERR_OK;
+ sbcErr err;
struct registry_key *key = NULL;
struct registry_value *value = NULL;
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
- REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_READ, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NOMEM;
goto done;
}
@@ -1029,11 +1034,13 @@ static WERROR smbconf_reg_delete_parameter(struct smbconf_ctx *ctx,
{
struct registry_key *key = NULL;
WERROR werr = WERR_OK;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
- REG_KEY_ALL, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_ALL, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NOMEM;
goto done;
}
@@ -1061,17 +1068,23 @@ static WERROR smbconf_reg_get_includes(struct smbconf_ctx *ctx,
char ***includes)
{
WERROR werr;
+ sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
- REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
+ REG_KEY_READ, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NOMEM;
goto done;
}
- werr = smbconf_reg_get_includes_internal(mem_ctx, key, num_includes,
+ err = smbconf_reg_get_includes_internal(mem_ctx, key, num_includes,
includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
done:
talloc_free(tmp_ctx);
@@ -1084,12 +1097,14 @@ static WERROR smbconf_reg_set_includes(struct smbconf_ctx *ctx,
const char **includes)
{
WERROR werr = WERR_OK;
+ sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
- REG_KEY_ALL, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ 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;
}
@@ -1112,12 +1127,14 @@ static WERROR smbconf_reg_delete_includes(struct smbconf_ctx *ctx,
const char *service)
{
WERROR werr = WERR_OK;
+ sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
- REG_KEY_ALL, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ 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;
}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 53fd3dad50..d9608babc8 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -7255,7 +7255,7 @@ static bool process_smbconf_service(struct smbconf_service *service)
*/
bool process_registry_service(const char *service_name)
{
- WERROR werr;
+ sbcErr err;
struct smbconf_service *service = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
@@ -7276,8 +7276,8 @@ bool process_registry_service(const char *service_name)
goto done;
}
- werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 3b6005a2b9..d4f91c691a 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -366,10 +366,10 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
if (servicename != NULL) {
struct smbconf_service *service = NULL;
- werr = smbconf_get_share(txt_ctx, mem_ctx,
- servicename,
- &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(txt_ctx, mem_ctx,
+ servicename,
+ &service);
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
@@ -528,7 +528,7 @@ static int net_conf_showshare(struct net_context *c,
const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
const char *sharename = NULL;
TALLOC_CTX *mem_ctx;
uint32_t count;
@@ -547,10 +547,10 @@ static int net_conf_showshare(struct net_context *c,
goto done;
}
- werr = smbconf_get_share(conf_ctx, mem_ctx, sharename, &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(conf_ctx, mem_ctx, sharename, &service);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error getting share parameters: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}