]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix checking index_doc_suffix when getting effective key 28904/head
authorEnming Zhang <enming.zhang@umcloud.com>
Wed, 10 Jul 2019 07:48:57 +0000 (00:48 -0700)
committerEnming Zhang <enming.zhang@umcloud.com>
Wed, 10 Jul 2019 08:19:02 +0000 (01:19 -0700)
Currently, if the index_doc_suffix is empty which is leaded
by the IndexDocument field is not configurated or is set to
empty string during enabling bucket website function, the
rgw will crash when accessing the static website through the
S3Website enabled RGW instance.

In actually, we have add the necessary checking in the commit
355f392ad26631f44dac250296e96f421d86fb8f, but double checking
in here is better.

Signed-off-by: Enming Zhang <enming.zhang@umcloud.com>
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_website.cc
src/rgw/rgw_website.h

index 42983890eab2f6a8cad56398ab8031caf70ca128..a4c6fd38c0754ccc24d117ad51408adf069ee4b0 100644 (file)
@@ -4186,7 +4186,13 @@ int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op) {
   }
 
   rgw_obj_key new_obj;
-  s->bucket_info.website_conf.get_effective_key(s->object.name, &new_obj.name, web_dir());
+  bool get_res = s->bucket_info.website_conf.get_effective_key(s->object.name, &new_obj.name, web_dir());
+  if (!get_res) {
+    s->err.message = "The IndexDocument Suffix is not configurated or not well formed!";
+    ldpp_dout(s, 5) << s->err.message << dendl;
+    return -EINVAL;
+  }
+
   ldpp_dout(s, 10) << "retarget get_effective_key " << s->object << " -> "
                    << new_obj << dendl;
 
index a546b349fc734961c20b6afa5fbff46e0b276c19..13a3b1de9e36c137f9209d07163ad9c282b715cb 100644 (file)
@@ -107,8 +107,11 @@ bool RGWBucketWebsiteConf::should_redirect(const string& key, const int http_err
   return true;
 }
 
-void RGWBucketWebsiteConf::get_effective_key(const string& key, string *effective_key, bool is_file) const
+bool RGWBucketWebsiteConf::get_effective_key(const string& key, string *effective_key, bool is_file) const
 {
+  if (index_doc_suffix.empty()) {
+    return false;
+  }
 
   if (key.empty()) {
     *effective_key = index_doc_suffix;
@@ -119,4 +122,6 @@ void RGWBucketWebsiteConf::get_effective_key(const string& key, string *effectiv
   } else {
     *effective_key = key;
   }
+
+  return true;
 }
index b423b630c34ef7f52e4e5835e68ee492c612b7ae..8366f39c02c69793fc94ae91eacb114224384214 100644 (file)
@@ -226,7 +226,7 @@ struct RGWBucketWebsiteConf
                        const int http_error_code,
                        RGWBWRoutingRule *redirect);
 
-  void get_effective_key(const std::string& key,
+  bool get_effective_key(const std::string& key,
                          std::string *effective_key, bool is_file) const;
 
   const std::string& get_index_doc() const {