From f773c749797635a605807b9a4967406f1a37f2e4 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 12 Dec 2014 17:00:52 -0800 Subject: [PATCH] rgw: cannot modify swift bucket policy When trying to set a policy on the bucket, fail unless policy matches current placement rule. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_op.cc | 7 +++++++ src/rgw/rgw_op.h | 1 + src/rgw/rgw_rest_swift.cc | 1 + 3 files changed, 9 insertions(+) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 35b5c30193f25..a4a23123bc549 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1908,6 +1908,13 @@ void RGWPutMetadata::execute() if (ret < 0) return; + if (!s->object && !placement_rule.empty()) { + if (placement_rule != s->bucket_info.placement_rule) { + ret = -EEXIST; + return; + } + } + /* only remove meta attrs */ for (iter = orig_attrs.begin(); iter != orig_attrs.end(); ++iter) { const string& name = iter->first; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index d3b227e3ebaa1..d818203b59fbb 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -419,6 +419,7 @@ protected: bool has_policy, has_cors; RGWAccessControlPolicy policy; RGWCORSConfiguration cors_config; + string placement_rule; public: RGWPutMetadata() { diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 6122e2611e85c..0b1d31c8ffc0b 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -441,6 +441,7 @@ int RGWPutMetadata_ObjStore_SWIFT::get_params() return r; } } + placement_rule = s->info.env->get("HTTP_X_STORAGE_POLICY", ""); return 0; } -- 2.39.5