From: Orit Wasserman Date: Mon, 19 Oct 2015 09:06:56 +0000 (+0200) Subject: rgw: zonegroup and zone should not be accessed directly X-Git-Tag: v10.1.0~354^2~335 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4733ccba0b6f73ef63a2454f747f726e43a836d3;p=ceph.git rgw: zonegroup and zone should not be accessed directly Signed-off-by: Orit Wasserman --- diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index a8353170d553..22db78e57d11 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -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(); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 3dab71332c17..4e026f9014f4 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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, diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 46ddd3e61ad8..579d75fa9494 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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 zone_conn_map; map zonegroup_conn_map; RGWZoneParams& get_zone_params() { return zone; } + RGWZoneGroup& get_zonegroup() { return zonegroup;} + RGWZone& get_zone() { return zone_public_config;} RGWMetadataManager *meta_mgr; diff --git a/src/rgw/rgw_rest_conn.cc b/src/rgw/rgw_rest_conn.cc index 65fd9d01731e..1ab561e9cb7c 100644 --- a/src/rgw/rgw_rest_conn.cc +++ b/src/rgw/rgw_rest_conn.cc @@ -14,7 +14,7 @@ RGWRESTConn::RGWRESTConn(CephContext *_cct, RGWRados *store, const list& 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) diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 545d1660a3fc..45e915f1dd99 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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; diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 876b36ab15f0..72e4768d616c 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -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,