summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2011-04-11 13:23:26 +0200
committerMichael Adam <obnox@samba.org>2011-05-10 19:13:21 +0200
commitddc28a683fcf036a279a0d3d7b23504364316fa6 (patch)
tree9b7f70351c2a22c1102092b54291e089ce725c28
parentfbd7626656d8d76f371e431005fbfa1228ba2029 (diff)
downloadsamba-ddc28a683fcf036a279a0d3d7b23504364316fa6.tar.gz
samba-ddc28a683fcf036a279a0d3d7b23504364316fa6.tar.xz
samba-ddc28a683fcf036a279a0d3d7b23504364316fa6.zip
libsmbconf: Convert smbconf_set_parameter() to sbcErr.
Signed-off-by: Michael Adam <obnox@samba.org>
-rw-r--r--lib/smbconf/smbconf.c11
-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/netapi/serverinfo.c9
-rw-r--r--source3/lib/smbconf/smbconf_reg.c26
-rw-r--r--source3/libnet/libnet_join.c54
-rw-r--r--source3/utils/net_conf.c42
8 files changed, 91 insertions, 61 deletions
diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
index c02899c0d5..786f4d32d1 100644
--- a/lib/smbconf/smbconf.c
+++ b/lib/smbconf/smbconf.c
@@ -260,7 +260,7 @@ sbcErr smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)
/**
* set a configuration parameter to the value provided.
*/
-WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
+sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx,
const char *service,
const char *param,
const char *valstr)
@@ -274,19 +274,18 @@ WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
*
* This also creates [global] when it does not exist.
*/
-WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
+sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx,
const char *param, const char *val)
{
- WERROR werr = WERR_OK;
sbcErr err;
err = smbconf_global_check(ctx);
if (!SBC_ERROR_IS_OK(err)) {
- return WERR_GENERAL_FAILURE;
+ return err;
}
- werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
+ err = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
- return werr;
+ return err;
}
/**
diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h
index af021f95d7..1471ceca1d 100644
--- a/lib/smbconf/smbconf.h
+++ b/lib/smbconf/smbconf.h
@@ -91,11 +91,11 @@ sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
struct smbconf_service **service);
sbcErr smbconf_delete_share(struct smbconf_ctx *ctx,
const char *servicename);
-WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
+sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx,
const char *service,
const char *param,
const char *valstr);
-WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
+sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx,
const char *param, const char *val);
WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h
index 0fa47e87a7..b11a1420ae 100644
--- a/lib/smbconf/smbconf_private.h
+++ b/lib/smbconf/smbconf_private.h
@@ -48,7 +48,7 @@ struct smbconf_ops {
struct smbconf_service **service);
sbcErr (*delete_share)(struct smbconf_ctx *ctx,
const char *servicename);
- WERROR (*set_parameter)(struct smbconf_ctx *ctx,
+ sbcErr (*set_parameter)(struct smbconf_ctx *ctx,
const char *service,
const char *param,
const char *valstr);
diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c
index 1017b5a1c8..0f77254d38 100644
--- a/lib/smbconf/smbconf_txt.c
+++ b/lib/smbconf/smbconf_txt.c
@@ -471,12 +471,12 @@ static sbcErr smbconf_txt_delete_share(struct smbconf_ctx *ctx,
/**
* set a configuration parameter to the value provided.
*/
-static WERROR smbconf_txt_set_parameter(struct smbconf_ctx *ctx,
+static sbcErr smbconf_txt_set_parameter(struct smbconf_ctx *ctx,
const char *service,
const char *param,
const char *valstr)
{
- return WERR_NOT_SUPPORTED;
+ return SBC_ERR_NOT_SUPPORTED;
}
/**
diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c
index e995bdaf47..f321648f24 100644
--- a/source3/lib/netapi/serverinfo.c
+++ b/source3/lib/netapi/serverinfo.c
@@ -573,8 +573,15 @@ static WERROR NetServerSetInfo_l_1005(struct libnetapi_ctx *ctx,
goto done;
}
- werr = smbconf_set_global_parameter(conf_ctx, "server string",
+ err = smbconf_set_global_parameter(conf_ctx, "server string",
info1005->comment);
+ if (!SBC_ERROR_IS_OK(err)) {
+ libnetapi_set_error_string(ctx,
+ "Could not set global parameter: %s",
+ sbcErrorString(err));
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
done:
smbconf_shutdown(conf_ctx);
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index e27a871a13..f7faf51e7d 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -163,12 +163,13 @@ static sbcErr smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
/**
* add a value to a key.
*/
-static WERROR smbconf_reg_set_value(struct registry_key *key,
+static sbcErr smbconf_reg_set_value(struct registry_key *key,
const char *valname,
const char *valstr)
{
struct registry_value val;
WERROR werr = WERR_OK;
+ sbcErr err;
char *subkeyname;
const char *canon_valname;
const char *canon_valstr;
@@ -184,14 +185,14 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
DEBUG(5, ("invalid value '%s' given for "
"parameter '%s'\n", valstr, valname));
}
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
if (smbconf_reg_valname_forbidden(canon_valname)) {
DEBUG(5, ("Parameter '%s' not allowed in registry.\n",
canon_valname));
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
@@ -199,7 +200,7 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) {
DEBUG(5, ("Invalid registry key '%s' given as "
"smbconf section.\n", key->key->name));
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
subkeyname++;
@@ -209,7 +210,7 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
DEBUG(5, ("Global parameter '%s' not allowed in "
"service definition ('%s').\n", canon_valname,
subkeyname));
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
@@ -217,7 +218,7 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
val.type = REG_SZ;
if (!push_reg_sz(talloc_tos(), &val.data, canon_valstr)) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -226,10 +227,13 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
DEBUG(5, ("Error adding value '%s' to "
"key '%s': %s\n",
canon_valname, key->key->name, win_errstr(werr)));
+ err = SBC_ERR_NOMEM;
+ goto done;
}
+ err = SBC_ERR_OK;
done:
- return werr;
+ return err;
}
static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
@@ -960,12 +964,11 @@ static sbcErr smbconf_reg_delete_share(struct smbconf_ctx *ctx,
/**
* set a configuration parameter to the value provided.
*/
-static WERROR smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
const char *service,
const char *param,
const char *valstr)
{
- WERROR werr;
sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -973,15 +976,14 @@ static WERROR smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
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;
}
- werr = smbconf_reg_set_value(key, param, valstr);
+ err = smbconf_reg_set_value(key, param, valstr);
done:
talloc_free(mem_ctx);
- return werr;
+ return err;
}
/**
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 5f7f93e087..ef0d5d0850 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -1467,30 +1467,49 @@ static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE)) {
- werr = smbconf_set_global_parameter(ctx, "security", "user");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "security", "user");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
- werr = smbconf_set_global_parameter(ctx, "workgroup",
- r->in.domain_name);
+ err = smbconf_set_global_parameter(ctx, "workgroup",
+ r->in.domain_name);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
smbconf_delete_global_parameter(ctx, "realm");
goto done;
}
- werr = smbconf_set_global_parameter(ctx, "security", "domain");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "security", "domain");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
- werr = smbconf_set_global_parameter(ctx, "workgroup",
- r->out.netbios_domain_name);
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "workgroup",
+ r->out.netbios_domain_name);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
if (r->out.domain_is_ad) {
- werr = smbconf_set_global_parameter(ctx, "security", "ads");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "security", "ads");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
- werr = smbconf_set_global_parameter(ctx, "realm",
- r->out.dns_domain_name);
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "realm",
+ r->out.dns_domain_name);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
}
done:
@@ -1515,8 +1534,11 @@ static WERROR do_unjoin_modify_vals_config(struct libnet_UnjoinCtx *r)
if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
- werr = smbconf_set_global_parameter(ctx, "security", "user");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "security", "user");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
werr = smbconf_delete_global_parameter(ctx, "workgroup");
W_ERROR_NOT_OK_GOTO_DONE(werr);
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 7e166e8e37..4be91e35a8 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -231,15 +231,16 @@ static WERROR import_process_service(struct net_context *c,
}
num_includes++;
} else {
- werr = smbconf_set_parameter(conf_ctx,
+ err = smbconf_set_parameter(conf_ctx,
service->name,
service->param_names[idx],
service->param_values[idx]);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr,
_("Error in section [%s], parameter \"%s\": %s\n"),
service->name, service->param_names[idx],
- win_errstr(werr));
+ sbcErrorString(err));
+ werr = WERR_NOMEM;
goto done;
}
}
@@ -729,35 +730,35 @@ static int net_conf_addshare(struct net_context *c,
* fill the share with parameters
*/
- werr = smbconf_set_parameter(conf_ctx, sharename, "path", path);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "path", path);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "path", win_errstr(werr));
+ "path", sbcErrorString(err));
goto cancel;
}
if (comment != NULL) {
- werr = smbconf_set_parameter(conf_ctx, sharename, "comment",
- comment);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "comment",
+ comment);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "comment", win_errstr(werr));
+ "comment", sbcErrorString(err));
goto cancel;
}
}
- werr = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "'guest ok'", win_errstr(werr));
+ "'guest ok'", sbcErrorString(err));
goto cancel;
}
- werr = smbconf_set_parameter(conf_ctx, sharename, "writeable",
- writeable);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "writeable",
+ writeable);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "writeable", win_errstr(werr));
+ "writeable", sbcErrorString(err));
goto cancel;
}
@@ -868,11 +869,10 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
}
}
- werr = smbconf_set_parameter(conf_ctx, service, param, value_str);
-
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, service, param, value_str);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting value '%s': %s\n"),
- param, win_errstr(werr));
+ param, sbcErrorString(err));
goto cancel;
}