]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: cannot modify swift bucket policy 2970/head
authorYehuda Sadeh <yehuda@redhat.com>
Sat, 13 Dec 2014 01:00:52 +0000 (17:00 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Sat, 13 Dec 2014 01:00:52 +0000 (17:00 -0800)
When trying to set a policy on the bucket, fail unless policy matches
current placement rule.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_swift.cc

index 35b5c30193f25398c9255dcd16486b65fbd0e7e5..a4a23123bc5496ebb49e2daf917c2d2a61f577b0 100644 (file)
@@ -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;
index d3b227e3ebaa1f3bd3f663fbec4ec6edd10c8431..d818203b59fbbc7acd599f7352c96e8159084b10 100644 (file)
@@ -419,6 +419,7 @@ protected:
   bool has_policy, has_cors;
   RGWAccessControlPolicy policy;
   RGWCORSConfiguration cors_config;
+  string placement_rule;
 
 public:
   RGWPutMetadata() {
index 6122e2611e85c890642bb87590ff928891839eef..0b1d31c8ffc0b7b7927623c70c1e0b2d1adc4daa 100644 (file)
@@ -441,6 +441,7 @@ int RGWPutMetadata_ObjStore_SWIFT::get_params()
       return r;
     }
   }
+  placement_rule = s->info.env->get("HTTP_X_STORAGE_POLICY", "");
 
   return 0;
 }