]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use effective owner in PutBucketReplication 59913/head
authorSeena Fallah <seenafallah@gmail.com>
Fri, 20 Sep 2024 23:09:18 +0000 (01:09 +0200)
committerSeena Fallah <seenafallah@gmail.com>
Tue, 7 Jan 2025 19:40:35 +0000 (20:40 +0100)
As PutBucketReplication requests are forwarded to the master, it
needs to use the effective owner to set the correct (client) as the
uid for sync pipe rather than the system user.

sync policies require a valid UID for authorization when operating in
rgw_sync_pipe_params::Mode::MODE_USER mode. Currently, when forwarding
requests to the master, rgwx-uid holds the ACLOwner string rather than
a UID, which can't be used for sync policy checks. Until this is
properly implemented, we are rejecting PutBucketReplication calls for
account holders.

Fixes: https://tracker.ceph.com/issues/68172
Signed-off-by: Seena Fallah <seenafallah@gmail.com>
src/rgw/rgw_rest_s3.cc

index 30ebe8e8965c38b82e4dcad4d878e380c8c30a52..5e1275950fef4364de5db4ae4274e2d589907cb6 100644 (file)
@@ -1303,12 +1303,19 @@ struct ReplicationConfiguration {
         return -EINVAL;
       }
 
+      if (!std::holds_alternative<rgw_user>(s->owner.id)) {
+        // Currently, replication configuration is only supported for rgw_user
+        ldpp_dout(s, 1) << "NOTICE: replication configuration is only supported for rgw_user" << dendl;
+        return -ERR_NOT_IMPLEMENTED;
+      }
+
       pipe->id = id;
       pipe->params.priority = priority;
 
-      const auto& user_id = s->user->get_id();
+      // Here we are sure that s->owner.id is of type rgw_user
+      const auto& tenant_owner = std::get_if<rgw_user>(&s->owner.id)->tenant;
 
-      rgw_bucket_key dest_bk(user_id.tenant,
+      rgw_bucket_key dest_bk(tenant_owner,
                              destination.bucket);
 
       if (source && !source->zone_names.empty()) {
@@ -1331,7 +1338,7 @@ struct ReplicationConfiguration {
       }
       if (destination.acl_translation) {
         rgw_user u;
-        u.tenant = user_id.tenant;
+        u.tenant = tenant_owner;
         u.from_str(destination.acl_translation->owner); /* explicit tenant will override tenant,
                                                            otherwise will inherit it from s->user */
         pipe->params.dest.acl_translation.emplace();
@@ -1342,7 +1349,7 @@ struct ReplicationConfiguration {
       *enabled = (status == "Enabled");
 
       pipe->params.mode = rgw_sync_pipe_params::Mode::MODE_USER;
-      pipe->params.user = user_id.to_str();
+      pipe->params.user = to_string(s->owner.id);
 
       return 0;
     }