summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-09-22 08:26:47 +0200
committerMichael Adam <obnox@samba.org>2013-09-24 07:44:28 +0200
commit3e5309768931629da555d0ea1b236913f4cc3484 (patch)
treeef53e1cd69baf680bb1784867cd86c55766846cc
parent429ab4ed02e2ef0887e92942987e5702022c8a7f (diff)
downloadsamba-3e5309768931629da555d0ea1b236913f4cc3484.tar.gz
samba-3e5309768931629da555d0ea1b236913f4cc3484.tar.bz2
samba-3e5309768931629da555d0ea1b236913f4cc3484.zip
s3:net rpc conf: reorganize the validity check and canonicalization of the input in "setparm"
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r--source3/utils/net_rpc_conf.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/source3/utils/net_rpc_conf.c b/source3/utils/net_rpc_conf.c
index 49c2eaf5f8..edf612088a 100644
--- a/source3/utils/net_rpc_conf.c
+++ b/source3/utils/net_rpc_conf.c
@@ -1822,39 +1822,45 @@ static NTSTATUS rpc_conf_setparm_internal(struct net_context *c,
break;
}
- /* check if parameter is valid for writing */
- if (!lp_canonicalize_parameter_with_value(argv[1], argv[2],
- &canon_valname,
- &canon_valstr))
- {
- if (canon_valname == NULL) {
- d_fprintf(stderr, "invalid parameter '%s' given\n",
- argv[1]);
- } else {
- d_fprintf(stderr, "invalid value '%s' given for "
- "parameter '%s'\n", argv[1], argv[2]);
- }
+ /*
+ * check if parameter is valid for writing
+ */
+
+ if (!lp_parameter_is_valid(argv[1])) {
+ d_fprintf(stderr, "Invalid parameter '%s' given.\n", argv[1]);
werr = WERR_INVALID_PARAM;
goto error;
}
- if (!smbconf_reg_parameter_is_valid(canon_valname)) {
+ if (!smbconf_reg_parameter_is_valid(argv[1])) {
d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n",
argv[1]);
werr = WERR_INVALID_PARAM;
goto error;
}
- if (!strequal(argv[0], "global") &&
- lp_parameter_is_global(argv[1]))
- {
+ if (!strequal(argv[0], "global") && lp_parameter_is_global(argv[1])) {
d_fprintf(stderr, "Global parameter '%s' not allowed in "
- "service definition ('%s').\n", canon_valname,
+ "service definition ('%s').\n", argv[1],
argv[0]);
werr = WERR_INVALID_PARAM;
goto error;
}
+ if (!lp_canonicalize_parameter_with_value(argv[1], argv[2],
+ &canon_valname,
+ &canon_valstr))
+ {
+ /*
+ * We already know the parameter name is valid.
+ * So the value must be invalid.
+ */
+ d_fprintf(stderr, "invalid value '%s' given for "
+ "parameter '%s'\n", argv[1], argv[2]);
+ werr = WERR_INVALID_PARAM;
+ goto error;
+ }
+
/* set the parameter */
status = dcerpc_winreg_set_sz(frame, b, &share_hnd,
argv[1], argv[2], &werr);