diff options
author | Kotresh HR <khiremat@redhat.com> | 2019-04-23 12:41:32 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-05-11 11:09:06 +0000 |
commit | af4d9131c8d09907853ee2f6e30b2a9bd80f3c84 (patch) | |
tree | 87a3adb186c0b116574ee37aedc59942a92a60a5 /cli/src/cli-cmd-parser.c | |
parent | b4db967224db3b16bc1d749fc2cb6f795363362d (diff) |
cli: Validate invalid slave url
This patch validates the invalid slave url
in cli itself and throws appropriate error.
fixes: bz#1098991
Change-Id: I278e2a04a4d619d2c2d1db0dd56ab5bdf7e7f469
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index ccae1ada981..6539b622dc0 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2486,6 +2486,17 @@ gsyncd_url_check(const char *w) } static gf_boolean_t +valid_slave_gsyncd_url(const char *w) +{ + if (strstr(w, ":::")) + return _gf_false; + else if (strstr(w, "::")) + return _gf_true; + else + return _gf_false; +} + +static gf_boolean_t gsyncd_glob_check(const char *w) { return !!strpbrk(w, "*?["); @@ -2708,7 +2719,8 @@ out: } int32_t -cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **options) +cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **options, + char **errstr) { int32_t ret = -1; dict_t *dict = NULL; @@ -2797,8 +2809,11 @@ cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **options) if (masteri && gsyncd_url_check(words[masteri])) goto out; - if (slavei && !glob && !gsyncd_url_check(words[slavei])) + + if (slavei && !glob && !valid_slave_gsyncd_url(words[slavei])) { + gf_asprintf(errstr, "Invalid slave url: %s", words[slavei]); goto out; + } w = str_getunamb(words[cmdi], opwords); if (!w) |