]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: zonegroup and zone should not be accessed directly
authorOrit Wasserman <owasserm@redhat.com>
Mon, 19 Oct 2015 09:06:56 +0000 (11:06 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:15 +0000 (16:13 -0800)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
src/rgw/rgw_main.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_user.cc

index a8353170d553ada0a347f5d4d83ae08bf8fb7a99..22db78e57d116ab465f8f19c0816d23a61cd2e22 100644 (file)
@@ -1128,7 +1128,7 @@ int main(int argc, const char **argv)
   }
   r = rgw_perf_start(g_ceph_context);
 
-  rgw_rest_init(g_ceph_context, store, store->zonegroup);
+  rgw_rest_init(g_ceph_context, store, store->get_zonegroup());
 
   mutex.Lock();
   init_timer.cancel_all_events();
index 3dab71332c172f0ed02e16015c4d93b96cfbbf48..4e026f9014f4f840615a0ec0e60b178865080b6e 100644 (file)
@@ -376,7 +376,7 @@ static int rgw_build_bucket_policies(RGWRados *store, struct req_state *s)
     }
     if (ret == 0) {
       string& zonegroup = source_info.zonegroup;
-      s->local_source = store->zonegroup.equals(zonegroup);
+      s->local_source = store->get_zonegroup().equals(zonegroup);
     }
   }
 
@@ -414,12 +414,12 @@ static int rgw_build_bucket_policies(RGWRados *store, struct req_state *s)
       s->zonegroup_endpoint = zonegroup.endpoints.front();
     }
 
