summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-08-16 15:32:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:29:52 -0500
commit53f5c4adfbf12fbf6f25eab3260d22a2d7c3efbe (patch)
treed80b531fdfb42cdc9c69a8aac5f8132e48d0dca7
parentbf374d3d3d12ed352ba8add9b5633855f2851c01 (diff)
downloadsamba-53f5c4adfbf12fbf6f25eab3260d22a2d7c3efbe.tar.gz
samba-53f5c4adfbf12fbf6f25eab3260d22a2d7c3efbe.tar.bz2
samba-53f5c4adfbf12fbf6f25eab3260d22a2d7c3efbe.zip
r24496: Add initial synonym handling to "net conf":
When storing parameters in the smbconf portion of the registry, up to now, synonyms could be misused to store a parameter twice. Now this is prevented by canonicalizing the paramter name first. Also, the value for a boolean parameter checked for validity before storing the bool in registry. (The canonicalization should finally go into the registry smbconf code to also prevent e.g. "regedit" or "net rpc registry" from storing synonyms. - This is in the making.) Michael (This used to be commit 95447dde860f54d835b3fe90d95fe60231788d1b)
-rw-r--r--source3/utils/net_conf.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index bcb116a0c8..f7385586fb 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -151,12 +151,10 @@ static WERROR reg_setvalue_internal(struct registry_key *key,
struct registry_value val;
WERROR werr = WERR_OK;
char *subkeyname;
-
- ZERO_STRUCT(val);
-
- val.type = REG_SZ;
- val.v.sz.str = CONST_DISCARD(char *, valstr);
- val.v.sz.len = strlen(valstr) + 1;
+ const char *canon_valname;
+ const char *canon_valstr;
+ BOOL canon_inverse;
+ struct parm_struct *parm;
if (!lp_parameter_is_valid(valname)) {
d_fprintf(stderr, "Invalid parameter '%s' given.\n", valname);
@@ -164,9 +162,45 @@ static WERROR reg_setvalue_internal(struct registry_key *key,
goto done;
}
- if (registry_smbconf_valname_forbidden(valname)) {
+ if (!lp_canonicalize_parameter(valname, &canon_valname, &canon_inverse))
+ {
+ d_fprintf(stderr, "ERROR: could not canonicalize parameter "
+ "'%s' after successful validation: this should not "
+ "happen!\n", valname);
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+ if (canon_inverse) {
+ if (!lp_invert_boolean(valstr, &canon_valstr)) {
+ d_fprintf(stderr, "invalid value '%s' given for "
+ "parameter '%s'\n", valstr, canon_valname);
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+ } else {
+ parm = lp_get_parameter(canon_valname);
+ if (parm->type == P_BOOL) {
+ if (!lp_canonicalize_boolean(valstr, &canon_valstr)) {
+ d_fprintf(stderr, "invalied value '%s' given "
+ "for parameter '%s'\n", valstr,
+ canon_valname);
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+ } else {
+ canon_valstr = valstr;
+ }
+ }
+
+ 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",
- valname);
+ canon_valname);
werr = WERR_INVALID_PARAM;
goto done;
}
@@ -183,18 +217,18 @@ static WERROR reg_setvalue_internal(struct registry_key *key,
lp_parameter_is_global(valname))
{
d_fprintf(stderr, "Global paramter '%s' not allowed in "
- "service definition ('%s').\n", valname,
+ "service definition ('%s').\n", canon_valname,
subkeyname);
werr = WERR_INVALID_PARAM;
goto done;
}
- werr = reg_setvalue(key, valname, &val);
+ 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",
- valname, key->key->name, dos_errstr(werr));
+ canon_valname, key->key->name, dos_errstr(werr));
}
done: