]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: strip the parts state from RGWPostObj_ObjStore.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 20 Sep 2016 14:07:39 +0000 (16:07 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 24 Apr 2017 15:32:14 +0000 (17:32 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_rest_swift.h

index 7abe148425eea74a201fc8518079bb4795d89be3..7d3d321c831a43fc61734fea780acba6017a052b 100644 (file)
@@ -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);
index 2ce806f2da840d8b98cab5cdedfb132655e94219..a40a0e80c77f2e1b0f2d0064bb403169a971dec7 100644 (file)
@@ -234,9 +234,11 @@ public:
   };
 
 protected:
+  using parts_collection_t = \
+    std::map<std::string, post_form_part, const ltstr_nocase>;
+
   std::string err_msg;
   ceph::bufferlist in_data;
-  std::map<std::string, post_form_part, const ltstr_nocase> 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<std::string, std::string>& 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() {}
index d2a8850994def2eda2cffb09c44df5728398a6ca..1f1b08e4b59ed477fb13d596f6dae302edff936c 100644 (file)
@@ -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<string, struct post_form_part, ltstr_nocase>::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) {
index af1c6a9f26b8c907d1272a76f8b7cf06a6f437dd..3b6ead19188a3b3969b8813a67a327f70d51f427 100644 (file)
@@ -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<string, string> crypt_http_responses;
index fe10ac292fd9ab5c25135e3b0a62a25bc4c53ee5..5980cc22b097caae4e054fa890b943cbabab6edf 100644 (file)
@@ -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;
   }
index 333860dd4c7894c92387fbf67601453cbe893f5c..8ab0e11b882cd08231e8142f9596346be3c13bd8 100644 (file)
@@ -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<post_form_part> current_data_part;
   std::string prefix;
   bool stream_done = false;