diff options
author | GauravKumarGarg <ggarg@redhat.com> | 2015-01-06 16:58:38 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-01-19 20:28:28 -0800 |
commit | 1ee8ce725f0e70f45419aa0e2f4d85db7223d766 (patch) | |
tree | d93f0499e6b94b88600ccff1611f194c6d99487f /xlators/mgmt/glusterd/src/glusterd-volume-set.c | |
parent | a29d6c80dfbd848e0b453d64faf761fe52b4d6c5 (diff) |
glusterd: option features.uss should accept only boolean value
"features.uss" with a non-boolean value gets set in the volume option
table because of which subsequent volume set operation fails since
features.uss does not contain a valid boolean value.
Fix is not to allow a non-boolean value to get set in the volume option
table. "features.uss" option should have validation function "validate_uss"
which validate the input value given by user.
Change-Id: I4a212f876627a4979715183b0d488fd69095f193
BUG: 1179175
Signed-off-by: ggarg <ggarg@redhat.com>
Reviewed-on: http://review.gluster.org/9395
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volume-set.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index a92bfffdb4f..27f35238dab 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -197,6 +197,32 @@ out: } static int +validate_uss (dict_t *dict, char *key, char *value, char **op_errstr) +{ + char errstr[2048] = ""; + int ret = 0; + xlator_t *this = NULL; + gf_boolean_t b = _gf_false; + + this = THIS; + GF_ASSERT (this); + + ret = gf_string2boolean (value, &b); + if (ret) { + snprintf (errstr, sizeof (errstr), "%s is not a valid boolean " + "value. %s expects a valid boolean value.", value, + key); + gf_log (this->name, GF_LOG_ERROR, "%s", errstr); + *op_errstr = gf_strdup (errstr); + goto out; + } +out: + gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + + return ret; +} + +static int validate_stripe (dict_t *dict, char *key, char *value, char **op_errstr) { char errstr[2048] = ""; @@ -1141,6 +1167,7 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = GD_OP_VERSION_3_6_0, .value = "off", .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT, + .validate_fn = validate_uss, .description = "enable/disable User Serviceable Snapshots on the " "volume." }, |