]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/rados: Bucket::chown() updates owner on bucket instance
authorCasey Bodley <cbodley@redhat.com>
Sun, 17 Dec 2023 17:11:06 +0000 (12:11 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 10 Apr 2024 17:09:14 +0000 (13:09 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_sal_rados.cc

index 163b602bc90f0e5ac07abb1f682673f98c16e056..45df165033cb0efa7bb857215194035adfda9865 100644 (file)
@@ -618,14 +618,41 @@ int RadosBucket::unlink(const DoutPrefixProvider* dpp, const rgw_owner& owner, o
 
 int RadosBucket::chown(const DoutPrefixProvider* dpp, const rgw_owner& new_owner, optional_yield y)
 {
-  std::string obj_marker;
   // unlink from the owner, but don't update the entrypoint until link()
   int r = this->unlink(dpp, info.owner, y, false);
   if (r < 0) {
     return r;
   }
 
-  return this->link(dpp, new_owner, y);
+  r = this->link(dpp, new_owner, y);
+  if (r < 0) {
+    return r;
+  }
+
+  // write updated owner to bucket instance metadata
+  info.owner = new_owner;
+
+  // update ACLOwner
+  if (auto i = attrs.find(RGW_ATTR_ACL); i != attrs.end()) {
+    try {
+      auto p = i->second.cbegin();
+
+      RGWAccessControlPolicy acl;
+      decode(acl, p);
+
+      acl.get_owner().id = new_owner;
+
+      bufferlist bl;
+      encode(acl, bl);
+
+      i->second = std::move(bl);
+    } catch (const buffer::error&) {
+      // not fatal
+    }
+  }
+
+  constexpr bool exclusive = false;
+  return put_info(dpp, exclusive, ceph::real_clock::now(), y);
 }
 
 int RadosBucket::put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time _mtime, optional_yield y)