From 22ed4f43d90ab41022ed30c424a8d0956740c005 Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Tue, 23 Feb 2021 22:38:50 -0500 Subject: [PATCH] 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 --- qa/tasks/cephfs/test_admin.py | 18 ++++++++++++++++++ src/mds/MDSAuthCaps.cc | 2 +- src/mon/MonCap.cc | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/qa/tasks/cephfs/test_admin.py b/qa/tasks/cephfs/test_admin.py index 744f0fdcfc24..a39a3e3c045e 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 34d4febbc8c4..dbf96ff30329 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 2dceb5311386..dc5bbe8084cf 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')); -- 2.47.3