summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/libnet/libnet_conf.c72
-rw-r--r--source3/utils/net_conf.c88
2 files changed, 82 insertions, 78 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c
index 960ee80dbc..d42e5ad227 100644
--- a/source3/libnet/libnet_conf.c
+++ b/source3/libnet/libnet_conf.c
@@ -148,6 +148,78 @@ done:
return werr;
}
+
+/*
+ * add a value to a key.
+ */
+WERROR libnet_smbconf_reg_setvalue_internal(struct registry_key *key,
+ const char *valname,
+ const char *valstr)
+{
+ struct registry_value val;
+ WERROR werr = WERR_OK;
+ char *subkeyname;
+ const char *canon_valname;
+ const char *canon_valstr;
+
+ if (!lp_canonicalize_parameter_with_value(valname, valstr,
+ &canon_valname,
+ &canon_valstr))
+ {
+ if (canon_valname == NULL) {
+ d_fprintf(stderr, "invalid parameter '%s' given\n",
+ valname);
+ } else {
+ d_fprintf(stderr, "invalid value '%s' given for "
+ "parameter '%s'\n", valstr, valname);
+ }
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ ZERO_STRUCT(val);
+
+ val.type = REG_SZ;
+ val.v.sz.str = CONST_DISCARD(char *, canon_valstr);
+ val.v.sz.len = strlen(canon_valstr) + 1;
+
+ if (registry_smbconf_valname_forbidden(canon_valname)) {
+ d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n",
+ canon_valname);
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ subkeyname = strrchr_m(key->key->name, '\\');
+ if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) {
+ d_fprintf(stderr, "Invalid registry key '%s' given as "
+ "smbconf section.\n", key->key->name);
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+ subkeyname++;
+ if (!strequal(subkeyname, GLOBAL_NAME) &&
+ lp_parameter_is_global(valname))
+ {
+ d_fprintf(stderr, "Global paramter '%s' not allowed in "
+ "service definition ('%s').\n", canon_valname,
+ subkeyname);
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ werr = reg_setvalue(key, canon_valname, &val);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_fprintf(stderr,
+ "Error adding value '%s' to "
+ "key '%s': %s\n",
+ canon_valname, key->key->name, dos_errstr(werr));
+ }
+
+done:
+ return werr;
+}
+
static WERROR do_modify_val_config(struct registry_key *key,
const char *val_name,
const char *val_data)
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 8d0b4b9bbe..2648aa2e81 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -144,77 +144,6 @@ static char *format_value(TALLOC_CTX *mem_ctx, struct registry_value *value)
}
/*
- * add a value to a key.
- */
-static WERROR reg_setvalue_internal(struct registry_key *key,
- const char *valname,
- const char *valstr)
-{
- struct registry_value val;
- WERROR werr = WERR_OK;
- char *subkeyname;
- const char *canon_valname;
- const char *canon_valstr;
-
- if (!lp_canonicalize_parameter_with_value(valname, valstr,
- &canon_valname,
- &canon_valstr))
- {
- if (canon_valname == NULL) {
- d_fprintf(stderr, "invalid parameter '%s' given\n",
- valname);
- } else {
- d_fprintf(stderr, "invalid value '%s' given for "
- "parameter '%s'\n", valstr, valname);
- }
- werr = WERR_INVALID_PARAM;
- goto done;
- }
-
- ZERO_STRUCT(val);
-
- val.type = REG_SZ;
- val.v.sz.str = CONST_DISCARD(char *, canon_valstr);
- val.v.sz.len = strlen(canon_valstr) + 1;
-
- if (registry_smbconf_valname_forbidden(canon_valname)) {
- d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n",
- canon_valname);
- werr = WERR_INVALID_PARAM;
- goto done;
- }
-
- subkeyname = strrchr_m(key->key->name, '\\');
- if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) {
- d_fprintf(stderr, "Invalid registry key '%s' given as "
- "smbconf section.\n", key->key->name);
- werr = WERR_INVALID_PARAM;
- goto done;
- }
- subkeyname++;
- if (!strequal(subkeyname, GLOBAL_NAME) &&
- lp_parameter_is_global(valname))
- {
- d_fprintf(stderr, "Global paramter '%s' not allowed in "
- "service definition ('%s').\n", canon_valname,
- subkeyname);
- werr = WERR_INVALID_PARAM;
- goto done;
- }
-
- werr = reg_setvalue(key, canon_valname, &val);
- if (!W_ERROR_IS_OK(werr)) {
- d_fprintf(stderr,
- "Error adding value '%s' to "
- "key '%s': %s\n",
- canon_valname, key->key->name, dos_errstr(werr));
- }
-
-done:
- return werr;
-}
-
-/*
* delete a subkey of KEY_SMBCONF
*/
static WERROR reg_delkey_internal(TALLOC_CTX *ctx, const char *keyname)
@@ -435,8 +364,8 @@ static int import_process_service(TALLOC_CTX *ctx,
if (opt_testmode) {
d_printf("\t%s = %s\n", parm->label, valstr);
} else {
- werr = reg_setvalue_internal(key, parm->label,
- valstr);
+ werr = libnet_smbconf_reg_setvalue_internal(key,
+ parm->label, valstr);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -854,21 +783,24 @@ int net_conf_addshare(int argc, const char **argv)
/* add config params as values */
- werr = reg_setvalue_internal(newkey, "path", path);
+ werr = libnet_smbconf_reg_setvalue_internal(newkey, "path", path);
if (!W_ERROR_IS_OK(werr))
goto done;
if (comment != NULL) {
- werr = reg_setvalue_internal(newkey, "comment", comment);
+ werr = libnet_smbconf_reg_setvalue_internal(newkey, "comment",
+ comment);
if (!W_ERROR_IS_OK(werr))
goto done;
}
- werr = reg_setvalue_internal(newkey, "guest ok", guest_ok);
+ werr = libnet_smbconf_reg_setvalue_internal(newkey, "guest ok",
+ guest_ok);
if (!W_ERROR_IS_OK(werr))
goto done;
- werr = reg_setvalue_internal(newkey, "writeable", writeable);
+ werr = libnet_smbconf_reg_setvalue_internal(newkey, "writeable",
+ writeable);
if (!W_ERROR_IS_OK(werr))
goto done;
@@ -927,7 +859,7 @@ static int net_conf_setparm(int argc, const char **argv)
goto done;
}
- werr = reg_setvalue_internal(key, param, value_str);
+ werr = libnet_smbconf_reg_setvalue_internal(key, param, value_str);
if (!W_ERROR_IS_OK(werr)) {
d_fprintf(stderr, "Error setting value '%s': %s\n",
param, dos_errstr(werr));