tags 666818 +patch
forwarded 666818 http://code.google.com/p/modwsgi/issues/detail?id=259
thanks

Hello,

please consider applying the patches attached to this follow-up message.
They port mod_wsgi to support Apache 2.4 in Debian. I added
apache-2.4-compat.patch separately another time, since that's a patch
which could go upstream, too (but see [1] - upstream made a very similar
patch already).

[1] http://code.google.com/p/modwsgi/issues/detail?id=259

-- 
with kind regards,
Arno Töll
IRC: daemonkeeper on Freenode/OFTC
GnuPG Key-ID: 0x9D80F36D
 debian/control                          |    9 +--
 debian/libapache2-mod-wsgi-py3.apache2  |    2 +
 debian/libapache2-mod-wsgi-py3.install  |    2 -
 debian/libapache2-mod-wsgi-py3.postinst |   24 +--------
 debian/libapache2-mod-wsgi-py3.prerm    |   11 ----
 debian/libapache2-mod-wsgi.apache2      |    2 +
 debian/libapache2-mod-wsgi.install      |    2 -
 debian/libapache2-mod-wsgi.postinst     |   25 +--------
 debian/libapache2-mod-wsgi.prerm        |   11 ----
 debian/patches/apache-2.4-compat.patch  |   87 +++++++++++++++++++++++++++++++
 debian/patches/series                   |    1 +
 debian/rules                            |    6 ++-
 12 files changed, 102 insertions(+), 80 deletions(-)

diff --git a/debian/control b/debian/control
index 11ac210..c5f017b 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: httpd
 Priority: optional
 Maintainer: Debian Python Modules Team <[email protected]>
 Uploaders: Bernd Zeimetz <[email protected]>, Piotr Ożarowski <[email protected]>
-Build-Depends: debhelper (>= 5), python-all-dev, python3-all-dev, apache2-threaded-dev
+Build-Depends: debhelper (>= 5), python-all-dev, python3-all-dev, apache2-dev, dh-apache2 
 Homepage: http://www.modwsgi.org/
 Standards-Version: 3.9.2
 Vcs-Svn: svn://svn.debian.org/python-modules/packages/mod-wsgi/trunk/
@@ -11,9 +11,7 @@ Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/mod-wsgi/trun
 
 Package: libapache2-mod-wsgi
 Architecture: any
-Depends: apache2, apache2.2-common, ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
-Suggests: apache2-mpm-worker | apache2-mpm-event
-Provides: httpd-wsgi
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
 Description: Python WSGI adapter module for Apache
  The mod_wsgi adapter is an Apache module that provides a WSGI (Web Server
  Gateway Interface, a standard interface between web server software and
@@ -25,8 +23,7 @@ Description: Python WSGI adapter module for Apache
 
 Package: libapache2-mod-wsgi-py3
 Architecture: any
-Depends: apache2, apache2.2-common, ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}
-Suggests: apache2-mpm-worker | apache2-mpm-event
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}
 Conflicts: libapache2-mod-wsgi
 Provides: httpd-wsgi
 Description: Python 3 WSGI adapter module for Apache
diff --git a/debian/libapache2-mod-wsgi-py3.apache2 b/debian/libapache2-mod-wsgi-py3.apache2
new file mode 100644
index 0000000..bf3dd63
--- /dev/null
+++ b/debian/libapache2-mod-wsgi-py3.apache2
@@ -0,0 +1,2 @@
+mod	debian/wsgi.load
+mod	debian/wsgi.conf
diff --git a/debian/libapache2-mod-wsgi-py3.install b/debian/libapache2-mod-wsgi-py3.install
deleted file mode 100644
index bc46e11..0000000
--- a/debian/libapache2-mod-wsgi-py3.install
+++ /dev/null
@@ -1,2 +0,0 @@
-debian/wsgi.load etc/apache2/mods-available
-debian/wsgi.conf etc/apache2/mods-available
diff --git a/debian/libapache2-mod-wsgi-py3.postinst b/debian/libapache2-mod-wsgi-py3.postinst
index 8dbc0dd..c88539a 100644
--- a/debian/libapache2-mod-wsgi-py3.postinst
+++ b/debian/libapache2-mod-wsgi-py3.postinst
@@ -2,16 +2,6 @@
 
 set -e
 
