From 462edf385d0c6db49a0bf0ef8432133d7f6c6bb8 Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Thu, 19 Dec 2024 11:54:54 +0000 Subject: [PATCH] rgw/logging: source and log bucket must be different Signed-off-by: Yuval Lifshitz --- doc/radosgw/bucket_logging.rst | 6 ++++++ src/rgw/rgw_rest_bucket_logging.cc | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/doc/radosgw/bucket_logging.rst b/doc/radosgw/bucket_logging.rst index 1ac4e546a4c7a..df469497383d7 100644 --- a/doc/radosgw/bucket_logging.rst +++ b/doc/radosgw/bucket_logging.rst @@ -15,6 +15,12 @@ The log bucket can accumulate logs from multiple buckets. It is recommended to c a different "prefix" for each bucket, so that the logs of different buckets will be stored in different objects in the log bucket. +.. note:: + + - The log bucket must be created before enabling logging on a bucket + - The log bucket cannot be the same as the bucket being logged + - The log bucket cannot have logging enabled on it + .. toctree:: :maxdepth: 1 diff --git a/src/rgw/rgw_rest_bucket_logging.cc b/src/rgw/rgw_rest_bucket_logging.cc index 0e7b53120db73..5689a7acc5687 100644 --- a/src/rgw/rgw_rest_bucket_logging.cc +++ b/src/rgw/rgw_rest_bucket_logging.cc @@ -181,6 +181,11 @@ class RGWPutBucketLoggingOp : public RGWDefaultResponseOp { return; } const rgw_bucket target_bucket_id(target_tenant_name, target_bucket_name); + if (target_bucket_id == src_bucket_id) { + ldpp_dout(this, 1) << "ERROR: target bucket '" << target_bucket_id << "' must be different from source bucket" << dendl; + op_ret = -EINVAL; + return; + } std::unique_ptr target_bucket; op_ret = driver->load_bucket(this, target_bucket_id, &target_bucket, y); -- 2.39.5