summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/bugs/glusterd/bug-1482344-volume-option-set-cluster-level.t25
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c8
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/bugs/glusterd/bug-1482344-volume-option-set-cluster-level.t b/tests/bugs/glusterd/bug-1482344-volume-option-set-cluster-level.t
new file mode 100644
index 00000000000..481dee186b8
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1482344-volume-option-set-cluster-level.t
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+#Test case: glusterd should disallow a volume level option to be set cluster
+wide and glusterd should not crash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+cleanup;
+
+#Basic checks
+TEST glusterd
+TEST pidof glusterd
+
+#Create a 2x1 distributed volume
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2};
+TEST $CLI volume start $V0
+
+TEST ! $CLI volume set all transport.listen-backlog 128
+
+# Check the volume info output, if glusterd would have crashed then this command
+# will fail
+TEST $CLI volume info $V0;
+
+cleanup;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 410885e82de..69629f201aa 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -807,6 +807,14 @@ glusterd_volopt_validate (glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
if ((vme->validate_fn) &&
((!strcmp (key, vme->key)) ||
(!strcmp (key, strchr (vme->key, '.') + 1)))) {
+ if ((vme->type != GLOBAL_DOC &&
+ vme->type != GLOBAL_NO_DOC) && !volinfo) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "%s is not"
+ " a global option", vme->key);
+ ret = -1;
+ goto out;
+ }
ret = vme->validate_fn (volinfo, dict, key, value,
op_errstr);
if (ret)