]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_log, rgw_file: account for new required envvars 20672/head
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 27 Oct 2017 00:31:34 +0000 (20:31 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 1 Mar 2018 16:01:54 +0000 (11:01 -0500)
rgw_log_op() expects more server and request variables from the
request environment.  Fix rgw_lib to set more that it can
usefully, but also make rgw_log_op() check for the existence
of all keys it will use.

Fixes: http://tracker.ceph.com/issues/21942
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit f9d5528a1990b5bcc33948284136c2d349aa838e)

src/rgw/librgw.cc
src/rgw/rgw_log.cc

index 023c3622e264ce92722361da49738de9a6de1ee0..4d7e32aaf4bbde25763e6300dc3593302e90868e 100644 (file)
@@ -246,6 +246,11 @@ namespace rgw {
       goto done;
     }
 
+    /* now expected by rgw_log_op() */
+    rgw_env.set("REQUEST_METHOD", s->info.method);
+    rgw_env.set("REQUEST_URI", s->info.request_uri);
+    rgw_env.set("QUERY_STRING", "");
+
     /* XXX authorize does less here then in the REST path, e.g.,
      * the user's info is cached, but still incomplete */
     req->log(s, "authorizing");
index 2930abb9af8127045532c7b6147ad7c90972c79c..5a28bbccb1fdbc54d2577314d256c1a3a13a8d44 100644 (file)
@@ -357,19 +357,29 @@ int rgw_log_op(RGWRados *store, RGWREST* const rest, struct req_state *s,
   else
     set_param_str(s, "HTTP_REFERER", entry.referrer);
 
-  std::string uri(s->info.env->get("REQUEST_METHOD"));
-  uri.append(" ");
-
-  uri.append(s->info.env->get("REQUEST_URI"));
-  const char* qs = s->info.env->get("QUERY_STRING");
-  if(qs && (*qs != '\0')) {
-    uri.append("?");
-    uri.append(qs);
+  std::string uri;
+  if (s->info.env->exists("REQUEST_METHOD")) {
+    uri.append(s->info.env->get("REQUEST_METHOD"));
+    uri.append(" ");
   }
 
-  uri.append(" ");
-  uri.append("HTTP/");
-  uri.append(s->info.env->get("HTTP_VERSION"));
+  if (s->info.env->exists("REQUEST_URI")) {
+    uri.append(s->info.env->get("REQUEST_URI"));
+  }
+
+  if (s->info.env->exists("QUERY_STRING")) {
+    const char* qs = s->info.env->get("QUERY_STRING");
+    if(qs && (*qs != '\0')) {
+      uri.append("?");
+      uri.append(qs);
+    }
+  }
+
+  if (s->info.env->exists("HTTP_VERSION")) {
+    uri.append(" ");
+    uri.append("HTTP/");
+    uri.append(s->info.env->get("HTTP_VERSION"));
+  }
 
   entry.uri = std::move(uri);