-apache_force_reload() {
-    if apache2ctl configtest 2>/dev/null; then
-        #invoke-rc.d apache2 force-reload || true
-        # use "restart" as a workaround for bug #558608
-        invoke-rc.d apache2 restart || true
-    else
-        echo "Your apache2 configuration is broken, please fix it and restart apache2 manually."
-    fi
-}
-
 update_symlink() {
     wsgi_py=`readlink /usr/lib/apache2/modules/mod_wsgi.so | sed 's,.*-,,'`
     py3_default=`dpkg -s python3 | grep '^Version' | sed 's,Version: \([^.]*.[^.]*\).*,\1,'`
@@ -20,19 +10,7 @@ update_symlink() {
     fi
 }
 
-if [ -z "$2" ]; then
-    update_symlink
-    if [ -e /etc/apache2/apache2.conf ]; then
-        a2enmod wsgi >/dev/null || true
-        apache_force_reload
-    fi
-else
-    #we're upgrading
-    update_symlink
-    if [ -e /etc/apache2/mods-enabled/wsgi.load ]; then
-        apache_force_reload
-    fi
-fi
+update_symlink
 
 #DEBHELPER#
 
diff --git a/debian/libapache2-mod-wsgi-py3.prerm b/debian/libapache2-mod-wsgi-py3.prerm
deleted file mode 100644
index 7849723..0000000
--- a/debian/libapache2-mod-wsgi-py3.prerm
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-set -e
-
-if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
-    a2dismod wsgi || true
-fi
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/libapache2-mod-wsgi.apache2 b/debian/libapache2-mod-wsgi.apache2
new file mode 100644
index 0000000..bf3dd63
--- /dev/null
+++ b/debian/libapache2-mod-wsgi.apache2
@@ -0,0 +1,2 @@
+mod	debian/wsgi.load
+mod	debian/wsgi.conf
diff --git a/debian/libapache2-mod-wsgi.install b/debian/libapache2-mod-wsgi.install
deleted file mode 100644
index bc46e11..0000000
--- a/debian/libapache2-mod-wsgi.install
+++ /dev/null
@@ -1,2 +0,0 @@
-debian/wsgi.load etc/apache2/mods-available
-debian/wsgi.conf etc/apache2/mods-available
diff --git a/debian/libapache2-mod-wsgi.postinst b/debian/libapache2-mod-wsgi.postinst
index 23b0ec4..997b8e6 100644
--- a/debian/libapache2-mod-wsgi.postinst
+++ b/debian/libapache2-mod-wsgi.postinst
@@ -2,16 +2,6 @@
 
 set -e
 
-apache_force_reload() {
-    if apache2ctl configtest 2>/dev/null; then
-        #invoke-rc.d apache2 force-reload || true
-        # use "restart" as a workaround for bug #558608
-        invoke-rc.d apache2 restart || true
-    else
-        echo "Your apache2 configuration is broken, please fix it and restart apache2 manually."
-    fi
-}
-
 update_symlink() {
     wsgi_py=`readlink /usr/lib/apache2/modules/mod_wsgi.so | sed 's,.*-,,'`
     py_default=`dpkg -s python | grep '^Version' | sed 's,Version: \([^.]*.[^.]*\).*,\1,'`
@@ -20,19 +10,8 @@ update_symlink() {
     fi
 }
 
-if [ -z "$2" ]; then
-    update_symlink
-    if [ -e /etc/apache2/apache2.conf ]; then
-        a2enmod wsgi >/dev/null || true
-        apache_force_reload
-    fi
-else
-    #we're upgrading
-    update_symlink
-    if [ -e /etc/apache2/mods-enabled/wsgi.load ]; then
-        apache_force_reload
-    fi
-fi
+
+update_symlink
 
 #DEBHELPER#
 
diff --git a/debian/libapache2-mod-wsgi.prerm b/debian/libapache2-mod-wsgi.prerm
deleted file mode 100644
index 7849723..0000000
--- a/debian/libapache2-mod-wsgi.prerm
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-set -e
-
-if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
-    a2dismod wsgi || true
-fi
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/patches/apache-2.4-compat.patch b/debian/patches/apache-2.4-compat.patch
new file mode 100644
index 0000000..2bdb934
--- /dev/null
+++ b/debian/patches/apache-2.4-compat.patch
@@ -0,0 +1,87 @@
+--- 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,8 @@
+     }
+     apr_sockaddr_ip_get(&c->local_ip, c->local_addr);
+ 
++
++#ifndef HAVE_UA_FIELDS /* 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,7 +10217,9 @@
+         apr_socket_close(sock);
+         return;
+     }
++
+     apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
++#endif
+ 
+     c->base_server = daemon->group->server;
+ 
+@@ -12861,8 +12871,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 +13396,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 +13435,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 +14543,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);
+ 
diff --git a/debian/patches/series b/debian/patches/series
index a171bba..26da770 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 python-3.2-compat.patch
+apache-2.4-compat.patch
diff --git a/debian/rules b/debian/rules
index 748c0b7..a685fe8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -15,6 +15,7 @@ PY3DEFAULT=$(shell py3versions -dv)
 PY3MIN=$(shell echo $(PY3VERS) | awk '{print $$1}')
 PY3MAX=$(shell echo $(PY3VERS) | LANG=C awk '{print $$NF+0.1}')
 pkgdir = $(CURDIR)/debian/$(PACKAGE)$(if $(patsubst 3.%,,$(1)),,-py3)
