[OpenSRF-GIT] OpenSRF branch rel_2_1 updated. osrf_rel_2_1_2-6-ge646224

Evergreen Git git at git.evergreen-ils.org
Sat Jan 19 13:51:06 EST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".

The branch, rel_2_1 has been updated
       via  e6462241444ab06944ef06a08a7599cb0e51e26f (commit)
      from  8c50b55dc7e7c706976a40a2a3926073fb2f8ff2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e6462241444ab06944ef06a08a7599cb0e51e26f
Author: Dan Scott <dscott at laurentian.ca>
Date:   Wed Jan 16 21:59:22 2013 -0500

    Support Apache 2.4 client IP address lookups
    
    The Apache 2.4 API replaces the conn_rec->remote_ip member with
    conn_rec->client_ip or conn_rec->useragent_ip (per
    http://httpd.apache.org/docs/2.4/developer/new_api_2_4.html). client_ip
    seems to be the best choice for us, to avoid everything being logged
    from the load balancer or proxy instead of the client's address.
    
    This code detects the version of Apache and uses client_ip if it is 2.4
    or greater.
    
    Signed-off-by: Dan Scott <dscott at laurentian.ca>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/configure.ac b/configure.ac
index 3bca402..d23354d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,6 +203,29 @@ if ! test -d "$APR_HEADERS"; then
 fi
 AC_SUBST([APR_HEADERS])
 
+# The following Apache version detection code is adapted from
+# http://www.gnu.org/software/autoconf-archive/ax_prog_apache.html
+# licensed under version 2 of the GNU General Public License, or
+# (at your discretion) any later version.
+#
+# Copyright (c) 2008 Loic Dachary <loic at senga.org>
+#
+# Collect apache version number. If for nothing else, this
+# guarantees that httpd is a working apache executable.
+#
+changequote(<<, >>)dnl
+APACHE=`$APXS2 -q progname`
+APACHE_READABLE_VERSION=`$APACHE -v | grep 'Server version' | sed -e 's;.*Apache/\([0-9\.][0-9\.]*\).*;\1;'`
+changequote([, ])dnl
+APACHE_VERSION=`echo $APACHE_READABLE_VERSION | sed -e 's/\.//g'`
+if test -z "$APACHE_VERSION" ; then
+    AC_MSG_ERROR("could not determine apache version number");
+fi
+APACHE_MAJOR=`expr $APACHE_VERSION : '\(..\)'`
+APACHE_MINOR=`expr $APACHE_VERSION : '..\(.*\)'`
+AM_CONDITIONAL(APACHE_MIN_24, test "$APACHE_MAJOR" -ge "24")
+AC_SUBST([APACHE_MIN_24])
+
 AC_ARG_WITH([libxml],
 [  --with-libxml=path               location of the libxml2 headers (default is /usr/include/libxml2/))],
 [LIBXML2_HEADERS=${withval}],
@@ -371,6 +394,7 @@ fi
         AC_MSG_RESULT(APXS2 location:                  ${APXS2})
         AC_MSG_RESULT(Apache headers location:         ${APACHE2_HEADERS})
         AC_MSG_RESULT(APR headers location:            ${APR_HEADERS})
+        AC_MSG_RESULT(Apache version:                  ${APACHE_READABLE_VERSION})
         AC_MSG_RESULT(libxml2 headers location:        ${LIBXML2_HEADERS})
 
 AC_MSG_RESULT([----------------------------------------------------------------------])
diff --git a/src/gateway/Makefile.am b/src/gateway/Makefile.am
index 3dafbdc..425a824 100644
--- a/src/gateway/Makefile.am
+++ b/src/gateway/Makefile.am
@@ -10,11 +10,14 @@
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-
+#
+if APACHE_MIN_24
+HAVE_APACHE_MIN_24 = -DAPACHE_MIN_24
+endif
 
 EXTRA_DIST = @srcdir@/apachetools.c @srcdir@/apachetools.h @srcdir@/osrf_json_gateway.c @srcdir@/osrf_http_translator.c
 
-AM_CFLAGS = -D_LARGEFILE64_SOURCE -Wall -I at abs_top_srcdir@/include/ -I$(LIBXML2_HEADERS) -I$(APACHE2_HEADERS) -I$(APR_HEADERS)
+AM_CFLAGS = -D_LARGEFILE64_SOURCE $(HAVE_APACHE_MIN_24) -Wall -I at abs_top_srcdir@/include/ -I$(LIBXML2_HEADERS) -I$(APACHE2_HEADERS) -I$(APR_HEADERS)
 AM_LDFLAGS = -L$(LIBDIR) -L at top_builddir@/src/libopensrf
 AP_LIBEXECDIR = `$(APXS2) -q LIBEXECDIR`
 
diff --git a/src/gateway/osrf_http_translator.c b/src/gateway/osrf_http_translator.c
index f6d492b..2fed04a 100644
--- a/src/gateway/osrf_http_translator.c
+++ b/src/gateway/osrf_http_translator.c
@@ -117,7 +117,11 @@ static osrfHttpTranslator* osrfNewHttpTranslator(request_rec* apreq) {
     trans->disconnectOnly = 0;
     trans->connecting = 0;
     trans->disconnecting = 0;
+#ifdef APACHE_MIN_24
+    trans->remoteHost = apreq->connection->client_ip;
+#else
     trans->remoteHost = apreq->connection->remote_ip;
+#endif
     trans->messages = NULL;
 
     /* load the message body */
diff --git a/src/gateway/osrf_json_gateway.c b/src/gateway/osrf_json_gateway.c
index ecc02a2..7d5f3f7 100644
--- a/src/gateway/osrf_json_gateway.c
+++ b/src/gateway/osrf_json_gateway.c
@@ -288,8 +288,13 @@ static int osrf_json_gateway_method_handler (request_rec *r) {
 		const char* authtoken = apr_table_get(r->headers_in, "X-OILS-Authtoken");
 		if(!authtoken) authtoken = "";
 		growing_buffer* act = buffer_init(128);
+#ifdef APACHE_MIN_24
+		buffer_fadd(act, "[%s] [%s] [%s] %s %s", r->connection->client_ip,
+			authtoken, osrf_locale, service, method );
+#else
 		buffer_fadd(act, "[%s] [%s] [%s] %s %s", r->connection->remote_ip,
 			authtoken, osrf_locale, service, method );
+#endif
 
 		const char* str; int i = 0;
 		int redact_params = 0;

-----------------------------------------------------------------------

Summary of changes:
 configure.ac                       |   24 ++++++++++++++++++++++++
 src/gateway/Makefile.am            |    7 +++++--
 src/gateway/osrf_http_translator.c |    4 ++++
 src/gateway/osrf_json_gateway.c    |    5 +++++
 4 files changed, 38 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list