Bug 179525 - [Patch] www/mod_rpaf2: Fix for mod_rpaf2 compatibility with Apache 2.4
Summary: [Patch] www/mod_rpaf2: Fix for mod_rpaf2 compatibility with Apache 2.4
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Olli Hauer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-12 23:50 UTC by morfin60
Modified: 2013-06-22 21:10 UTC (History)
0 users

See Also:


Attachments
file.diff (2.73 KB, patch)
2013-06-12 23:50 UTC, morfin60
no flags Details | Diff
mod_rpaf-2.0-patch.txt (2.82 KB, text/plain; charset=US-ASCII)
2013-06-13 01:07 UTC, morfin60
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description morfin60 2013-06-12 23:50:00 UTC
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).

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:
How-To-Repeat: Build apache24 from /usr/ports/www/apache24 and then build /usr/ports/www/mod_rpaf2
Comment 1 Glen Barber freebsd_committer freebsd_triage 2013-06-17 12:13:02 UTC
Responsible Changed
From-To: freebsd-www->apache

Reclassify and assign.
Comment 2 Olli Hauer freebsd_committer freebsd_triage 2013-06-17 20:30:39 UTC
Responsible Changed
From-To: apache->ohauer

I'll take it
Comment 3 Olli Hauer 2013-06-17 20:56:52 UTC
Hi Alexander,

sadly the patch does not apply clean even if I apply patch 1 first.

Could you please send me the resulting patched mod_rpaf-2.0.c as tar archive.

Regards,
olli
Comment 4 Olli Hauer freebsd_committer freebsd_triage 2013-06-18 21:24:57 UTC
State Changed
From-To: open->feedback

Request clean patch
Comment 5 dfilter service freebsd_committer freebsd_triage 2013-06-22 21:00:09 UTC
Author: ohauer
Date: Sat Jun 22 19:59:57 2013
New Revision: 321585
URL: http://svnweb.freebsd.org/changeset/ports/321585

Log:
  - fix build with apache24
  
  PR:		ports/179525
  Submitted by:	Alexander <morfin60@gmail.com>
  
  M    mod_rpaf2/Makefile
  A    mod_rpaf2/files
  AM   mod_rpaf2/files/patch-mod_rpaf-2.0.c

Added:
  head/www/mod_rpaf2/files/
  head/www/mod_rpaf2/files/patch-mod_rpaf-2.0.c   (contents, props changed)
Modified:
  head/www/mod_rpaf2/Makefile

Modified: head/www/mod_rpaf2/Makefile
==============================================================================
--- head/www/mod_rpaf2/Makefile	Sat Jun 22 19:15:53 2013	(r321584)
+++ head/www/mod_rpaf2/Makefile	Sat Jun 22 19:59:57 2013	(r321585)
@@ -3,7 +3,7 @@
 
 PORTNAME=	mod_rpaf2
 PORTVERSION=	0.6
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	www
 MASTER_SITES=	http://stderr.net/apache/rpaf/download/
 DISTNAME=	mod_rpaf-${PORTVERSION}
@@ -13,7 +13,7 @@ COMMENT=	Make proxied requests appear wi
 
 MAKE_JOBS_SAFE=  yes
 
-USE_APACHE=	22
+USE_APACHE=	22+
 AP_FAST_BUILD=	yes
 AP_GENPLIST=	yes
 SHORTMODNAME=	rpaf

Added: head/www/mod_rpaf2/files/patch-mod_rpaf-2.0.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/mod_rpaf2/files/patch-mod_rpaf-2.0.c	Sat Jun 22 19:59:57 2013	(r321585)
@@ -0,0 +1,66 @@
+PR: ports/179525 	Fix for mod_rpaf2 compatibility with Apache 2.4
+========================================================================
+--- ./mod_rpaf-2.0.c.orig
++++ ./mod_rpaf-2.0.c
+@@ -86,6 +86,23 @@
+     request_rec *r;
+ } rpaf_cleanup_rec;
+ 
++
++inline apr_sockaddr_t * rpaf_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 * rpaf_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 *remote_ip = rpaf_client_ip(rcr->r->connection);
++    strcpy(remote_ip,apr_pstrdup(rcr->r->connection->pool, rcr->old_ip)); 
++    rpaf_client_addr(rcr->r->connection)->sa.sin.sin_addr.s_addr = apr_inet_addr(remote_ip);
+     return APR_SUCCESS;
+ }
+ 
+@@ -160,8 +178,8 @@
+ 
+     if (!cfg->enable)
+         return DECLINED;
+-
+-    if (is_in_array(r->connection->remote_ip, cfg->proxy_ips) == 1) {
++    char *remote_ip = rpaf_client_ip(r->connection);
++    if (is_in_array(remote_ip, 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,11 @@
+                 if (*fwdvalue != '\0')
+                     ++fwdvalue;
+             }
+-            rcr->old_ip = apr_pstrdup(r->connection->pool, r->connection->remote_ip);
++            rcr->old_ip = apr_pstrdup(r->connection->pool, remote_ip);
+             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);
++            strcpy(remote_ip,apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]));
++            rpaf_client_addr(r->connection)->sa.sin.sin_addr.s_addr = apr_inet_addr(remote_ip);
+             if (cfg->sethostname) {
+                 const char *hostvalue;
+                 if (hostvalue = apr_table_get(r->headers_in, "X-Forwarded-Host")) {
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 6 Olli Hauer freebsd_committer freebsd_triage 2013-06-22 21:02:14 UTC
State Changed
From-To: feedback->closed

Committed, 
Thanks!