Lines 1-66
Link Here
|
1 |
PR: ports/179525 Fix for mod_rpaf2 compatibility with Apache 2.4 |
|
|
2 |
======================================================================== |
3 |
--- ./mod_rpaf-2.0.c.orig |
4 |
+++ ./mod_rpaf-2.0.c |
5 |
@@ -86,6 +86,23 @@ |
6 |
request_rec *r; |
7 |
} rpaf_cleanup_rec; |
8 |
|
9 |
+ |
10 |
+inline apr_sockaddr_t * rpaf_client_addr(conn_rec *c) { |
11 |
+#if AP_SERVER_MAJORVERSION_NUMBER >= 2 && AP_SERVER_MINORVERSION_NUMBER >= 4 |
12 |
+ return c->client_addr; |
13 |
+#else |
14 |
+ return c->remote_addr; |
15 |
+#endif |
16 |
+} |
17 |
+ |
18 |
+inline char * rpaf_client_ip(conn_rec *c) { |
19 |
+#if AP_SERVER_MAJORVERSION_NUMBER >= 2 && AP_SERVER_MINORVERSION_NUMBER >= 4 |
20 |
+ return c->client_ip; |
21 |
+#else |
22 |
+ return c->remote_ip; |
23 |
+#endif |
24 |
+} |
25 |
+ |
26 |
static void *rpaf_create_server_cfg(apr_pool_t *p, server_rec *s) { |
27 |
rpaf_server_cfg *cfg = (rpaf_server_cfg *)apr_pcalloc(p, sizeof(rpaf_server_cfg)); |
28 |
if (!cfg) |
29 |
@@ -147,8 +164,9 @@ |
30 |
|
31 |
static apr_status_t rpaf_cleanup(void *data) { |
32 |
rpaf_cleanup_rec *rcr = (rpaf_cleanup_rec *)data; |
33 |
- rcr->r->connection->remote_ip = apr_pstrdup(rcr->r->connection->pool, rcr->old_ip); |
34 |
- rcr->r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(rcr->r->connection->remote_ip); |
35 |
+ char *remote_ip = rpaf_client_ip(rcr->r->connection); |
36 |
+ strcpy(remote_ip,apr_pstrdup(rcr->r->connection->pool, rcr->old_ip)); |
37 |
+ rpaf_client_addr(rcr->r->connection)->sa.sin.sin_addr.s_addr = apr_inet_addr(remote_ip); |
38 |
return APR_SUCCESS; |
39 |
} |
40 |
|
41 |
@@ -160,8 +178,8 @@ |
42 |
|
43 |
if (!cfg->enable) |
44 |
return DECLINED; |
45 |
- |
46 |
- if (is_in_array(r->connection->remote_ip, cfg->proxy_ips) == 1) { |
47 |
+ char *remote_ip = rpaf_client_ip(r->connection); |
48 |
+ if (is_in_array(remote_ip, cfg->proxy_ips) == 1) { |
49 |
/* check if cfg->headername is set and if it is use |
50 |
that instead of X-Forwarded-For by default */ |
51 |
if (cfg->headername && (fwdvalue = apr_table_get(r->headers_in, cfg->headername))) { |
52 |
@@ -180,11 +198,11 @@ |
53 |
if (*fwdvalue != '\0') |
54 |
++fwdvalue; |
55 |
} |
56 |
- rcr->old_ip = apr_pstrdup(r->connection->pool, r->connection->remote_ip); |
57 |
+ rcr->old_ip = apr_pstrdup(r->connection->pool, remote_ip); |
58 |
rcr->r = r; |
59 |
apr_pool_cleanup_register(r->pool, (void *)rcr, rpaf_cleanup, apr_pool_cleanup_null); |
60 |
- r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]); |
61 |
- r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(r->connection->remote_ip); |
62 |
+ strcpy(remote_ip,apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)])); |
63 |
+ rpaf_client_addr(r->connection)->sa.sin.sin_addr.s_addr = apr_inet_addr(remote_ip); |
64 |
if (cfg->sethostname) { |
65 |
const char *hostvalue; |
66 |
if (hostvalue = apr_table_get(r->headers_in, "X-Forwarded-Host")) { |