Hi, Stefan Fritsch pointed me to an issue with my patch: it does not properly handle wsgi_process_socket(), where upstream does slightly abuse APIs since it generates a new connection object for backend connections. Thus, it is strange but correct to set the remote address as client address, where my hunk disabled that code completely in 2.4.
Please use the updated patch attached. Note, I didn't carefully check whether the module works as expected in 2.4. I did hardly more than porting it and try to load the module. -- with kind regards, Arno Töll IRC: daemonkeeper on Freenode/OFTC GnuPG Key-ID: 0x9D80F36D
--- a/mod_wsgi.c
+++ b/mod_wsgi.c
@@ -128,6 +128,12 @@
#define ap_unixd_config unixd_config
#endif
+#if AP_MODULE_MAGIC_AT_LEAST(20111130,0)
+#define HAVE_UA_FIELDS 1
+#else
+#undef HAVE_UA_FIELDS
+#endif
+
#ifndef WIN32
#include <pwd.h>
#endif
@@ -10201,6 +10207,21 @@
}
apr_sockaddr_ip_get(&c->local_ip, c->local_addr);
+
+#ifdef HAVE_UA_FIELDS
+ if ((rv = apr_socket_addr_get(&c->client_addr, APR_REMOTE, sock))
+ != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, WSGI_LOG_INFO(rv), wsgi_server,
+ "mod_wsgi (pid=%d): Failed call "
+ "apr_socket_addr_get(APR_REMOTE).", getpid());
+ apr_socket_close(sock);
+ return;
+ }
+
+ apr_sockaddr_ip_get(&c->client_ip, c->client_addr);
+
+
+#else /* 2.4 does not carry a remote address in conn_rec anymore */
if ((rv = apr_socket_addr_get(&c->remote_addr, APR_REMOTE, sock))
!= APR_SUCCESS) {
ap_log_error(APLOG_MARK, WSGI_LOG_INFO(rv), wsgi_server,
@@ -10209,8 +10230,11 @@
apr_socket_close(sock);
return;
}
+
apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
+#endif
+
c->base_server = daemon->group->server;
c->bucket_alloc = bucket_alloc;
@@ -12861,8 +12885,13 @@
* file for the host.
*/
+#ifdef HAVE_UA_FIELDS
+ r->useragent_ip = (char *)apr_table_get(r->subprocess_env,
+ "REMOTE_ADDR");
+#else
r->connection->remote_ip = (char *)apr_table_get(r->subprocess_env,
"REMOTE_ADDR");
+#endif
key = apr_psprintf(p, "%s|%s",
apr_table_get(r->subprocess_env,
@@ -13381,8 +13410,14 @@
Py_DECREF(object);
}
+#ifdef HAVE_UA_FIELDS
+ if (r->useragent_ip) {
+ value = r->useragent_ip;
+#else
if (c->remote_ip) {
value = c->remote_ip;
+#endif
+
#if PY_MAJOR_VERSION >= 3
object = PyUnicode_DecodeLatin1(value, strlen(value), NULL);
#else
@@ -13414,7 +13449,11 @@
Py_DECREF(object);
}
+#ifdef HAVE_UA_FIELDS
+ rport = r->useragent_addr->port;
+#else
rport = c->remote_addr->port;
+#endif
value = apr_itoa(r->pool, rport);
#if PY_MAJOR_VERSION >= 3
object = PyUnicode_DecodeLatin1(value, strlen(value), NULL);
@@ -14518,7 +14557,11 @@
REMOTE_HOST, NULL);
if (!host)
+#ifdef HAVE_UA_FIELDS
+ host = r->useragent_ip;
+#else
host = r->connection->remote_ip;
+#endif
allow = wsgi_allow_access(r, config, host);
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Python-modules-team mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/python-modules-team

