summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-07-28 07:49:36 +0530
committerAnand Avati <avati@redhat.com>2012-07-29 13:24:32 -0700
commitc2859a6039ecb74a4b88989326fa538d1d5b06c2 (patch)
treea47a461f30e365917247a0907f5771370e0b67e7
parent6a5e047bc56fc80a0f87f3a44056ffc38ba68c25 (diff)
cli: Prevent creation of volumes with tokens as volnames
RCA: yyparse confuses volnames with tokens when any of the tokens 'volume', 'type', 'subvolumes', 'option', 'end-volume' are used as volnames. This happens because io-stats xlator name is same as volname in fuse volfile. Both nfs, fuse volfiles are affected by this problem. Fix: We could fix this also by changing io-stats xlator name to something other than 'volname'. But I am worried of the backward compatibility issues it may introduce. Disallowing creation of volumes with tokens as volname seems like a safer fix. Tests: All volume creation operations with tokens as volname give invalid volume name error. Change-Id: Ifc63a5c31375e92541b954ec133aa3c8e6a56a02 BUG: 844030 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/3745 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 18b628ae18b..b29583f21a0 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -168,6 +168,8 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
char *bricks = NULL;
int32_t brick_count = 0;
char *opwords[] = { "replica", "stripe", "transport", NULL };
+ char *invalid_volnames[] = {"volume", "type", "subvolumes", "option",
+ "end-volume", "all", NULL};
char *w = NULL;
int op_count = 0;
int32_t replica_count = 1;
@@ -193,9 +195,12 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
if (volname[0] == '-')
goto out;
- if (!strcmp (volname, "all")) {
- cli_err ("\"all\" cannot be the name of a volume.");
- goto out;
+ for (i = 0; invalid_volnames[i]; i++) {
+ if (!strcmp (volname, invalid_volnames[i])) {
+ cli_err ("\"%s\" cannot be the name of a volume.",
+ volname);
+ goto out;
+ }
}
if (strchr (volname, '/'))