From a10c60232480678fdc9ea2314df64e0655eb169b Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Mon, 10 Jul 2017 10:59:08 +0200 Subject: [PATCH] move to proxy_fdpass2 name plugin to avoid clash names --- debian/changelog | 4 +- debian/conf/proxy_fdpass.load | 2 - debian/conf/proxy_fdpass2.load | 2 + debian/control | 8 ++-- debian/install | 6 +-- debian/postinst | 10 ++-- debian/prerm | 14 +++--- debian/rules | 4 +- mod_proxy_fdpass.c => mod_proxy_fdpass2.c | 58 +++++++++++++++++------ mod_proxy_fdpass.h => mod_proxy_fdpass2.h | 8 ++-- proxy_fdpass.conf | 3 -- proxy_fdpass2.conf | 3 ++ 12 files changed, 75 insertions(+), 47 deletions(-) delete mode 100644 debian/conf/proxy_fdpass.load create mode 100644 debian/conf/proxy_fdpass2.load rename mod_proxy_fdpass.c => mod_proxy_fdpass2.c (91%) rename mod_proxy_fdpass.h => mod_proxy_fdpass2.h (86%) delete mode 100644 proxy_fdpass.conf create mode 100644 proxy_fdpass2.conf diff --git a/debian/changelog b/debian/changelog index 5d7a3b6..48552da 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -mod-proxy-fdpass (0.1.1-1) unstable; urgency=low +mod-proxy-fdpass2 (0.1.1-1) unstable; urgency=low * Log for debugging disabled -- Matteo Nastasi Thu, 21 Mar 2013 10:07:13 +0100 -mod-proxy-fdpass (0.1.0-1) unstable; urgency=low +mod-proxy-fdpass2 (0.1.0-1) unstable; urgency=low * First backport of fdpass module diff --git a/debian/conf/proxy_fdpass.load b/debian/conf/proxy_fdpass.load deleted file mode 100644 index b27bcdb..0000000 --- a/debian/conf/proxy_fdpass.load +++ /dev/null @@ -1,2 +0,0 @@ -# Depends: proxy -LoadModule proxy_fdpass_module /usr/lib/apache2/modules/mod_proxy_fdpass.so diff --git a/debian/conf/proxy_fdpass2.load b/debian/conf/proxy_fdpass2.load new file mode 100644 index 0000000..29a0f8f --- /dev/null +++ b/debian/conf/proxy_fdpass2.load @@ -0,0 +1,2 @@ +# Depends: proxy +LoadModule proxy_fdpass2_module /usr/lib/apache2/modules/mod_proxy_fdpass2.so diff --git a/debian/control b/debian/control index 8ed91bf..5567697 100644 --- a/debian/control +++ b/debian/control @@ -1,15 +1,15 @@ -Source: mod-proxy-fdpass +Source: mod-proxy-fdpass2 Section: web Priority: optional Maintainer: Emmanuel Lacour Build-Depends: debhelper (>= 4.0.0), apache2-prefork-dev (>> 2.2), libxml2-dev (>> 2.5.10) Standards-Version: 0.1.0 -Package: libapache2-mod-proxy-fdpass +Package: libapache2-mod-proxy-fdpass2 Architecture: any -Depends: ${shlibs:Depends}, apache2, apache2.2-common, libxml2 (>> 2.5.10) +Depends: ${shlibs:Depends}, apache2, apache2-data, libxml2 (>> 2.5.10) Description: Apache2 filter module for HTML links rewriting - mod_proxy_fdpass is an output filter to rewrite HTML links in a proxy + mod_proxy_fdpass2 is an output filter to rewrite HTML links in a proxy situation, to ensure that links work for users outside the proxy. It serves the same purpose as Apache's ProxyPassReverse directive does for HTTP headers, and is an essential component of a reverse proxy. diff --git a/debian/install b/debian/install index 0cb76a2..489c254 100644 --- a/debian/install +++ b/debian/install @@ -1,3 +1,3 @@ -debian/conf/proxy_fdpass.load /etc/apache2/mods-available/ -proxy_fdpass.conf /etc/apache2/mods-available/ -.libs/mod_proxy_fdpass.so /usr/lib/apache2/modules/ +debian/conf/proxy_fdpass2.load /etc/apache2/mods-available/ +proxy_fdpass2.conf /etc/apache2/mods-available/ +.libs/mod_proxy_fdpass2.so /usr/lib/apache2/modules/ diff --git a/debian/postinst b/debian/postinst index e3cf6f7..da6d769 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,5 +1,5 @@ #! /bin/sh -# postinst script for libapache2-mod-proxy-fdpass +# postinst script for libapache2-mod-proxy-fdpass2 # # see: dh_installdeb(1) @@ -31,18 +31,18 @@ case "$1" in configure) # Reload the module on upgrade if enabled if [ -n "$2" ]; then - if [ -e /etc/apache2/mods-enabled/proxy_fdpass.load ]; then + if [ -e /etc/apache2/mods-enabled/proxy_fdpass2.load ]; then # We must reenable this module to enable the new configuration file if dpkg --compare-versions "$2" lt "3.0.0-1" ; then - a2dismod proxy_fdpass >/dev/null || true - a2enmod proxy_fdpass >/dev/null || true + a2dismod proxy_fdpass2 >/dev/null || true + a2enmod proxy_fdpass2 >/dev/null || true fi reload_apache fi else # Enable the module if [ -e /etc/apache2/apache2.conf ]; then - a2enmod proxy_fdpass >/dev/null || true + a2enmod proxy_fdpass2 >/dev/null || true reload_apache fi fi diff --git a/debian/prerm b/debian/prerm index 9f64884..a6ada29 100644 --- a/debian/prerm +++ b/debian/prerm @@ -1,5 +1,5 @@ #! /bin/sh -# prerm script for libapache2-mod-proxy-fdpass +# prerm script for libapache2-mod-proxy-fdpass2 # # see: dh_installdeb(1) @@ -28,13 +28,13 @@ reload_apache() case "$1" in remove) - if [ -e /etc/apache2/mods-enabled/proxy_fdpass.load ]; then - a2dismod proxy_fdpass >/dev/null || true - reload_apache - fi - ;; + if [ -e /etc/apache2/mods-enabled/proxy_fdpass2.load ]; then + a2dismod proxy_fdpass2 >/dev/null || true + reload_apache + fi + ;; upgrade|failed-upgrade|deconfigure) - ;; + ;; *) echo "prerm called with unknown argument \`$1'" >&2 exit 1 diff --git a/debian/rules b/debian/rules index b0f820e..271f838 100755 --- a/debian/rules +++ b/debian/rules @@ -13,13 +13,13 @@ build: build-stamp build-stamp: dh_testdir - apxs2 -c -I/usr/include/libxml2 mod_proxy_fdpass.c + apxs2 -c -I/usr/include/libxml2 mod_proxy_fdpass2.c touch build-stamp clean: dh_testdir dh_testroot - rm -f build-stamp mod_proxy_fdpass.la mod_proxy_fdpass.lo mod_proxy_fdpass.o mod_proxy_fdpass.slo + rm -f build-stamp mod_proxy_fdpass2.la mod_proxy_fdpass2.lo mod_proxy_fdpass2.o mod_proxy_fdpass2.slo rm -rf .libs dh_clean diff --git a/mod_proxy_fdpass.c b/mod_proxy_fdpass2.c similarity index 91% rename from mod_proxy_fdpass.c rename to mod_proxy_fdpass2.c index ff3e684..7d4c6ae 100644 --- a/mod_proxy_fdpass.c +++ b/mod_proxy_fdpass2.c @@ -30,13 +30,13 @@ #include "apr_support.h" #endif -#include "mod_proxy_fdpass.h" +#include "mod_proxy_fdpass2.h" -module AP_MODULE_DECLARE_DATA proxy_fdpass_module; +module AP_MODULE_DECLARE_DATA proxy_fdpass2_module; -#define MOP_DEBUG 0 +#define MOP_DEBUG 1 -static int proxy_fdpass_canon(request_rec *r, char *url) +static int proxy_fdpass2_canon(request_rec *r, char *url) { const char *path; @@ -45,7 +45,7 @@ static int proxy_fdpass_canon(request_rec *r, char *url) char mop_bf[512]; mop_fd = open("/tmp/apache_mop.log", O_WRONLY | O_APPEND | O_CREAT, 0644); - sprintf(mop_bf, "proxy_http_canon: start\n"); + sprintf(mop_bf, "proxy_http_canon: start [%p]\n", r->headers_in); write(mop_fd, mop_bf, strlen(mop_bf)); close(mop_fd); @@ -265,8 +265,23 @@ static int headers_builder(void *rec, const char *key, const char *value) s = (char *)rec; + if (MOP_DEBUG == 1) { + int mop_fd; + char mop_bf[512]; + + mop_fd = open("/tmp/apache_mop.log", O_WRONLY | O_APPEND | O_CREAT, 0644); + sprintf(mop_bf, "HEADERS_BUILDER: [%s:%s]\n", key, value); + write(mop_fd, mop_bf, strlen(mop_bf)); + close(mop_fd); + } + + // TODO: verify length - sprintf(s, "%s%s:%s\n", s, key, value); + // sprintf(s, "%s%s:%s\n", s, key, value); + strcat(s, key); + strcat(s, ":"); + strcat(s, value); + strcat(s, "\n"); } #define CTRL_BUFF_MAX_SZ (8*1024) @@ -330,6 +345,7 @@ int read_post(request_rec *r, const char **data) if (p = strchr(s_type, ';')) { *p = '\0'; } + if (strcasecmp(s_type, DEFAULT_ENCTYPE) != 0) { return DECLINED; } @@ -353,7 +369,7 @@ int read_post(request_rec *r, const char **data) // TODO: sanitize calloc -static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker, +static int proxy_fdpass2_handler(request_rec *r, proxy_worker *worker, proxy_server_conf *conf, char *url, const char *proxyname, apr_port_t proxyport) @@ -419,7 +435,7 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker, char mop_bf[512]; mop_fd = open("/tmp/apache_mop.log", O_WRONLY | O_APPEND | O_CREAT, 0644); - sprintf(mop_bf, "proxy_fdpass_handler: start\n"); + sprintf(mop_bf, "proxy_fdpass2_handler: start\n"); write(mop_fd, mop_bf, strlen(mop_bf)); write(mop_fd, headers_out, strlen(headers_out)); close(mop_fd); @@ -448,7 +464,7 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker, /* const char *flush_method = worker->flusher ? worker->flusher : "flush"; */ const char *flush_method = "flush"; - proxy_fdpass_flush *flush = ap_lookup_provider(PROXY_FDPASS_FLUSHER, + proxy_fdpass2_flush *flush = ap_lookup_provider(PROXY_FDPASS_FLUSHER, flush_method, "0"); if (!flush) { @@ -484,6 +500,18 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker, strcat(headers_out, "\n"); wrlen = strlen(headers_out); rv = apr_socket_send(ctrlsock, headers_out, &wrlen); + + if (MOP_DEBUG == 1) { + int mop_fd; + char mop_bf[512]; + + mop_fd = open("/tmp/apache_mop.log", O_WRONLY | O_APPEND | O_CREAT, 0644); + write(mop_fd, "HEADERS_OUT\n", 12); + write(mop_fd, headers_out, wrlen); + close(mop_fd); + } + + if (rv != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: FD: send headers failed"); @@ -548,26 +576,26 @@ static int standard_flush(request_rec *r) return OK; } -static const proxy_fdpass_flush builtin_flush = +static const proxy_fdpass2_flush builtin_flush = { "flush", &standard_flush, NULL }; -static void ap_proxy_fdpass_register_hooks(apr_pool_t *p) +static void ap_proxy_fdpass2_register_hooks(apr_pool_t *p) { ap_register_provider(p, PROXY_FDPASS_FLUSHER, "flush", "0", &builtin_flush); - proxy_hook_scheme_handler(proxy_fdpass_handler, NULL, NULL, APR_HOOK_FIRST); - proxy_hook_canon_handler(proxy_fdpass_canon, NULL, NULL, APR_HOOK_FIRST); + proxy_hook_scheme_handler(proxy_fdpass2_handler, NULL, NULL, APR_HOOK_FIRST); + proxy_hook_canon_handler(proxy_fdpass2_canon, NULL, NULL, APR_HOOK_FIRST); } -module AP_MODULE_DECLARE_DATA proxy_fdpass_module = { +module AP_MODULE_DECLARE_DATA proxy_fdpass2_module = { STANDARD20_MODULE_STUFF, NULL, /* create per-directory config structure */ NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ NULL, /* command apr_table_t */ - ap_proxy_fdpass_register_hooks /* register hooks */ + ap_proxy_fdpass2_register_hooks /* register hooks */ }; diff --git a/mod_proxy_fdpass.h b/mod_proxy_fdpass2.h similarity index 86% rename from mod_proxy_fdpass.h rename to mod_proxy_fdpass2.h index b9d2231..194dbb3 100644 --- a/mod_proxy_fdpass.h +++ b/mod_proxy_fdpass2.h @@ -15,7 +15,7 @@ */ /** - * @file mod_proxy_fdpass.h + * @file mod_proxy_fdpass2.h * @brief FD Passing interfaces * * @addtogroup FDPass_provider @@ -27,10 +27,10 @@ #ifndef _PROXY_FDPASS_H_ #define _PROXY_FDPASS_H_ -#define PROXY_FDPASS_FLUSHER "proxy_fdpass_flusher" +#define PROXY_FDPASS_FLUSHER "proxy_fdpass2_flusher" -typedef struct proxy_fdpass_flush proxy_fdpass_flush; -struct proxy_fdpass_flush { +typedef struct proxy_fdpass2_flush proxy_fdpass2_flush; +struct proxy_fdpass2_flush { const char *name; int (*flusher)(request_rec *r); void *context; diff --git a/proxy_fdpass.conf b/proxy_fdpass.conf deleted file mode 100644 index c9ab012..0000000 --- a/proxy_fdpass.conf +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/proxy_fdpass2.conf b/proxy_fdpass2.conf new file mode 100644 index 0000000..7deb73e --- /dev/null +++ b/proxy_fdpass2.conf @@ -0,0 +1,3 @@ + + + -- 2.17.1