]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: allow `fs authorize` command to work 40086/head
authorRamana Raja <rraja@redhat.com>
Wed, 24 Feb 2021 03:38:50 +0000 (22:38 -0500)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 12 Mar 2021 20:52:31 +0000 (12:52 -0800)
... on filesystems with '-' in their names.

Fixes: https://tracker.ceph.com/issues/49301
Signed-off-by: Ramana Raja <rraja@redhat.com>
(cherry picked from commit 22ed4f43d90ab41022ed30c424a8d0956740c005)

qa/tasks/cephfs/test_admin.py
src/mds/MDSAuthCaps.cc
src/mon/MonCap.cc

index 744f0fdcfc242f0331a0910923e938e406134dee..a39a3e3c045ea1a7a8e6d1e96ce22db15f5ea8bf 100644 (file)
@@ -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)
index 34d4febbc8c4766bdcf7fd1366f58245798d44cd..dbf96ff30329590989d78f427de82c7c5d34c680 100644 (file)
@@ -63,7 +63,7 @@ struct MDSCapParser : qi::grammar<Iterator, MDSAuthCaps()>
       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=<path>] [uid=<uid> [gids=<gid>[,<gid>...]]
     // TODO: allow fsname, and root_squash to be specified with uid, and gidlist
index 2dceb5311386e4ae8d9672eb491a83b727b05471..dc5bbe8084cfff941d09af695ce9756f8282ed4c 100644 (file)
@@ -540,7 +540,7 @@ struct MonCapParser : qi::grammar<Iterator, MonCap()>
     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'));