From: Casey Bodley Date: Sun, 17 Dec 2023 17:11:06 +0000 (-0500) Subject: rgw/rados: Bucket::chown() updates owner on bucket instance X-Git-Tag: testing/wip-pdonnell-testing-20240416.232051-debug~25^2~134 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c44c493aed60d22950e17e71024e74c5fcc4e2e1;p=ceph-ci.git rgw/rados: Bucket::chown() updates owner on bucket instance Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 163b602bc90..45df165033c 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -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)