diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/netapi/serverinfo.c | 9 | ||||
-rw-r--r-- | source3/lib/smbconf/smbconf_reg.c | 26 | ||||
-rw-r--r-- | source3/libnet/libnet_join.c | 54 | ||||
-rw-r--r-- | source3/utils/net_conf.c | 42 |
4 files changed, 81 insertions, 50 deletions
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; } |