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
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().
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:
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;
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)
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"))
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) {
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;
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);
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"))
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) {
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:
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));