21ab4e
From 17fcdf15aa8620bf69623bae4a081f5cf7780dbd Mon Sep 17 00:00:00 2001
21ab4e
From: Gaurav Yadav <gyadav@redhat.com>
21ab4e
Date: Tue, 21 Feb 2017 22:35:47 +0530
21ab4e
Subject: [PATCH 398/406] glusterd : cluster.brick-multiplex validation is
21ab4e
 missing while setting it
21ab4e
21ab4e
Currently glusterd allow setting all values  while setting cluster.brick-multiplex
21ab4e
option. Validation of allowed options is missing.
21ab4e
21ab4e
With this patch glusterd will validate the values given while setting
21ab4e
cluster.brick-multiplex.
21ab4e
21ab4e
> Reviewed-on: https://review.gluster.org/16704
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
21ab4e
Change-Id: I938fb16b8f5faa9d31326373cd18632b8aa7ebab
21ab4e
BUG: 1443950
21ab4e
Signed-off-by: Gaurav Yadav <gyadav@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/104133
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/mgmt/glusterd/src/glusterd-volume-set.c | 31 ++++---------------------
21ab4e
 1 file changed, 4 insertions(+), 27 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
index 4ee27b4..2d4dfc0 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
@@ -893,30 +893,6 @@ out:
21ab4e
         return ret;
21ab4e
 }
21ab4e
 
21ab4e
-
21ab4e
-static int
21ab4e
-validate_worm (glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
21ab4e
-               char *value, char **op_errstr)
21ab4e
-{
21ab4e
-        xlator_t *this      =       NULL;
21ab4e
-        gf_boolean_t b      =       _gf_false;
21ab4e
-        int ret             =       -1;
21ab4e
-
21ab4e
-        this = THIS;
21ab4e
-        GF_VALIDATE_OR_GOTO ("glusterd", this, out);
21ab4e
-        ret = gf_string2boolean (value, &b);
21ab4e
-        if (ret) {
21ab4e
-                gf_asprintf (op_errstr, "%s is not a valid boolean value. %s "
21ab4e
-                             "expects a valid boolean value.", value, key);
21ab4e
-                gf_msg (this->name, GF_LOG_ERROR, 0,
21ab4e
-                        GD_MSG_INVALID_ENTRY, "%s", *op_errstr);
21ab4e
-        }
21ab4e
-out:
21ab4e
-        gf_msg_debug ("glusterd", 0, "Returning %d", ret);
21ab4e
-
21ab4e
-        return ret;
21ab4e
-}
21ab4e
-
21ab4e
 static int
21ab4e
 validate_boolean (glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
21ab4e
                char *value, char **op_errstr)
21ab4e
@@ -2500,7 +2476,7 @@ struct volopt_map_entry glusterd_volopt_map[] = {
21ab4e
           .voltype     = "features/worm",
21ab4e
           .option      = "worm",
21ab4e
           .value       = "off",
21ab4e
-          .validate_fn = validate_worm,
21ab4e
+          .validate_fn = validate_boolean,
21ab4e
           .op_version  = 2,
21ab4e
           .flags       = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT
21ab4e
         },
21ab4e
@@ -2508,7 +2484,7 @@ struct volopt_map_entry glusterd_volopt_map[] = {
21ab4e
           .voltype     = "features/worm",
21ab4e
           .option      = "worm-file-level",
21ab4e
           .value       = "off",
21ab4e
-          .validate_fn = validate_worm,
21ab4e
+          .validate_fn = validate_boolean,
21ab4e
           .op_version  = GD_OP_VERSION_3_8_0,
21ab4e
           .flags      = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT
21ab4e
         },
21ab4e
@@ -3145,7 +3121,8 @@ struct volopt_map_entry glusterd_volopt_map[] = {
21ab4e
         { .key         = GLUSTERD_BRICK_MULTIPLEX_KEY,
21ab4e
           .voltype     = "mgmt/glusterd",
21ab4e
           .value       = "off",
21ab4e
-          .op_version  = GD_OP_VERSION_3_10_0
21ab4e
+          .op_version  = GD_OP_VERSION_3_10_0,
21ab4e
+          .validate_fn = validate_boolean
21ab4e
         },
21ab4e
         { .key         = NULL
21ab4e
         }
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e