From owner-freebsd-www@FreeBSD.ORG Wed Jun 12 22:50:00 2013 Return-Path: Delivered-To: freebsd-www@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D0FBBB66 for ; Wed, 12 Jun 2013 22:50:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id B3D5618DC for ; Wed, 12 Jun 2013 22:50:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r5CMo093022681 for ; Wed, 12 Jun 2013 22:50:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r5CMo0Xn022666; Wed, 12 Jun 2013 22:50:00 GMT (envelope-from gnats) Resent-Date: Wed, 12 Jun 2013 22:50:00 GMT Resent-Message-Id: <201306122250.r5CMo0Xn022666@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-www@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Alexander Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A419AB1B for ; Wed, 12 Jun 2013 22:41:25 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121]) by mx1.freebsd.org (Postfix) with ESMTP id 961EE18B6 for ; Wed, 12 Jun 2013 22:41:25 +0000 (UTC) Received: from oldred.freebsd.org ([127.0.1.6]) by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r5CMfOwJ079905 for ; Wed, 12 Jun 2013 22:41:24 GMT (envelope-from nobody@oldred.freebsd.org) Received: (from nobody@localhost) by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r5CMfOEb079903; Wed, 12 Jun 2013 22:41:24 GMT (envelope-from nobody) Message-Id: <201306122241.r5CMfOEb079903@oldred.freebsd.org> Date: Wed, 12 Jun 2013 22:41:24 GMT From: Alexander To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: www/179525: [Patch] Fix for mod_rpaf2 compatibility with Apache 2.4 X-BeenThere: freebsd-www@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: **OBSOLETE** FreeBSD Project Webmasters List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jun 2013 22:50:00 -0000 >Number: 179525 >Category: www >Synopsis: [Patch] Fix for mod_rpaf2 compatibility with Apache 2.4 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-www >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Jun 12 22:50:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Alexander >Release: 9.1-RELEASE >Organization: none >Environment: FreeBSD noname.botans.org 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Tue Jun 11 10:40:06 YEKT 2013 root@noname.botans.org:/usr/obj/usr/src/sys/MY amd64 >Description: Port mod_rpaf2 can't be compiled when using apache24 because it is marked as broken. Also it can't be compiled when USE_APACHE is changed to 24 in Makefile because some conn_rec fields was renamed(remote_addr to client_addr and remote_ip to client_ip). >How-To-Repeat: Build apache24 from /usr/ports/www/apache24 and then build /usr/ports/www/mod_rpaf2 >Fix: I've added inline functions which accessing fields using preprocessor directives which checks AP_SERVER_MAJORVERSION_NUMBER and AP_SERVER_MINORVERSION_NUMBER values. This patch was tested on Apache 2.4.4 and 2.2.24 Patch attached with submission follows: --- /usr/ports/www/mod_rpaf2/work/mod_rpaf-0.6/mod_rpaf-2.0.c 2008-01-01 08:05:40.000000000 +0500 +++ mod_rpaf-2.0.c 2013-06-13 03:41:46.000000000 +0600 @@ -86,6 +86,23 @@ request_rec *r; } rpaf_cleanup_rec; +inline apr_sockaddr_t * client_addr(conn_rec *c) { +#if AP_SERVER_MAJORVERSION_NUMBER >= 2 && AP_SERVER_MINORVERSION_NUMBER >= 4 + return c->client_addr; +#else + return c->remote_addr; +#endif +} + +inline char * client_ip(conn_rec *c) { +#if AP_SERVER_MAJORVERSION_NUMBER >= 2 && AP_SERVER_MINORVERSION_NUMBER >= 4 + return c->client_ip; +#else + return c->remote_ip; +#endif +} + + static void *rpaf_create_server_cfg(apr_pool_t *p, server_rec *s) { rpaf_server_cfg *cfg = (rpaf_server_cfg *)apr_pcalloc(p, sizeof(rpaf_server_cfg)); if (!cfg) @@ -147,8 +164,9 @@ static apr_status_t rpaf_cleanup(void *data) { rpaf_cleanup_rec *rcr = (rpaf_cleanup_rec *)data; - rcr->r->connection->remote_ip = apr_pstrdup(rcr->r->connection->pool, rcr->old_ip); - rcr->r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(rcr->r->connection->remote_ip); + char *ip = client_ip(rcr->r->connection); + ip = apr_pstrdup(rcr->r->connection->pool, rcr->old_ip); + client_addr(rcr->r->connection)->sa.sin.sin_addr.s_addr = apr_inet_addr(ip); return APR_SUCCESS; } @@ -161,7 +179,7 @@ if (!cfg->enable) return DECLINED; - if (is_in_array(r->connection->remote_ip, cfg->proxy_ips) == 1) { + if (is_in_array(client_ip(r->connection), cfg->proxy_ips) == 1) { /* check if cfg->headername is set and if it is use that instead of X-Forwarded-For by default */ if (cfg->headername && (fwdvalue = apr_table_get(r->headers_in, cfg->headername))) { @@ -180,11 +198,12 @@ if (*fwdvalue != '\0') ++fwdvalue; } - rcr->old_ip = apr_pstrdup(r->connection->pool, r->connection->remote_ip); + rcr->old_ip = apr_pstrdup(r->connection->pool, client_ip(r->connection)); rcr->r = r; apr_pool_cleanup_register(r->pool, (void *)rcr, rpaf_cleanup, apr_pool_cleanup_null); - r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]); - r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(r->connection->remote_ip); + char *ip = client_ip(r->connection); + ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]); + client_addr(r->connection)->sa.sin.sin_addr.s_addr = apr_inet_addr(client_ip(r->connection)); if (cfg->sethostname) { const char *hostvalue; if (hostvalue = apr_table_get(r->headers_in, "X-Forwarded-Host")) { >Release-Note: >Audit-Trail: >Unformatted: