]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1610207 from trunk resp. r1610340 from 2.4.x:
authorRainer Jung <rjung@apache.org>
Tue, 15 Jul 2014 22:07:19 +0000 (22:07 +0000)
committerRainer Jung <rjung@apache.org>
Tue, 15 Jul 2014 22:07:19 +0000 (22:07 +0000)
Forward local IP address as a custom request attribute
like we already do for the remote port.

Both were forgotten in the original AJP 13 spec
but are needed by the Servlet spec. Until now,
Tomcat simply returns for getLocalAddr() the same as
for getLocalName().

The next round of Tomcat releases will look for the
optional new request attribute.

See also Tomcat BZ 56661.

Submitted by: rjung
Reviewed by: trawick, ylavic

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1610867 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/proxy/ajp_header.c
modules/proxy/ajp_header.h

diff --git a/CHANGES b/CHANGES
index 77b47617f442439ed1b6fa3b355583f8e8f31379..60848d57b37d04505a42d1a60a53b838f2314172 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ Changes with Apache 2.2.28
      Fix a race condition in scoreboard handling, which could lead to
      a heap buffer overflow.  [Joe Orton, Eric Covener, Jeff Trawick]
 
+  *) mod_proxy_ajp: Forward local IP address as a custom request attribute
+     like we already do for the remote port. [Rainer Jung]
+
   *) mod_cache, mod_disk_cache: With CacheLock enabled, responses with a Vary 
      header might not get the benefit of the thundering herd protection due to 
      an incorrect internal cache key.  PR 50317. 
diff --git a/STATUS b/STATUS
index 8b21dd2528203bb95731eadf8761d896f9b45082..138307c076166939bd6534eca64fcab48834bd23 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -110,20 +110,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
      *) mod_dav: Fix improper encoding in PROPFIND responses.  PR 56480.
      +1: breser, rpluem, ylavic
 
-   * mod_proxy_ajp: Forward local IP address as a custom request attribute
-     like we already do for the remote port.
-     Both were forgotten in the original AJP 13 spec
-     but are needed by the Servlet spec. Until now,
-     Tomcat simply returns for getLocalAddr() the same as
-     for getLocalName().
-     The next round of Tomcat releases will look for the
-     optional new request attribute.
-     See also Tomcat BZ 56661.
-     trunk patch: http://svn.apache.org/r1610207
-     2.4.x patch: http://svn.apache.org/r1610340
-     2.2.x patch: http://people.apache.org/~rjung/patches/mod_proxy_ajp_local_addr-2.2.patch
-     +1: rjung, trawick, ylavic
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 72440822378b2bb1314f34210e6614f5ab8f0448..ff9639b2b40942e1d6c9572faedbb2ed2513498a 100644 (file)
@@ -434,6 +434,26 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
             return AJP_EOVERFLOW;
         }
     }
+    /* Forward the local ip address information, which was forgotten
+     * from the builtin data of the AJP 13 protocol.
+     * Since the servlet spec allows to retrieve it via getLocalAddr(),
+     * we provide the address to the Tomcat connector as a request
+     * attribute. Modern Tomcat versions know how to retrieve
+     * the local address from this attribute.
+     */
+    {
+        const char *key = SC_A_REQ_LOCAL_ADDR;
+        char *val = r->connection->local_ip;
+        if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
+            ajp_msg_append_string(msg, key)   ||
+            ajp_msg_append_string(msg, val)) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                    "ajp_marshal_into_msgb: "
+                    "Error appending attribute %s=%s",
+                    key, val);
+            return AJP_EOVERFLOW;
+        }
+    }
     /* Use the environment vars prefixed with AJP_
      * and pass it to the header striping that prefix.
      */
index 158966e89de582304705325163ae5c6b574ecf87..03a7ec3263869bfb9264ccbd715778651a8b4d8d 100644 (file)
  * to contain the forwarded remote port.
  */
 #define SC_A_REQ_REMOTE_PORT    ("AJP_REMOTE_PORT")
+/*
+ * The following request attribute is recognized by Tomcat
+ * to contain the forwarded local ip address.
+ */
+#define SC_A_REQ_LOCAL_ADDR     ("AJP_LOCAL_ADDR")
 
 /*
  * Request methods, coded as numbers instead of strings.