+moduledir = $(shell a2query -d)
 
 build-%/config.status:
 	dh_testdir
@@ -61,13 +62,14 @@ binary-arch: build install
 	dh_installchangelogs 
 	dh_installdocs
 	dh_install
+	dh_apache2
 	install -d -m 755 debian/$(PACKAGE)/usr/share/python/runtime.d
 	install -d -m 755 debian/$(PACKAGE)-py3/usr/share/python3/runtime.d
 	install -m 755 debian/$(PACKAGE).rtupdate debian/$(PACKAGE)/usr/share/python/runtime.d/
 	install -m 755 debian/$(PACKAGE)-py3.rtupdate debian/$(PACKAGE)-py3/usr/share/python3/runtime.d/
 	dh_installman
-	dh_link -p $(PACKAGE) /usr/lib/apache2/modules/mod_wsgi.so-$(PYDEFAULT) usr/lib/apache2/modules/mod_wsgi.so
-	dh_link -p $(PACKAGE)-py3 /usr/lib/apache2/modules/mod_wsgi.so-$(PY3DEFAULT) usr/lib/apache2/modules/mod_wsgi.so
+	dh_link -p $(PACKAGE) $(moduledir)/mod_wsgi.so-$(PYDEFAULT) $(moduledir)/mod_wsgi.so
+	dh_link -p $(PACKAGE)-py3 $(moduledir)/mod_wsgi.so-$(PY3DEFAULT) $(moduledir)/mod_wsgi.so
 	dh_strip
 	dh_compress
 	dh_fixperms
Description: Port connection object to Apache 2.4 API
 Replace conn_rec->remote_ip by request_rec->useragent_ip
 .
 See http://httpd.apache.org/docs/2.4/developer/new_api_2_4.html
Author: Arno Töll <[email protected]>

Last-Update: 2012-04-21

--- a/functions.h
+++ b/functions.h
@@ -14,7 +14,7 @@
 
 static const char *extract_remote_address(request_rec *r, char *a)
 {
-    return r->connection->remote_ip;
+    return r->useragent_ip;
 }
 
 static const char *extract_local_address(request_rec *r, char *a) __attribute__((unused));

Attachment: 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

Reply via email to