summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd-parser.c37
-rw-r--r--cli/src/cli-mem-types.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c2
3 files changed, 35 insertions, 5 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index a0219a04ad7..ca4c8d315ce 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1122,8 +1122,11 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
{
int32_t ret = 0;
int32_t config_type = 0;
- dict_t *dict = NULL;
- gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE;
+ dict_t *dict = NULL;
+ gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE;
+ char *append_str = NULL;
+ size_t append_len = 0;
+ int i = 0;
GF_ASSERT (words);
GF_ASSERT (options);
@@ -1164,11 +1167,34 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
if (strcmp (words [5], "config-set") == 0) {
config_type = GF_GSYNC_OPTION_TYPE_CONFIG_SET;
+ if (wordcount < 8) {
+ ret = -1;
+
+ goto out;
+ }
+
ret = dict_set_str (dict, "op_name", (char *)words[6]);
if (ret < 0)
goto out;
+ /*XXX hack to get around the fact, where parsing of
+ * args is done based on spaces */
+ for (i = 7; i < wordcount; i++)
+ append_len += (strlen (words[i]) + 1);
+ append_len++; /* trailing strcat will add two bytes, make space for that */
+
+ append_str = GF_CALLOC (1, append_len, cli_mt_append_str);
+ if (!append_str) {
+ ret = -1;
+ goto out;
+ }
+
+ for (i = 7; i< wordcount; i++) {
+ strcat (append_str, words[i]);
+ strcat (append_str, " ");
+ }
+ append_str[append_len - 2] = '\0';
- ret = dict_set_str (dict, "op_value", (char *)words[7]);
+ ret = dict_set_dynstr (dict, "op_value", append_str);
if (ret < 0)
goto out;
}
@@ -1205,9 +1231,12 @@ set_type:
*options = dict;
out:
- if (ret)
+ if (ret) {
if (dict)
dict_destroy (dict);
+ if (append_str)
+ GF_FREE (append_str);
+ }
return ret;
}
diff --git a/cli/src/cli-mem-types.h b/cli/src/cli-mem-types.h
index 86e346641ff..a3d74d31ad8 100644
--- a/cli/src/cli-mem-types.h
+++ b/cli/src/cli-mem-types.h
@@ -32,6 +32,7 @@ enum cli_mem_types_ {
cli_mt_call_pool_t,
cli_mt_cli_local_t,
cli_mt_cli_get_vol_ctx_t,
+ cli_mt_append_str,
cli_mt_end
};
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 4017dd91c11..aaedf3d8761 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -3744,7 +3744,7 @@ gsync_config_set (char *master, char *slave,
}
ret = snprintf (cmd, 1024, GSYNCD_PREFIX"/gsyncd -c %s/%s %s %s"
- " --config-set %s %s", priv->workdir,
+ " --config-set %s \" %s \"", priv->workdir,
GSYNC_CONF, master, slave, op_name, op_value);
if (ret <= 0) {
gf_log ("", GF_LOG_WARNING, "failed to "