]> granicus.if.org Git - apache/commitdiff
Merge r1729930, r1729931 from trunk:
authorJim Jagielski <jim@apache.org>
Wed, 2 Mar 2016 13:22:07 +0000 (13:22 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 2 Mar 2016 13:22:07 +0000 (13:22 +0000)
hostname: Test and log useragent_host per-request across various modules,
including the scoreboard, expression and rewrite engines, setenvif,
authz_host, access_compat, custom logging, ssl and REMOTE_HOST variables.
PR55348  [William Rowe]

This is the complete change set which applies cleanly to 2.4.x as well,
the server/scoreboard.c will follow, which does not apply due to drift.

A rather ugly patch since the code was refactored recently to exclude
the simple patch for 2.4.x, illustrated below.

Completes the changeset r1729930 and resolves all 2.4.19-dev corrections,
but other 2.5.0-dev specific changes may still be needed on trunk.

--- server/scoreboard.c (revision 1729907)
+++ server/scoreboard.c (working copy)
@@ -491,9 +491,8 @@
             ws->conn_bytes = 0;
         }
         if (r) {
-            const char *client = ap_get_remote_host(c, r->per_dir_config,
-                                 REMOTE_NOLOOKUP, NULL);
-            if (!client || !strcmp(client, c->client_ip)) {
+            const char *client;
+            if (!(client = ap_get_useragent_host(r, REMOTE_NOLOOKUP, NULL))) {
                 apr_cpystrn(ws->client, r->useragent_ip, sizeof(ws->client));
             }
             else {

Submitted by: wrowe
Reviewed/backported by: jim

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

12 files changed:
CHANGES
STATUS
modules/aaa/mod_access_compat.c
modules/aaa/mod_authz_host.c
modules/arch/netware/mod_nw_ssl.c
modules/mappers/mod_rewrite.c
modules/metadata/mod_setenvif.c
modules/proxy/ajp_header.c
modules/ssl/ssl_engine_vars.c
server/scoreboard.c
server/util_expr_eval.c
server/util_script.c

diff --git a/CHANGES b/CHANGES
index 49f74c70a2096265d240df74e00105f56f76fdc3..d92c65a6f1239ad0fb8869f8238e3e4bdb5c18b9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,11 @@
 
 Changes with Apache 2.4.19
 
+  *) hostname: Test and log useragent_host per-request across various modules,
+     including the scoreboard, expression and rewrite engines, setenvif,
+     authz_host, access_compat, custom logging, ssl and REMOTE_HOST variables.
+     PR55348  [William Rowe]
   *) core: Track the useragent_host per-request when mod_remoteip or similar
      modules track a per-request useragent_ip.  Modules should be updated
      to inquire for ap_get_useragent_host() in place of ap_get_remote_host().
diff --git a/STATUS b/STATUS
index 2dfe74ca2e54e15d1826f72343aaf7a258eecdb0..b58ebad882d4008929c7963a026349c686505655 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -112,17 +112,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) hostname: Test and log useragent_host per-request across various modules,
-     including the scoreboard, expression and rewrite engines, setenvif,
-     authz_host, access_compat, custom logging, ssl and REMOTE_HOST variables.
-     PR55348  [William Rowe]
-     Trunk version of patch:
-         http://svn.apache.org/r1729930
-         http://svn.apache.org/r1729931
-     Trunk patch r1729930 applies, modulo CHANGES
-     Backport patch to r1729931 is noted in the commit log message
-     Requires r1729929 to be applied.
-     +1: wrowe, ylavic, icing
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
index 46d8da0e53b911f238007d54fa00cb77dc3dc0b4..30238033c99057ee055e4f2410c6f9806df77ddd 100644 (file)
@@ -276,10 +276,8 @@ static int find_allowdeny(request_rec *r, apr_array_header_t *a, int method)
             if (!gothost) {
                 int remotehost_is_ip;
 
-                remotehost = ap_get_remote_host(r->connection,
-                                                r->per_dir_config,
-                                                REMOTE_DOUBLE_REV,
-                                                &remotehost_is_ip);
+                remotehost = ap_get_useragent_host(r, REMOTE_DOUBLE_REV,
+                                                   &remotehost_is_ip);
 
                 if ((remotehost == NULL) || remotehost_is_ip) {
                     gothost = 1;
index 83fc6e6c71a3faace71b33c0355e8c46b64bd07d..dc1a73e8545b9484fcfd3b44a3483ec1b448a6db 100644 (file)
@@ -168,10 +168,7 @@ static authz_status host_check_authorization(request_rec *r,
     const char *remotehost = NULL;
     int remotehost_is_ip;
 
-    remotehost = ap_get_remote_host(r->connection,
-                                    r->per_dir_config,
-                                    REMOTE_DOUBLE_REV,
-                                    &remotehost_is_ip);
+    remotehost = ap_get_useragent_host(r, REMOTE_DOUBLE_REV, &remotehost_is_ip);
 
     if ((remotehost == NULL) || remotehost_is_ip) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01753)
index 8e392a7f01c1840cfd0955196bff7e454c0dd1da..fc8af9889e0836ffe5ad27f9df22726f3c135963 100644 (file)
@@ -1020,8 +1020,7 @@ char *ssl_var_lookup(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r,
             else if (strcEQ(var, "REMOTE_ADDR"))
                 result = r->useragent_ip;
             else if (strcEQ(var, "REMOTE_HOST"))
-                result = ap_get_remote_host(r->connection, r->per_dir_config,
-                                            REMOTE_NAME, NULL);
+                result = ap_get_useragent_host(r, REMOTE_NAME, NULL);
             else if (strcEQ(var, "REMOTE_IDENT"))
                 result = ap_get_remote_logname(r);
             else if (strcEQ(var, "REMOTE_USER"))
index 5593d82f1fd5983f5b273322f6976192dfc36d4a..ddc2904b7ff0e4363d01c117992242c4b9d15932 100644 (file)
@@ -443,8 +443,7 @@ static void do_rewritelog(request_rec *r, int level, char *perdir,
     if (!APLOG_R_IS_LEVEL(r, APLOG_DEBUG + level))
         return;
 
-    rhost = ap_get_remote_host(r->connection, r->per_dir_config,
-                               REMOTE_NOLOOKUP, NULL);
+    rhost = ap_get_useragent_host(r, REMOTE_NOLOOKUP, NULL);
     rname = ap_get_remote_logname(r);
 
     for (redir=0, req=r; req->prev; req = req->prev) {
index db58b601f3a0f60283d0073f0efa1f3fe942f542..c56ef503187723f558325fa4cb0843d0912a02be 100644 (file)
@@ -531,8 +531,7 @@ static int match_headers(request_rec *r)
                     val = r->connection->local_ip;
                     break;
                 case SPECIAL_REMOTE_HOST:
-                    val =  ap_get_remote_host(r->connection, r->per_dir_config,
-                                              REMOTE_NAME, NULL);
+                    val = ap_get_useragent_host(r, REMOTE_NAME, NULL);
                     break;
                 case SPECIAL_REQUEST_URI:
                     val = r->uri;
index 74ae09ade9ae7be8e74d7980e185a5bd5260fb42..67353a70e4cf1baa0469370bd4c3fc411bd70877 100644 (file)
@@ -239,7 +239,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
         num_headers = t->nelts;
     }
 
-    remote_host = (char *)ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_HOST, NULL);
+    remote_host = (char *)ap_get_useragent_host(r, REMOTE_HOST, NULL);
 
     ajp_msg_reset(msg);
 
index a6b0d0da1563e119e02d70fedad68805ef3663cd..093a69bed3b2567ba3ef19098f5d20a4e485132e 100644 (file)
@@ -221,8 +221,7 @@ char *ssl_var_lookup(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r,
             else if (strcEQ(var, "REMOTE_ADDR"))
                 result = r->useragent_ip;
             else if (strcEQ(var, "REMOTE_HOST"))
-                result = ap_get_remote_host(r->connection, r->per_dir_config,
-                                            REMOTE_NAME, NULL);
+                result = ap_get_useragent_host(r, REMOTE_NAME, NULL);
             else if (strcEQ(var, "REMOTE_IDENT"))
                 result = ap_get_remote_logname(r);
             else if (strcEQ(var, "REMOTE_USER"))
index 8040fc6a833e6b911464e07cf8e781fd179ad202..7dc6ae25a6ca030f5f9cf61ffb3c13b04a46e0bc 100644 (file)
@@ -510,15 +510,18 @@ static int update_child_status_internal(int child_num,
             else if (r) {
                 copy_request(ws->request, sizeof(ws->request), r);
             }
-            if (r || c) {
-                val = ap_get_remote_host(c, r? r->per_dir_config : NULL, 
-                                         REMOTE_NOLOOKUP, NULL);
-                if (r && (!val || !strcmp(val, c->client_ip))) {
+            if (r) {
+                if (!(val = ap_get_useragent_host(r, REMOTE_NOLOOKUP, NULL)))
                     apr_cpystrn(ws->client, r->useragent_ip, sizeof(ws->client));
-                }
-                else {
+                else
+                    apr_cpystrn(ws->client, val, sizeof(ws->client));
+            }
+            else if (c) {
+                if (!(val = ap_get_remote_host(c, c->base_server->lookup_defaults,
+                                               REMOTE_NOLOOKUP, NULL)))
+                    apr_cpystrn(ws->client, c->client_ip, sizeof(ws->client));
+                else
                     apr_cpystrn(ws->client, val, sizeof(ws->client));
-                }
             }
             if (s) {
                 if (c) {
index d85706c23ded72c4ba035ad6691d11f20765cb84..fbb3f6b94ce00c8cf05b9bb6e82a4c64ddd52989 100644 (file)
@@ -1348,8 +1348,7 @@ static const char *request_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
     case 3:
         return r->filename;
     case 4:
-        return ap_get_remote_host(r->connection, r->per_dir_config,
-                                  REMOTE_NAME, NULL);
+        return ap_get_useragent_host(r, REMOTE_NAME, NULL);
     case 5:
         return ap_get_remote_logname(r);
     case 6:
index 60ef39656fef1c2a69e432fba3a10419cbd48c3f..c8cda244156e477f3a879a74bcb326c9ad987bbf 100644 (file)
@@ -240,7 +240,7 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r)
     apr_table_addn(e, "SERVER_PORT",
                   apr_psprintf(r->pool, "%u", ap_get_server_port(r)));
     add_unless_null(e, "REMOTE_HOST",
-                    ap_get_remote_host(c, r->per_dir_config, REMOTE_HOST, NULL));
+                    ap_get_useragent_host(r, REMOTE_HOST, NULL));
     apr_table_addn(e, "REMOTE_ADDR", r->useragent_ip);
     apr_table_addn(e, "DOCUMENT_ROOT", ap_document_root(r));    /* Apache */
     apr_table_setn(e, "REQUEST_SCHEME", ap_http_scheme(r));