diff options
author | Michael Adam <obnox@samba.org> | 2013-09-22 08:47:14 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-09-24 07:44:28 +0200 |
commit | 76a008cd1827d0563c42dbef433e35ce5ee6a041 (patch) | |
tree | 1ff9d286268f2c8c7ea4a18176dcabd3629a2529 /source3/lib | |
parent | b7db29eb2a224068282f9dd38502a147c2df5712 (diff) | |
download | samba-76a008cd1827d0563c42dbef433e35ce5ee6a041.tar.gz samba-76a008cd1827d0563c42dbef433e35ce5ee6a041.tar.bz2 samba-76a008cd1827d0563c42dbef433e35ce5ee6a041.zip |
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>
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/smbconf/smbconf_reg.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c index 696dd1f823..9bdcbfd903 100644 --- a/source3/lib/smbconf/smbconf_reg.c +++ b/source3/lib/smbconf/smbconf_reg.c @@ -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; |