-    if (s->bucket_exists && !store->zonegroup.equals(s->bucket_info.zonegroup)) {
-      ldout(s->cct, 0) << "NOTICE: request for data in a different zonegroup (" << s->bucket_info.zonegroup << " != " << store->zonegroup.get_name() << ")" << dendl;
+    if (s->bucket_exists && !store->get_zonegroup().equals(s->bucket_info.zonegroup)) {
+      ldout(s->cct, 0) << "NOTICE: request for data in a different zonegroup (" << s->bucket_info.zonegroup << " != " << store->get_zonegroup().get_name() << ")" << dendl;
       /* we now need to make sure that the operation actually requires copy source, that is
        * it's a copy operation
        */
-      if (store->zonegroup.is_master && s->op == OP_DELETE && s->system_request) {
+      if (store->get_zonegroup().is_master && s->op == OP_DELETE && s->system_request) {
         /*If the operation is delete and if this is the master, don't redirect*/
       } else if (!s->local_source ||
           (s->op != OP_PUT && s->op != OP_COPY) ||
@@ -491,7 +491,7 @@ int RGWOp::verify_op_mask()
     return -EPERM;
   }
 
-  if (!s->system_request && (required_mask & RGW_OP_TYPE_MODIFY) && store->zonegroup.master_zone
+  if (!s->system_request && (required_mask & RGW_OP_TYPE_MODIFY) && store->get_zonegroup().master_zone
       != store->zone.get_id())  {
     ldout(s->cct, 5) << "NOTICE: modify request to a non-master zone by a non-system user, permission denied"  << dendl;
     return -EPERM;
@@ -1720,9 +1720,9 @@ void RGWCreateBucket::execute()
   if (op_ret < 0)
     return;
 
-  if (!store->zonegroup.is_master &&
-      store->zonegroup.api_name != location_constraint) {
-    ldout(s->cct, 0) << "location constraint (" << location_constraint << ") doesn't match zonegroup" << " (" << store->zonegroup.api_name << ")" << dendl;
+  if (!store->get_zonegroup().is_master &&
+      store->get_zonegroup().api_name != location_constraint) {
+    ldout(s->cct, 0) << "location constraint (" << location_constraint << ") doesn't match zonegroup" << " (" << store->get_zonegroup().api_name << ")" << dendl;
     op_ret = -EINVAL;
     return;
   }
@@ -1752,7 +1752,7 @@ void RGWCreateBucket::execute()
   rgw_bucket *pmaster_bucket;
   time_t creation_time;
 
-  if (!store->zonegroup.is_master) {
+  if (!store->get_zonegroup().is_master) {
     JSONParser jp;
     op_ret = forward_request_to_master(s, NULL, store, in_data, &jp);
     if (op_ret < 0)
@@ -1776,10 +1776,10 @@ void RGWCreateBucket::execute()
   if (s->system_request) {
     zonegroup_id = s->info.args.get(RGW_SYS_PARAM_PREFIX "zonegroup");
     if (zonegroup_id.empty()) {
-      zonegroup_id = store->zonegroup.get_id();
+      zonegroup_id = store->get_zonegroup().get_id();
     }
   } else {
-    zonegroup_id = store->zonegroup.get_id();
+    zonegroup_id = store->get_zonegroup().get_id();
   }
 
   if (s->bucket_exists) {
@@ -1900,7 +1900,7 @@ void RGWDeleteBucket::execute()
     return;
   }
 
-  if (!store->zonegroup.is_master) {
+  if (!store->get_zonegroup().is_master) {
     bufferlist in_data;
     JSONParser jp;
     op_ret = forward_request_to_master(s, &ot.read_version, store, in_data,
index 46ddd3e61ad8ff79109b19e859bd388e5c551c61..579d75fa94943f411127c195c3d259537788d79d 100644 (file)
@@ -1763,6 +1763,9 @@ protected:
 
   Finisher *finisher;
 
+  RGWZoneGroup zonegroup;
+  RGWZone zone_public_config; /* external zone params, e.g., entrypoints, log flags, etc. */
+
 public:
   RGWRados() : max_req_id(0), lock("rados_timer_lock"), watchers_lock("watchers_lock"), timer(NULL),
                gc(NULL), obj_expirer(NULL), use_gc_thread(false), quota_threads(false),
@@ -1807,15 +1810,15 @@ public:
   string host_id;
 
   RGWRealm realm;
-  RGWZoneGroup zonegroup;
   RGWZoneParams zone; /* internal zone params, e.g., rados pools */
-  RGWZone zone_public_config; /* external zone params, e.g., entrypoints, log flags, etc. */
   RGWZoneGroupMap zonegroup_map;
   RGWRESTConn *rest_master_conn;
   map<string, RGWRESTConn *> zone_conn_map;
   map<string, RGWRESTConn *> zonegroup_conn_map;
 
   RGWZoneParams& get_zone_params() { return zone; }
+  RGWZoneGroup& get_zonegroup() { return zonegroup;}
+  RGWZone& get_zone() { return zone_public_config;}
 
   RGWMetadataManager *meta_mgr;
 
index 65fd9d01731e9afd5c82c9a07dd53a562b90d5f2..1ab561e9cb7cc08b1d6013b87bb368828ccf8875 100644 (file)
@@ -14,7 +14,7 @@ RGWRESTConn::RGWRESTConn(CephContext *_cct, RGWRados *store, const list<string>&
     endpoints[i] = *iter;
   }
   key = store->zone.system_key;
-  zone_group = store->zonegroup.get_id();
+  zone_group = store->get_zonegroup().get_id();
 }
 
 int RGWRESTConn::get_url(string& endpoint)
index 545d1660a3fc0432572d8f169e69f23b29a370de..45e915f1dd9913fe006cc304847e29d45aeace97 100644 (file)
@@ -459,7 +459,7 @@ int RGWCreateBucket_ObjStore_SWIFT::get_params()
     policy.create_default(s->user.user_id, s->user.display_name);
   }
 
-  location_constraint = store->zonegroup.api_name;
+  location_constraint = store->get_zonegroup().api_name;
   placement_rule = s->info.env->get("HTTP_X_STORAGE_POLICY", "");
 
   return 0;
index 876b36ab15f030c972cb8f0d558298589632ce5d..72e4768d616c3304f0c97ffbec19fa916326a93e 100644 (file)
@@ -167,7 +167,7 @@ int rgw_store_user_info(RGWRados *store,
   if (!info.user_email.empty()) {
     if (!old_info ||
         old_info->user_email.compare(info.user_email) != 0) { /* only if new index changed */
-      ret = rgw_put_system_obj(store, store->zone.user_email_pool, info.user_email,
+      ret = rgw_put_system_obj(store, store->get_zone_params().user_email_pool, info.user_email,
                                link_bl.c_str(), link_bl.length(), exclusive, NULL, 0);
       if (ret < 0)
         return ret;
@@ -181,7 +181,7 @@ int rgw_store_user_info(RGWRados *store,
       if (old_info && old_info->access_keys.count(iter->first) != 0)
        continue;
 
-      ret = rgw_put_system_obj(store, store->zone.user_keys_pool, k.id,
+      ret = rgw_put_system_obj(store, store->get_zone_params().user_keys_pool, k.id,
                                link_bl.c_str(), link_bl.length(), exclusive,
                                NULL, 0);
       if (ret < 0)
@@ -309,7 +309,7 @@ int rgw_get_user_info_by_uid(RGWRados *store,
 int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info,
                                RGWObjVersionTracker *objv_tracker, time_t *pmtime)
 {
-  return rgw_get_user_info_from_index(store, email, store->zone.user_email_pool, info, objv_tracker, pmtime);
+  return rgw_get_user_info_from_index(store, email, store->get_zone_params().user_email_pool, info, objv_tracker, pmtime);
 }
 
 /**
@@ -319,7 +319,7 @@ int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info
 extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUserInfo& info,
                                       RGWObjVersionTracker *objv_tracker, time_t *pmtime)
 {
-  return rgw_get_user_info_from_index(store, swift_name, store->zone.user_swift_pool, info, objv_tracker, pmtime);
+  return rgw_get_user_info_from_index(store, swift_name, store->get_zone_params().user_swift_pool, info, objv_tracker, pmtime);
 }
 
 /**
@@ -329,7 +329,7 @@ extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUs
 extern int rgw_get_user_info_by_access_key(RGWRados *store, string& access_key, RGWUserInfo& info,
                                            RGWObjVersionTracker *objv_tracker, time_t *pmtime)
 {
-  return rgw_get_user_info_from_index(store, access_key, store->zone.user_keys_pool, info, objv_tracker, pmtime);
+  return rgw_get_user_info_from_index(store, access_key, store->get_zone_params().user_keys_pool, info, objv_tracker, pmtime);
 }
 
 int rgw_get_user_attrs_by_uid(RGWRados *store,