]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
AuthMonitor: no need to check permission in MDS caps
authorRishabh Dave <ridave@redhat.com>
Sat, 24 Jun 2023 04:17:12 +0000 (09:47 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 13 Mar 2024 13:42:30 +0000 (19:12 +0530)
For "fs authorize" command, AuthMonitor.cc checks if permissions is "r"
or begins with "rw". This check is redundant now.
AuthMonitor::valid_caps() runs MDSAuthCaps.parse() which now runs same
check for the MDS caps, regardless of the command.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit 8e1e322054ea14eb5e59969439c0ea27885503ab)

Conflicts:
qa/tasks/cephfs/test_admin.py
Since line numbers where the patch should be applied is
different in quincy branch compared to main branch, the conflict
occured.

qa/tasks/cephfs/test_admin.py
src/mon/AuthMonitor.cc

index ae04a4ca3154088ff97e3aec0f60afce2a0d9e08..340dde80e343062d1a108ae38d482a5784af3bc0 100644 (file)
@@ -1180,3 +1180,10 @@ class TestPermErrMsg(CephFSTestCase):
     def test_auth_get_or_create_key(self):
         for mdscap in self.MDSCAPS:
             self._negtestcmd('auth get-or-create-key', mdscap)
+
+    def test_fs_authorize(self):
+        for wrong_perm in ('w', 'wr'):
+            self.negtest_ceph_cmd(
+                args=(f'fs authorize {self.fs.name} {self.CLIENT_NAME} / '
+                      f'{wrong_perm}'), retval=self.EXPECTED_ERRNO,
+                errmsgs=self.EXPECTED_ERRMSG)
index 395ff4926189971ad7b4d9487bd6ed582dcc102d..59adc404eb4f86f71ad12cd1a3d6fc12f7a245b0 100644 (file)
@@ -1769,11 +1769,6 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op)
        ++it;
       }
 
-      if (cap != "r" && cap.compare(0, 2, "rw")) {
-       ss << "Permission flags must start with 'r' or 'rw'.";
-       err = -EINVAL;
-       goto done;
-      }
       if (cap.compare(0, 2, "rw") == 0)
        osd_cap_wanted = "rw";