summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2010-09-04 01:11:34 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-06 02:21:36 -0700
commit4c87d30724b29a83c6a0f4a101468824fa76ac19 (patch)
treea2368d6b61648b9efb7f684a76f3804250388e5e /cli
parent07d84f0f77ea336b3c3ae65907261ed3242feacb (diff)
Volume create hostname should not be localhost
volume create hostname should not be localhost or 127.0.0.1. It should be a valid nodeid or ip. This will prevent invalid vol files being created on glusterd's when localhost or 127.0.0.1 is specified Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1505 (volume create/add-brick requires ip or hostname for localhost) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1505
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index fb3b162d1..cf9357c41 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -52,6 +52,9 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
char *tmp_list = NULL;
char *tmpptr = NULL;
int j = 0;
+ char *host_name = NULL;
+ char *tmp = NULL;
+ char *freeptr = NULL;
GF_ASSERT (words);
GF_ASSERT (options);
@@ -164,6 +167,26 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
ret = -1;
goto out;
}
+
+ host_name = gf_strdup(words[brick_index]);
+ if (!host_name) {
+ ret = -1;
+ gf_log("cli",GF_LOG_ERROR, "Unable to allocate "
+ "memory");
+ goto out;
+ }
+ freeptr = host_name;
+
+ strtok_r(host_name, ":", &tmp);
+ if (!(strcmp(host_name, "localhost") &&
+ strcmp (host_name, "127.0.0.1"))) {
+ cli_out ("Please provide a valid hostname/ip other "
+ "localhost or 127.0.0.1");
+ ret = -1;
+ GF_FREE(freeptr);
+ goto out;
+ }
+ GF_FREE (freeptr);
tmp_list = strdup(brick_list+1);
j = 0;
while(( brick_count != 0) && (j < brick_count)) {