summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-07-24 12:44:11 +0530
committerAnand Avati <avati@redhat.com>2012-07-29 14:20:38 -0700
commit86e326921e29bc39f2ea4efe6a1882199de18a79 (patch)
treea3d24f0108b7ded371e8d3a64616db200be24501 /xlators/mgmt
parentc9b96e26a3bab09a4146b2bec57a57c69b9aa8b7 (diff)
glusterd: Persisted hooks friendly user.* keys
- Fixed validation of user.* keys in presence of multiple key, value pairs in a single volume set command Change-Id: I5b96de2d009fbc79772121308d9b4c0a552bac52 BUG: 825902 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.com/3715 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c21
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-hooks.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c28
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c44
4 files changed, 51 insertions, 48 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 4540bf3e272..ccec91f80df 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -285,7 +285,6 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
data_pair_t *pairs = NULL;
char reconfig_key[256] = {0, };
dict_t *dict = NULL;
- data_t *value = NULL;
int opt_count = 0;
glusterd_conf_t *priv = NULL;
char *volume_id_str = NULL;
@@ -370,21 +369,13 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
goto out;
}
- pairs = dict->members_list;
+ for (pairs = dict->members_list; pairs != NULL; pairs = pairs->next) {
+ snprintf (reconfig_key, 256, "volume%d.option.%s", count,
+ pairs->key);
+ ret = dict_set_str (volumes, reconfig_key, pairs->value->data);
+ if (0 == ret)
+ opt_count++;
- while (pairs) {
- if (1 == glusterd_check_option_exists (pairs->key, NULL)) {
- value = pairs->value;
- if (!value)
- continue;
-
- snprintf (reconfig_key, 256, "volume%d.option.%s", count,
- pairs->key);
- ret = dict_set_str (volumes, reconfig_key, value->data);
- if (!ret)
- opt_count++;
- }
- pairs = pairs->next;
}
snprintf (key, 256, "volume%d.opt_count", count);
diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.h b/xlators/mgmt/glusterd/src/glusterd-hooks.h
index e717395be40..2584b6bfeb0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-hooks.h
+++ b/xlators/mgmt/glusterd/src/glusterd-hooks.h
@@ -60,15 +60,13 @@ typedef struct hooks_stub {
static inline gf_boolean_t
-is_key_glusterd_hooks_friendly (xlator_t *this, char *volname, char *key)
+is_key_glusterd_hooks_friendly (char *key)
{
gf_boolean_t is_friendly = _gf_false;
/* This is very specific to hooks friendly behavior */
if (fnmatch (GD_HOOKS_SPECIFIC_KEY, key, FNM_NOESCAPE) == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "user configured key (%s) sent on volume %s",
- key, volname);
+ gf_log (THIS->name, GF_LOG_DEBUG, "user namespace key %s", key);
is_friendly = _gf_true;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index d6855b9043b..d4697434895 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -416,10 +416,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
goto out;
}
- if (is_key_glusterd_hooks_friendly (this, volname, key)) {
- ret = 0;
- goto out;
- }
+ if (is_key_glusterd_hooks_friendly (key))
+ continue;
exists = glusterd_check_option_exists (key, &key_fixed);
if (exists == -1) {
@@ -444,8 +442,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
if (key_fixed)
key = key_fixed;
- ret = glusterd_check_globaloption (key);
- if (ret)
+ if (glusterd_check_globaloption (key))
global_opt = _gf_true;
ret = dict_set_str (val_dict, key, value);
@@ -1111,20 +1108,17 @@ glusterd_op_set_volume (dict_t *dict)
goto out;
}
- if (is_key_glusterd_hooks_friendly (this, volname, key)) {
- ret = 0;
- goto out;
- }
+ if (!is_key_glusterd_hooks_friendly (key)) {
+ ret = glusterd_check_option_exists (key, &key_fixed);
+ GF_ASSERT (ret);
+ if (ret <= 0) {
+ key_fixed = NULL;
+ goto out;
+ }
- ret = glusterd_check_option_exists (key, &key_fixed);
- GF_ASSERT (ret);
- if (ret == -1) {
- key_fixed = NULL;
- goto out;
}
- ret = glusterd_check_globaloption (key);
- if (ret)
+ if (glusterd_check_globaloption (key))
global_opt = _gf_true;
if (!global_opt)
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index fba681e093a..07c29b9d359 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -42,6 +42,7 @@
#include "glusterd-sm.h"
#include "glusterd-op-sm.h"
#include "glusterd-utils.h"
+#include "glusterd-hooks.h"
#include "glusterd-store.h"
#include "rpc-clnt.h"
@@ -605,10 +606,17 @@ void _storeopts (dict_t *this, char *key, data_t *value, void *data)
if (!value || !value->data)
return;
- exists = glusterd_check_option_exists (key, NULL);
+ if (is_key_glusterd_hooks_friendly (key)) {
+ exists = 1;
+
+ } else {
+ exists = glusterd_check_option_exists (key, NULL);
+ }
+
if (1 == exists) {
gf_log ("", GF_LOG_DEBUG, "Storing in volinfo:key= %s, val=%s",
key, value->data);
+
} else {
gf_log ("", GF_LOG_DEBUG, "Discarding:key= %s, val=%s",
key, value->data);
@@ -2230,27 +2238,39 @@ glusterd_store_retrieve_volume (char *volname)
}
gf_log ("", GF_LOG_DEBUG, "Parsed as "GEOREP" "
" slave:key=%s,value:%s", key, value);
+
} else {
- exists = glusterd_check_option_exists (key, NULL);
- if (exists == -1) {
+
+ if (is_key_glusterd_hooks_friendly (key)) {
+ exists = 1;
+
+ } else {
+ exists = glusterd_check_option_exists (key,
+ NULL);
+ }
+
+ switch (exists) {
+ case -1:
ret = -1;
goto out;
- }
- if (exists) {
+
+ case 0:
+ gf_log ("", GF_LOG_ERROR, "Unknown key: %s",
+ key);
+ break;
+
+ case 1:
ret = dict_set_str(volinfo->dict, key,
- gf_strdup (value));
+ gf_strdup (value));
if (ret) {
gf_log ("",GF_LOG_ERROR, "Error in "
- "dict_set_str");
+ "dict_set_str");
goto out;
}
gf_log ("", GF_LOG_DEBUG, "Parsed as Volume-"
- "set:key=%s,value:%s",
- key, value);
+ "set:key=%s,value:%s", key, value);
+ break;
}
- else
- gf_log ("", GF_LOG_ERROR, "Unknown key: %s",
- key);
}
GF_FREE (key);