summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2012-03-07 13:06:38 +0530
committerAnand Avati <avati@redhat.com>2012-03-18 00:52:40 -0700
commit93022c0cc6c22b3a30ded3e109a3fe0a0dce8ca0 (patch)
treee3544585d651356c8e8bbb17d62f432855f1ea47 /cli/src
parentc3bbf6aa6c090fd066ab0079aa1c8ae332309d2a (diff)
mgmt/glusterd : volume set validation fixes
This is the new version of the patch by Kaushik at review.gluster.com/699 The following new option types have been introduced: * GF_OPTION_TYPE_INTERNET_ADDRESS_LIST * GF_OPTION_TYPE_PRIORITY_LIST * GF_OPTION_TYPE_SIZE_LIST and option types of several options in translators have been updated to use the new types. valid_internet_address(), valid_ipv4_address() & valid_ipv6_address() functions has been updated for * wildcard matching. Previously used standalone wildcard address checking functions have been removed. Changes have been done to stripe translator to correctly set, update and use stripe-blocksize. Also minimum value for block-size has been set to 16KB. Change-Id: I2aa484ff695f6a915a8fc9a9f965cf0344f41d59 BUG: 765248 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.com/2899 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shishir Gowda <shishirng@gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-parser.c101
-rw-r--r--cli/src/cli-cmd-peer.c2
2 files changed, 26 insertions, 77 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index d41493b6cf7..4c86ab488c5 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -115,9 +115,9 @@ cli_cmd_bricks_parse (const char **words, int wordcount, int brick_index,
GF_FREE (tmp_host);
goto out;
}
- if (!valid_internet_address (host_name)) {
- cli_out ("internet address '%s' does not comform to "
- "standards", host_name);
+ if (!valid_internet_address (host_name, _gf_false)) {
+ cli_out ("internet address '%s' does not conform to "
+ "standards", host_name);
}
GF_FREE (tmp_host);
tmp_list = gf_strdup (brick_list + 1);
@@ -635,53 +635,16 @@ out:
}
int32_t
-cli_cmd_valid_ip_list (char *iplist)
-{
- int ret = 0;
- char *duplist = NULL;
- char *addr = NULL;
- char *saveptr = NULL;
-
- GF_ASSERT (iplist);
- duplist = gf_strdup (iplist);
-
- if (!duplist) {
- ret = -1;
- goto out;
- }
-
- addr = strtok_r (duplist, ",", &saveptr);
- if (!addr) {
- ret = -1;
- goto out;
- }
- while (addr) {
- if (!valid_internet_address (addr) &&
- !valid_wildcard_internet_address (addr)) {
- cli_out ("Invalid ip or wildcard : %s", addr);
- ret= -1;
- goto out;
- }
- addr = strtok_r (NULL, ",", &saveptr);
- }
-out:
- if (duplist)
- GF_FREE (duplist);
- gf_log ("cli", GF_LOG_INFO, "Returning %d", ret);
- return ret;
-}
-
-int32_t
cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options)
{
- dict_t *dict = NULL;
- char *volname = NULL;
- int ret = -1;
- int count = 0;
- char *key = NULL;
- char *value = NULL;
- int i = 0;
- char str[50] = {0,};
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ int ret = -1;
+ int count = 0;
+ char *key = NULL;
+ char *value = NULL;
+ int i = 0;
+ char str[50] = {0,};
GF_ASSERT (words);
GF_ASSERT (options);
@@ -703,42 +666,28 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options)
if (ret)
goto out;
- if (wordcount == 3) {
- if (!strcmp (volname, "help")) {
- ret = dict_set_str (dict, "help", volname);
- if (ret)
- goto out;
- } else if (!strcmp (volname, "help-xml")) {
- ret = dict_set_str (dict, "help-xml", volname);
- if (ret)
- goto out;
- } else {
- ret = -1;
+ if ((!strcmp (volname, "help") || !strcmp (volname, "help-xml"))
+ && wordcount == 3 ) {
+ ret = dict_set_str (dict, volname, volname);
+ if (ret)
goto out;
- }
+ } else if (wordcount < 5) {
+ ret = -1;
+ goto out;
}
-
for (i = 3; i < wordcount; i+=2) {
- key = (char *) words[i];
- value = (char *) words[i+1];
+ key = (char *) words[i];
+ value = (char *) words[i+1];
- if ( !key || !value) {
- ret = -1;
- goto out;
- }
+ if ( !key || !value) {
+ ret = -1;
+ goto out;
+ }
count++;
- if (!strncmp ("auth.allow", key, sizeof (key)) ||
- !strncmp ("auth.reject", key, sizeof (key))) {
- ret = cli_cmd_valid_ip_list (value);
- if (ret) {
- gf_log ("cli", GF_LOG_ERROR,
- "invalid ips given");
- goto out;
- }
- }
+
sprintf (str, "key%d", count);
ret = dict_set_str (dict, str, key);
if (ret)
diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c
index cad520dfcb5..7f0d28f6d08 100644
--- a/cli/src/cli-cmd-peer.c
+++ b/cli/src/cli-cmd-peer.c
@@ -72,7 +72,7 @@ cli_cmd_peer_probe_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (ret)
goto out;
- ret = valid_internet_address ((char *) words[2]);
+ ret = valid_internet_address ((char *) words[2], _gf_false);
if (ret == 1) {
ret = 0;
} else {