]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWCopyObj loads src_bucket in init_processing()
authorCasey Bodley <cbodley@redhat.com>
Thu, 23 Mar 2023 19:02:51 +0000 (15:02 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 11 Apr 2023 13:12:00 +0000 (09:12 -0400)
if `RGWCopyObj::verify_permissions()` returns an error, it may leave
some zipper objects uninitialized. when the user has admin or system
privileges, we'll ignore that error and call `execute()` anyway. this
moves the initialization into `RGWCopyObj::init_processing()` instead

Fixes: https://tracker.ceph.com/issues/58035
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 9e1d2b140fe9550370fdc6e15329005ecc5b4d9d)

src/rgw/rgw_op.cc
src/rgw/rgw_op.h

index 238ee2956b22a66a56e7ca7e2a32eb060439f259..b9be0e823408ccd973fa2335e9b4f9acd9856c54 100644 (file)
@@ -5191,10 +5191,13 @@ bool RGWCopyObj::parse_copy_location(const std::string_view& url_src,
   return true;
 }
 
-int RGWCopyObj::verify_permission(optional_yield y)
+int RGWCopyObj::init_processing(optional_yield y)
 {
-  RGWAccessControlPolicy src_acl(s->cct);
-  boost::optional<Policy> src_policy;
+  op_ret = RGWOp::init_processing(y);
+  if (op_ret < 0) {
+    return op_ret;
+  }
+
   op_ret = get_params(y);
   if (op_ret < 0)
     return op_ret;
@@ -5217,6 +5220,14 @@ int RGWCopyObj::verify_permission(optional_yield y)
 
   /* This is the only place the bucket is set on src_object */
   s->src_object->set_bucket(src_bucket.get());
+  return 0;
+}
+
+int RGWCopyObj::verify_permission(optional_yield y)
+{
+  RGWAccessControlPolicy src_acl(s->cct);
+  boost::optional<Policy> src_policy;
+
   /* get buckets info (source and dest) */
   if (s->local_source &&  source_zone.empty()) {
     s->src_object->set_atomic();
index b29c87c51cae02e6bba8cbd28cfce33511015839..2e95ebd03f7180a30694ad87fc3fe6a98864a8fb 100644 (file)
@@ -1570,6 +1570,7 @@ public:
     RGWOp::init(driver, s, h);
     dest_policy.set_ctx(s->cct);
   }
+  int init_processing(optional_yield y) override;
   int verify_permission(optional_yield y) override;
   void pre_exec() override;
   void execute(optional_yield y) override;