From 1fd5320485a4d47c6da072b079dd106be82f6804 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 18 Jul 2018 16:24:24 -0400 Subject: [PATCH] rgw: RGWBucket::link supports tenant use tenant-aware helper functions to generate metadata keys/oids this allows 'radosgw-admin bucket link' to succeed for a tenanted user, provided that the bucket belongs to the same tenant Fixes: http://tracker.ceph.com/issues/22666 Signed-off-by: Casey Bodley --- src/rgw/rgw_bucket.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 34036572848d3..6cce9f7c15408 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -819,21 +819,20 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) rgw_bucket bucket = op_state.get_bucket(); const rgw_pool& root_pool = store->get_zone_params().domain_root; - rgw_raw_obj obj(root_pool, bucket.name); + std::string bucket_entry; + rgw_make_bucket_entry_name(tenant, bucket_name, bucket_entry); + rgw_raw_obj obj(root_pool, bucket_entry); RGWObjVersionTracker objv_tracker; map attrs; RGWBucketInfo bucket_info; - string key = bucket.name + ":" + bucket_id; RGWObjectCtx obj_ctx(store); - int r = store->get_bucket_instance_info(obj_ctx, key, bucket_info, NULL, &attrs); + int r = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, &attrs); if (r < 0) { return r; } - rgw_user user_id = op_state.get_user_id(); - map::iterator aiter = attrs.find(RGW_ATTR_ACL); if (aiter != attrs.end()) { bufferlist aclbl = aiter->second; @@ -881,8 +880,8 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) aclbl.clear(); policy_instance.encode(aclbl); - string oid_bucket_instance = RGW_BUCKET_INSTANCE_MD_PREFIX + key; - rgw_raw_obj obj_bucket_instance(root_pool, oid_bucket_instance); + rgw_raw_obj obj_bucket_instance; + store->get_bucket_instance_obj(bucket, obj_bucket_instance); r = store->system_obj_set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker); if (r < 0) { return r; -- 2.39.5