From: William A. Rowe Jr Date: Fri, 12 Feb 2016 01:17:03 +0000 (+0000) Subject: hostname: Test and log useragent_host per-request across various modules, X-Git-Tag: 2.5.0-alpha~2106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=690c6105f9e66cb3a8a8b03344f64b2cf00d83e9;p=apache 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1729930 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index e7df1730c5..a5ba845e8a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) 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/modules/aaa/mod_access_compat.c b/modules/aaa/mod_access_compat.c index 591fcebed8..e9f1abe483 100644 --- a/modules/aaa/mod_access_compat.c +++ b/modules/aaa/mod_access_compat.c @@ -279,10 +279,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; diff --git a/modules/aaa/mod_authz_host.c b/modules/aaa/mod_authz_host.c index c7bbbe015d..15f453996e 100644 --- a/modules/aaa/mod_authz_host.c +++ b/modules/aaa/mod_authz_host.c @@ -169,10 +169,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) diff --git a/modules/arch/netware/mod_nw_ssl.c b/modules/arch/netware/mod_nw_ssl.c index 8e392a7f01..fc8af9889e 100644 --- a/modules/arch/netware/mod_nw_ssl.c +++ b/modules/arch/netware/mod_nw_ssl.c @@ -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")) diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 95f1d70946..648958ef45 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -451,8 +451,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) { diff --git a/modules/metadata/mod_setenvif.c b/modules/metadata/mod_setenvif.c index db58b601f3..c56ef50318 100644 --- a/modules/metadata/mod_setenvif.c +++ b/modules/metadata/mod_setenvif.c @@ -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; diff --git a/modules/proxy/ajp_header.c b/modules/proxy/ajp_header.c index 145bdcfdff..4f94f7b684 100644 --- a/modules/proxy/ajp_header.c +++ b/modules/proxy/ajp_header.c @@ -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); diff --git a/modules/ssl/ssl_engine_vars.c b/modules/ssl/ssl_engine_vars.c index 2b6d0aaa33..9a9cfded68 100644 --- a/modules/ssl/ssl_engine_vars.c +++ b/modules/ssl/ssl_engine_vars.c @@ -295,8 +295,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")) diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index d8428ed98a..38f5df9d4b 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -1476,8 +1476,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: diff --git a/server/util_script.c b/server/util_script.c index 37508f81d0..b6d361222c 100644 --- a/server/util_script.c +++ b/server/util_script.c @@ -244,7 +244,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));