]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: deny writes to a secondary zone by non-system users
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 5 Nov 2013 22:54:20 +0000 (14:54 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Thu, 7 Nov 2013 17:17:22 +0000 (09:17 -0800)
Fixes: #6678
We don't want to allow regular users to write to secondary zones,
otherwise we'd end up with data inconsistencies.

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index c750276596f8327765273b4f310cb2b396b18268..bd73a239a4bf1fbfe253e651f07bc3857a91a015 100644 (file)
@@ -418,6 +418,11 @@ int RGWOp::verify_op_mask()
     return -EPERM;
   }
 
+  if (!s->system_request && (required_mask & RGW_OP_TYPE_MODIFY) && !store->zone.is_master)  {
+    ldout(s->cct, 5) << "NOTICE: modify request to a non-master zone by a non-system user, permission denied"  << dendl;
+    return -EPERM;
+  }
+
   return 0;
 }
 
index 4d6f8ef45301ad21d16c8a4fbb5c62a3f511a871..55d4b92bcbdb00b24b60d6c059671c4baba65f17 100644 (file)
@@ -362,6 +362,10 @@ int RGWZoneParams::init(CephContext *cct, RGWRados *store, RGWRegion& region)
     return -EIO;
   }
 
+  is_master = (name == region.master_zone) || (region.master_zone.empty() && name == "default");
+
+  ldout(cct, 2) << "zone " << name << " is " << (is_master ? "" : "NOT ") << "master" << dendl;
+
   return 0;
 }
 
index 874492ffe692da7e6a0477246f160458482d879f..476572ce3f6c9c69a6de74aae3d8ad4522d68b1c 100644 (file)
@@ -428,11 +428,14 @@ struct RGWZoneParams {
   rgw_bucket user_uid_pool;
 
   string name;
+  bool is_master;
 
   RGWAccessKey system_key;
 
   map<string, RGWZonePlacementInfo> placement_pools;
 
+  RGWZoneParams() : is_master(false) {}
+
   static int get_pool_name(CephContext *cct, string *pool_name);
   void init_name(CephContext *cct, RGWRegion& region);
   int init(CephContext *cct, RGWRados *store, RGWRegion& region);