From: Radoslaw Zarzynski Date: Tue, 20 Sep 2016 14:07:39 +0000 (+0200) Subject: rgw: strip the parts state from RGWPostObj_ObjStore. X-Git-Tag: v12.0.3~99^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3439e5f8dca317e32787f54275c82253cece90f7;p=ceph.git rgw: strip the parts state from RGWPostObj_ObjStore. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 7abe148425ee..7d3d321c831a 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -1489,7 +1489,8 @@ int RGWPostObj_ObjStore::read_form_part_header(struct post_form_part* const part return 0; } -bool RGWPostObj_ObjStore::part_str(const std::string& name, +bool RGWPostObj_ObjStore::part_str(parts_collection_t& parts, + const std::string& name, std::string* val) { const auto iter = parts.find(name); @@ -1503,7 +1504,8 @@ bool RGWPostObj_ObjStore::part_str(const std::string& name, return true; } -bool RGWPostObj_ObjStore::part_bl(const std::string& name, +bool RGWPostObj_ObjStore::part_bl(parts_collection_t& parts, + const std::string& name, ceph::bufferlist* pbl) { const auto iter = parts.find(name); diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index 2ce806f2da84..a40a0e80c77f 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -234,9 +234,11 @@ public: }; protected: + using parts_collection_t = \ + std::map; + std::string err_msg; ceph::bufferlist in_data; - std::map parts; int read_with_boundary(ceph::bufferlist& bl, uint64_t max, @@ -256,8 +258,8 @@ protected: int read_form_part_header(struct post_form_part *part, bool *done); - bool part_str(const string& name, string *val); - bool part_bl(const string& name, bufferlist *pbl); + + int get_params() override; static int parse_part_field(const std::string& line, std::string& field_name, /* out */ @@ -266,7 +268,14 @@ protected: static void parse_boundary_params(const std::string& params_str, std::string& first, std::map& params); - int get_params() override; + + static bool part_str(parts_collection_t& parts, + const std::string& name, + std::string *val); + + static bool part_bl(parts_collection_t& parts, + const std::string& name, + ceph::bufferlist *pbl); public: RGWPostObj_ObjStore() {} diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index d2a8850994de..1f1b08e4b59e 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -1577,7 +1577,7 @@ int RGWPostObj_ObjStore_S3::get_params() } while (!done); string object_str; - if (!part_str("key", &object_str)) { + if (!part_str(parts, "key", &object_str)) { err_msg = "Key not specified"; return -EINVAL; } @@ -1593,7 +1593,7 @@ int RGWPostObj_ObjStore_S3::get_params() env.add_var("key", s->object.name); - part_str("Content-Type", &content_type); + part_str(parts, "Content-Type", &content_type); env.add_var("Content-Type", content_type); map::iterator piter = @@ -1644,16 +1644,16 @@ int RGWPostObj_ObjStore_S3::get_params() int RGWPostObj_ObjStore_S3::get_policy() { - if (part_bl("policy", &s->auth.s3_postobj_creds.encoded_policy)) { - + if (part_bl(parts, "policy", &s->auth.s3_postobj_creds.encoded_policy)) { // check that the signature matches the encoded policy - if (! part_str("AWSAccessKeyId", &s->auth.s3_postobj_creds.access_key)) { + if (!part_str(parts, "AWSAccessKeyId", + &s->auth.s3_postobj_creds.access_key)) { ldout(s->cct, 0) << "No S3 access key found!" << dendl; err_msg = "Missing access key"; return -EINVAL; } - string received_signature_str; - if (! part_str("signature", &s->auth.s3_postobj_creds.signature)) { + + if (!part_str(parts, "signature", &s->auth.s3_postobj_creds.signature)) { ldout(s->cct, 0) << "No signature found!" << dendl; err_msg = "Missing signature"; return -EINVAL; @@ -1729,7 +1729,7 @@ int RGWPostObj_ObjStore_S3::get_policy() } string canned_acl; - part_str("acl", &canned_acl); + part_str(parts, "acl", &canned_acl); RGWAccessControlPolicy_S3 s3policy(s->cct); ldout(s->cct, 20) << "canned_acl=" << canned_acl << dendl; @@ -1798,7 +1798,7 @@ void RGWPostObj_ObjStore_S3::send_response() if (op_ret == 0 && parts.count("success_action_redirect")) { string redirect; - part_str("success_action_redirect", &redirect); + part_str(parts, "success_action_redirect", &redirect); string tenant; string bucket; @@ -1848,7 +1848,7 @@ void RGWPostObj_ObjStore_S3::send_response() string status_string; uint32_t status_int; - part_str("success_action_status", &status_string); + part_str(parts, "success_action_status", &status_string); int r = stringtoul(status_string, &status_int); if (r < 0) { diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index af1c6a9f26b8..3b6ead19188a 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -196,7 +196,8 @@ public: }; class RGWPostObj_ObjStore_S3 : public RGWPostObj_ObjStore { - string filename; + parts_collection_t parts; + std::string filename; RGWPolicyEnv env; RGWPolicy post_policy; map crypt_http_responses; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index fe10ac292fd9..5980cc22b097 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -1807,12 +1807,12 @@ int RGWFormPost::get_params() return -EINVAL; } - parts[part.name] = std::move(part); + ctrl_parts[part.name] = std::move(part); } } while (! stream_done); std::string expires; - if (part_str("expires", &expires) && is_expired(expires)) { + if (part_str(ctrl_parts, "expires", &expires) && is_expired(expires)) { err_msg = "FormPost: Form Expired"; return -EACCES; } diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index 333860dd4c78..8ab0e11b882c 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -243,6 +243,7 @@ class RGWFormPost : public RGWPostObj_ObjStore { bool is_next_file_to_upload() override; static bool is_expired(const std::string& expires); + parts_collection_t ctrl_parts; boost::optional current_data_part; std::string prefix; bool stream_done = false;