From c2859a6039ecb74a4b88989326fa538d1d5b06c2 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Sat, 28 Jul 2012 07:49:36 +0530 Subject: 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 Reviewed-on: http://review.gluster.com/3745 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- cli/src/cli-cmd-parser.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 18b628ae..b29583f2 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, '/')) -- cgit