Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jun 2013 22:46:18 GMT
From:      Alexander <morfin60@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/179527: [Patch] Fix for mod_rpaf2 compatibility with Apache 2.4
Message-ID:  <201306122246.r5CMkIua080936@oldred.freebsd.org>
Resent-Message-ID: <201306122250.r5CMo2ei022723@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         179527
>Category:       ports
>Synopsis:       [Patch] Fix for mod_rpaf2 compatibility with Apache 2.4
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 12 22:50:02 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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306122246.r5CMkIua080936>