]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: s3website error handler uses original object name 21100/head
authorCasey Bodley <cbodley@redhat.com>
Fri, 2 Mar 2018 19:22:30 +0000 (14:22 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 28 Mar 2018 17:28:02 +0000 (13:28 -0400)
the s3website error handler needs to use the same object name for
redirect handling that retarget() does, but s->object.name may be
modified based on get_effective_key()

Fixes: http://tracker.ceph.com/issues/23201
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 8f7cbbce26c7fbccb7e9ae46040f3472d8762a88)

Conflicts:
src/rgw/rgw_rest_s3.cc (auth rework)
src/rgw/rgw_rest_s3website.h (frontend rework)

src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3website.h

index 13168ee59828f059cf2234396918e1372231ae1d..ad574c0e79a33995a153453b70517de4e125baef 100644 (file)
@@ -4326,6 +4326,17 @@ bool RGWHandler_REST_S3Website::web_dir() const {
   return state->exists;
 }
 
+int RGWHandler_REST_S3Website::init(RGWRados *store, req_state *s,
+                                    RGWClientIO* cio)
+{
+  // save the original object name before retarget() replaces it with the
+  // result of get_effective_key(). the error_handler() needs the original
+  // object name for redirect handling
+  original_object_name = s->object.name;
+
+  return RGWHandler_REST_S3::init(store, s, cio);
+}
+
 int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op) {
   *new_op = op;
   ldout(s->cct, 10) << __func__ << "Starting retarget" << dendl;
@@ -4475,16 +4486,16 @@ int RGWHandler_REST_S3Website::error_handler(int err_no,
 
   RGWBWRoutingRule rrule;
   bool should_redirect =
-    s->bucket_info.website_conf.should_redirect(s->object.name, http_error_code,
-                                               &rrule);
+    s->bucket_info.website_conf.should_redirect(original_object_name,
+                                                http_error_code, &rrule);
 
   if (should_redirect) {
     const string& hostname = s->info.env->get("HTTP_HOST", "");
     const string& protocol =
       (s->info.env->get("SERVER_PORT_SECURE") ? "https" : "http");
     int redirect_code = 0;
-    rrule.apply_rule(protocol, hostname, s->object.name, &s->redirect,
-                   &redirect_code);
+    rrule.apply_rule(protocol, hostname, original_object_name,
+                     &s->redirect, &redirect_code);
     // Apply a custom HTTP response code
     if (redirect_code > 0)
       s->err.http_ret = redirect_code; // Apply a custom HTTP response code
index 29643aa4b0d9afc495daae4efcc496a595c982e1..7f42656875ca0678a779bae5d4fe5cbf64c94562 100644 (file)
@@ -17,6 +17,7 @@
 #include "rgw_rest_s3.h"
 
 class RGWHandler_REST_S3Website : public RGWHandler_REST_S3 {
+  std::string original_object_name; // object name before retarget()
   bool web_dir() const;
 protected:
   int retarget(RGWOp *op, RGWOp **new_op);
@@ -37,6 +38,7 @@ protected:
 public:
   RGWHandler_REST_S3Website() : RGWHandler_REST_S3() {}
   virtual ~RGWHandler_REST_S3Website() {}
+  int init(RGWRados *store, req_state *s, RGWClientIO* cio) override;
   virtual int error_handler(int err_no, string *error_content);
 };