]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw file: refuse to rename directories
authorMatt Benjamin <mbenjamin@redhat.com>
Mon, 8 Aug 2016 14:18:35 +0000 (10:18 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 5 Oct 2016 18:23:01 +0000 (14:23 -0400)
The representation of paths as an aggregate involving any
number of objects argues against ever permitting such
operations.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit 297220fd2a96c0cf34701127b8cf724e24e6865f)

src/rgw/rgw_file.cc

index 525062cdb12a97c5b3a8271ec84b6c9f14f37326..538b05f7842e7d65e85afed929c0971115ef4cbb 100644 (file)
@@ -298,6 +298,18 @@ namespace rgw {
       goto out;
     }
 
+    /* forbid renaming of directories (unreasonable at scale) */
+    if (rgw_fh->is_dir()) {
+      ldout(get_context(), 12) << __func__
+                       << " rejecting attempt to rename directory path="
+                       << rgw_fh->full_object_name()
+                       << dendl;
+      rgw_fh->mtx.unlock(); /* !LOCKED */
+      unref(rgw_fh); /* -ref */
+      rc = -EPERM;
+      goto out;
+    }
+
     for (int ix : {0, 1}) {
       switch (ix) {
       case 0: