1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

libsmbconf:registry: reorganize the validity check and canonicalization of the input in "setparm"

- first check that the name is an smbconf parameter
- then check that the parameter is allowed in the registry config
- then check that a global parameter is not to be set in a service section
- then canonicalize the parameter and value name, thereby checking that the
  value has valid format

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Michael Adam 2013-09-22 08:47:14 +02:00
parent b7db29eb2a
commit 76a008cd18

View File

@ -174,24 +174,15 @@ static sbcErr smbconf_reg_set_value(struct registry_key *key,
const char *canon_valname;
const char *canon_valstr;
if (!lp_canonicalize_parameter_with_value(valname, valstr,
&canon_valname,
&canon_valstr))
{
if (canon_valname == NULL) {
DEBUG(5, ("invalid parameter '%s' given\n",
valname));
} else {
DEBUG(5, ("invalid value '%s' given for "
"parameter '%s'\n", valstr, valname));
}
if (!lp_parameter_is_valid(valname)) {
DEBUG(5, ("Invalid parameter '%s' given.\n", valname));
err = SBC_ERR_INVALID_PARAM;
goto done;
}
if (!smbconf_reg_parameter_is_valid(canon_valname)) {
if (!smbconf_reg_parameter_is_valid(valname)) {
DEBUG(5, ("Parameter '%s' not allowed in registry.\n",
canon_valname));
valname));
err = SBC_ERR_INVALID_PARAM;
goto done;
}
@ -208,12 +199,26 @@ static sbcErr smbconf_reg_set_value(struct registry_key *key,
lp_parameter_is_global(valname))
{
DEBUG(5, ("Global parameter '%s' not allowed in "
"service definition ('%s').\n", canon_valname,
"service definition ('%s').\n", valname,
subkeyname));
err = SBC_ERR_INVALID_PARAM;
goto done;
}
if (!lp_canonicalize_parameter_with_value(valname, valstr,
&canon_valname,
&canon_valstr))
{
/*
* We already know the parameter name is valid.
* So the value must be invalid.
*/
DEBUG(5, ("invalid value '%s' given for parameter '%s'\n",
valstr, valname));
err = SBC_ERR_INVALID_PARAM;
goto done;
}
ZERO_STRUCT(val);
val.type = REG_SZ;