From: Ramana Raja Date: Wed, 24 Feb 2021 03:38:50 +0000 (-0500) Subject: mds: allow `fs authorize` command to work X-Git-Tag: v16.2.0~59^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4df5e083c41f82c806a9063edc35b381045f9b08;p=ceph.git mds: allow `fs authorize` command to work ... on filesystems with '-' in their names. Fixes: https://tracker.ceph.com/issues/49301 Signed-off-by: Ramana Raja (cherry picked from commit 22ed4f43d90ab41022ed30c424a8d0956740c005) --- diff --git a/qa/tasks/cephfs/test_admin.py b/qa/tasks/cephfs/test_admin.py index 744f0fdcfc242..a39a3e3c045ea 100644 --- a/qa/tasks/cephfs/test_admin.py +++ b/qa/tasks/cephfs/test_admin.py @@ -492,6 +492,24 @@ class TestSubCmdFsAuthorize(CapsHelper): cmdargs = ['echo', 'some random data', Raw('|'), 'sudo', 'tee', filepath] self.mount_a.negtestcmd(args=cmdargs, retval=1, errmsg='permission denied') + def test_single_path_authorize_on_nonalphanumeric_fsname(self): + """ + That fs authorize command works on filesystems with names having [_.-] characters + """ + self.mount_a.umount_wait(require_clean=True) + self.mds_cluster.delete_all_filesystems() + fs_name = "cephfs-_." + self.fs = self.mds_cluster.newfs(name=fs_name) + self.fs.wait_for_daemons() + self.run_cluster_cmd(f'auth caps client.{self.mount_a.client_id} ' + f'mon "allow r" ' + f'osd "allow rw pool={self.fs.get_data_pool_name()}" ' + f'mds allow') + self.mount_a.remount(cephfs_name=self.fs.name) + perm = 'rw' + filepaths, filedata, mounts, keyring = self.setup_test_env(perm) + self.run_mds_cap_tests(filepaths, filedata, mounts, perm) + def test_multiple_path_r(self): perm, paths = 'r', ('/dir1', '/dir2/dir22') filepaths, filedata, mounts, keyring = self.setup_test_env(perm, paths) diff --git a/src/mds/MDSAuthCaps.cc b/src/mds/MDSAuthCaps.cc index 34d4febbc8c47..dbf96ff303295 100644 --- a/src/mds/MDSAuthCaps.cc +++ b/src/mds/MDSAuthCaps.cc @@ -63,7 +63,7 @@ struct MDSCapParser : qi::grammar lexeme[lit("'") >> *(char_ - '\'') >> '\'']; unquoted_path %= +char_("a-zA-Z0-9_./-"); network_str %= +char_("/.:a-fA-F0-9]["); - fs_name_str %= +char_("a-zA-Z0-9-_."); + fs_name_str %= +char_("a-zA-Z0-9_.-"); // match := [path=] [uid= [gids=[,...]] // TODO: allow fsname, and root_squash to be specified with uid, and gidlist diff --git a/src/mon/MonCap.cc b/src/mon/MonCap.cc index 2dceb5311386e..dc5bbe8084cff 100644 --- a/src/mon/MonCap.cc +++ b/src/mon/MonCap.cc @@ -540,7 +540,7 @@ struct MonCapParser : qi::grammar unquoted_word %= +char_("a-zA-Z0-9_./-"); str %= quoted_string | unquoted_word; network_str %= +char_("/.:a-fA-F0-9]["); - fs_name_str %= +char_("a-zA-Z0-9-_."); + fs_name_str %= +char_("a-zA-Z0-9_.-"); spaces = +(lit(' ') | lit('\n') | lit('\t'));