]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw:bucket link now set the bucket.instance acl 8583/head
authorAran85 <zhangzengran@h3c.com>
Mon, 28 Sep 2015 00:23:22 +0000 (08:23 +0800)
committerVicente Cheng <freeze.bilsted@gmail.com>
Wed, 13 Apr 2016 15:01:57 +0000 (23:01 +0800)
Fixes: #11076
Signed-off-by: Zengran Zhang <zhangzengran@h3c.com>
(cherry picked from commit 4d59b1d36f8924290c3ecb5b7608747191470188)

Conflicts:

src/rgw/rgw_bucket.cc
            1. Do not use the rgw_user structure and remove the tenant parameter that describes as below
            2. user_id is not used so just remove the line
            3. instead of system_obj_set_attr you can use the method set_attr

Backport Change:
We do not use the rgw_user structure and remove the `tenant` parameter
because this feature is not introduced on hammer version.
The rgw multi-tenant feature is introduced on pr#6784 (https://github.com/ceph/ceph/pull/6784)
This feature is supported from v10.0.2 and later version.

src/rgw/rgw_bucket.cc

index 5d2af38ea6fb1995cb68647913797402f2c5fca9..1926b0a66ed447f3f0ae96feb55fb8f4e53c6327 100644 (file)
@@ -138,9 +138,6 @@ int rgw_link_bucket(RGWRados *store, string user_id, rgw_bucket& bucket, time_t
     ret = store->get_bucket_entrypoint_info(obj_ctx, bucket_name, ep, &ot, NULL, &attrs);
     if (ret < 0 && ret != -ENOENT) {
       ldout(store->ctx(), 0) << "ERROR: store->get_bucket_entrypoint_info() returned " << ret << dendl;
-    } else if (ret >= 0 && ep.linked && ep.owner != user_id) {
-      ldout(store->ctx(), 0) << "can't link bucket, already linked to a different user: " << ep.owner << dendl;
-      return -EINVAL;
     }
   }
 
@@ -542,7 +539,7 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg)
       return -EIO;
     }
 
-    r = rgw_unlink_bucket(store, owner.get_id(), bucket.name);
+    r = rgw_unlink_bucket(store, owner.get_id(), bucket.name, false);
     if (r < 0) {
       set_err_msg(err_msg, "could not unlink policy from user " + owner.get_id());
       return r;
@@ -569,6 +566,17 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg)
     if (r < 0)
       return r;
 
+    RGWAccessControlPolicy policy_instance;
+    policy_instance.create_default(user_info.user_id, display_name);
+    aclbl.clear();
+    policy_instance.encode(aclbl);
+
+    string oid_bucket_instance = RGW_BUCKET_INSTANCE_MD_PREFIX + key;
+    rgw_bucket bucket_instance;
+    bucket_instance.name = oid_bucket_instance;
+    rgw_obj obj_bucket_instance(bucket_instance, no_oid);
+    r = store->set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker);
+
     r = rgw_link_bucket(store, user_info.user_id, bucket, 0);
     if (r < 0)
       return r;