--- filterproxy-0.30.orig/html/ImageComp.html +++ filterproxy-0.30/html/ImageComp.html @@ -0,0 +1,12 @@ + + +FilterProxy::ImageComp Config + +

FilterProxy::ImageComp Config

+

Back to FilterProxy main configuration. +

ImageComp has no global configuration. +


ImageComp was written by + Bob McElrath. Please see the README, BUGS, and any relevant module documentation before + mailing me with problems. + + --- filterproxy-0.30.orig/html/Rewrite.html +++ filterproxy-0.30/html/Rewrite.html @@ -94,7 +94,7 @@ % } - +
--- filterproxy-0.30.orig/debian/dirs +++ filterproxy-0.30/debian/dirs @@ -0,0 +1,4 @@ +usr/share/filterproxy +usr/share/doc/filterproxy +usr/sbin +var/log/filterproxy --- filterproxy-0.30.orig/debian/docs +++ filterproxy-0.30/debian/docs @@ -0,0 +1,4 @@ +BUGS +README +TODO +FilterProxy.conf --- filterproxy-0.30.orig/debian/control +++ filterproxy-0.30/debian/control @@ -0,0 +1,16 @@ +Source: filterproxy +Section: web +Priority: optional +Maintainer: Mario Lang +Build-Depends-Indep: debhelper (>> 3.0.0) +Standards-Version: 3.5.2.0 + +Package: filterproxy +Architecture: all +Depends: liburi-perl, libcompress-zlib-perl (>= 1.10), libhtml-mason-perl (>= 1.1201), libxml-libxml-perl, libxml-libxslt-perl, libxml2, libxslt1, libwww-perl, perl (>= 5.8) | libtime-hires-perl (>= 1.10), perl (>= 5.6), debconf (>= 0.5), perlmagick (>= 5.4) +Description: A filtering proxy, which can among other things remove ads. + FilterProxy is a Perl script that acts as a generic web proxy. It is + unique in that it allows "Modules" to be installed that can perform + arbitrary transformations on HTML(or any other mime-type). Currently + it filters ads, and compresses HTML content (for a 5-1 speedup on + modems!) Configuration is done with web forms. --- filterproxy-0.30.orig/debian/rules +++ filterproxy-0.30/debian/rules @@ -0,0 +1,75 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# This file is public domain software, originally written by Joey Hess. +# +# This version is for packages that are architecture independent. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This is the debhelper compatibility version to use. +export DH_COMPAT=3 + +build: build-stamp +build-stamp: + dh_testdir + + # Add here commands to compile the package. + #$(MAKE) + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + # Add here commands to clean up after the build process. + #-$(MAKE) clean + #-$(MAKE) distclean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/. + #$(MAKE) prefix=`pwd`/debian/`dh_listpackages`/usr install + cp FilterProxy.pl $(CURDIR)/debian/filterproxy/usr/sbin/FilterProxy + cp -R html/ xsl/ FilterProxy/ $(CURDIR)/debian/filterproxy/usr/share/filterproxy + +# Build architecture-independent files here. +binary-indep: build install + dh_testdir + dh_testroot + dh_installdebconf + dh_installdocs + dh_installexamples FilterProxy.conf +# dh_installmenu +# dh_installlogrotate +# dh_installpam +# dh_installmime + dh_installinit +# dh_installcron + dh_installman debian/FilterProxy.8 +# dh_installinfo +# dh_undocumented + dh_installchangelogs + dh_link + dh_compress + dh_fixperms + dh_installdeb +# dh_perl + dh_gencontrol + dh_md5sums + dh_builddeb + +# Build architecture-dependent files here. +binary-arch: build install +# We have nothing to do by default. + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- filterproxy-0.30.orig/debian/conffiles +++ filterproxy-0.30/debian/conffiles @@ -0,0 +1 @@ +/etc/init.d/filterproxy --- filterproxy-0.30.orig/debian/changelog +++ filterproxy-0.30/debian/changelog @@ -0,0 +1,168 @@ +filterproxy (0.30-5) unstable; urgency=low + + * Added xsl/ to the installation process. + * Build it with .orig.tar.gz again (Closes: #159149) + + -- Mario Lang Tue, 22 Oct 2002 10:15:11 +0200 + +filterproxy (0.30-4) unstable; urgency=low + + * New maintainer upload (Closes: Bug#160773) + * Fixed mason compatibility (Closes: Bug#159929) + * Now depends on mason >= 1.1201 + * Add dependency for liburi-perl + * Patch from upstream (Closes: Bug#143864) + * Remove libxml2-dev, libxslt1-dev from build-depend, they + are really not used. + + -- Mario Lang Wed, 18 Sep 2002 10:02:50 +0200 + +filterproxy (0.30-3.1) unstable; urgency=low + + * Non-maintainer upload (BSP) + * Fixed depends for perl 5.8 + + -- Bas Zoetekouw Sun, 1 Sep 2002 15:02:51 +0000 + +filterproxy (0.30-3) unstable; urgency=low + + * Danish templates fixed (Closes: #144108) + * NMU by Søren Boll Overgaard, since maintainers new key has not yet + been accepted into the keyring. Identity of maintainer has been + rechecked. + + -- Kenneth Vestergaard Schmidt Tue, 23 Apr 2002 22:19:02 +0200 + +filterproxy (0.30-2.1) unstable; urgency=high + + * NMU to get ready for woody release. + * Corrected sequence of actions in postinst, fresh install should now + succeed - using a slightly different approach than in proposed patch + though - doesn't chown config if it already exists (Closes: #135575) + + -- Erich Schubert Sun, 10 Mar 2002 20:36:50 +0100 + +filterproxy (0.30-2) unstable; urgency=low + + * Don't create homedir in postinst script (Closes: #129454) + * Don't overwrite config-file, since it doesn't change in any noteworthy + way between releases. (Closes: #129596) + + -- Kenneth Vestergaard Schmidt Thu, 17 Jan 2002 17:00:50 +0100 + +filterproxy (0.30-1) unstable; urgency=low + + * New upstream release + * Fixed a little display-bug with Konqueror in Rewrite.html + + -- Kenneth Vestergaard Schmidt Sun, 13 Jan 2002 23:36:41 +0100 + +filterproxy (0.29.2-4) unstable; urgency=low + + * Depend on perlmagick (Closes: #120455) + + -- Kenneth Vestergaard Schmidt Tue, 4 Dec 2001 15:35:59 +0100 + +filterproxy (0.29.2-3) unstable; urgency=low + + * Added Brazilian portuguese (pt_BR) debconf template, courtesy of Andre Luis + Lopes (Closes: #120938) + + -- Kenneth Vestergaard Schmidt Tue, 27 Nov 2001 14:44:43 +0100 + +filterproxy (0.29.2-2) unstable; urgency=low + + * Add dummy ImageComp.html (Closes: #120455) + + -- Kenneth Vestergaard Schmidt Thu, 22 Nov 2001 12:48:37 +0100 + +filterproxy (0.29.2-1) unstable; urgency=low + + * New upstream release + * Fixed pid-file writing (Closes: #119621) + + -- Kenneth Vestergaard Schmidt Mon, 19 Nov 2001 21:41:18 +0100 + +filterproxy (0.29.1-6) unstable; urgency=low + + * Duh. Guess who feels like a fool... (Closes: #102004) + * German added to debconf templates, courtesy of Sebastian Feltel (Closes: #102013) + + -- Kenneth Vestergaard Schmidt Sun, 24 Jun 2001 15:34:35 +0200 + +filterproxy (0.29.1-5) unstable; urgency=low + + * New (improved) initscript, courtesy of Cristian Ionescu-Idbohrn. (Closes: #101912) + + -- Kenneth Vestergaard Schmidt Fri, 22 Jun 2001 14:24:16 +0200 + +filterproxy (0.29.1-4) unstable; urgency=medium + + * Fixed misc. bugs in postrm, which made the package unremoveable. + + -- Kenneth Vestergaard Schmidt Tue, 19 Jun 2001 22:25:40 +0200 + +filterproxy (0.29.1-3) unstable; urgency=low + + * Delete pid-file on remove, delete log-files on purge. Also, keep logs in + separate directory (policy/permissions). (Closes: #100147) + + -- Kenneth Vestergaard Schmidt Tue, 19 Jun 2001 00:40:01 +0200 + +filterproxy (0.29.1-2) unstable; urgency=low + + * Fixed a typo on my part (Closes: #99867) + + -- Kenneth Vestergaard Schmidt Mon, 4 Jun 2001 12:43:17 +0200 + +filterproxy (0.29.1-1) unstable; urgency=low + + * New upstream release (small bugfixes only) + * Fixed a couple of old bugs, and a new (Closes: #99707) + + -- Kenneth Vestergaard Schmidt Sat, 2 Jun 2001 23:22:07 +0200 + +filterproxy (0.29-7) unstable; urgency=low + + * Argh. Crap. (Closes: #95379) + + -- Kenneth Vestergaard Schmidt Fri, 27 Apr 2001 13:21:38 +0200 + +filterproxy (0.29-6) unstable; urgency=low + + * Fixed .pid and .log file placement (Closes: #95181) + + -- Kenneth Vestergaard Schmidt Wed, 25 Apr 2001 19:22:30 +0200 + +filterproxy (0.29-5) unstable; urgency=high + + * Fixes the "hanging installation" bug, caused by the daemon not closing + file descriptors properly. (Closes: #92244) + + -- Kenneth Vestergaard Schmidt Mon, 2 Apr 2001 20:37:35 +0200 + +filterproxy (0.29-4) unstable; urgency=low + + * Moved the "press ENTER" prompt from postinst to debconf, after a + small compliant (sorry about that :(). (Closes: #92126) + + -- Kenneth Vestergaard Schmidt Thu, 29 Mar 2001 23:19:53 +0200 + +filterproxy (0.29-3) unstable; urgency=low + + * Typos, once again (Thue). (Closes: #90674) + + -- Kenneth Vestergaard Schmidt Thu, 22 Mar 2001 13:30:28 +0100 + +filterproxy (0.29-2) unstable; urgency=low + + * Fixed a typo in Rewrite.html (thanks Thue). (Closes: #90546) + * Added $HOME to @INC, problem reported by Thue. (Closes: #90670) + + -- Kenneth Vestergaard Schmidt Thu, 22 Mar 2001 11:24:44 +0100 + +filterproxy (0.29-1) unstable; urgency=low + + * Initial Release. (Closes: #86980, #87161) + + -- Kenneth Vestergaard Schmidt Sat, 10 Mar 2001 00:08:03 +0100 --- filterproxy-0.30.orig/debian/postinst +++ filterproxy-0.30/debian/postinst @@ -0,0 +1,54 @@ +#! /bin/sh +# postinst script for filterproxy +# +# see: dh_installdeb(1) + +# Source debconf library (needed to make "deep magic" work :] ) +. /usr/share/debconf/confmodule + +set +e + +# Next set of statements "loaned" from squid's postinst :) + +# create filterproxy group if it doesn't already exist +if ! grep -q ^filterproxy: /etc/group; then + echo Adding system group: filterproxy + addgroup filterproxy +fi + +# creating filterproxy user if it doesn't already exist +if ! grep -q ^filterproxy: /etc/passwd; then + echo Adding system user: filterproxy + adduser --system --ingroup filterproxy --no-create-home --home /usr/share/filterproxy filterproxy +fi + +usermod -c "FilterProxy" filterproxy +usermod -d "/usr/share/filterproxy" filterproxy +usermod -g "filterproxy" filterproxy +usermod -s "/bin/false" filterproxy + +set -e + +if [ -d /usr/share/filterproxy ]; then + chown -R filterproxy:filterproxy /usr/share/filterproxy + chmod 0750 /usr/share/filterproxy +fi + +# Make sure log directory has correct permissions +chown filterproxy:filterproxy /var/log/filterproxy +chmod 750 /var/log/filterproxy + +# Copy initial config if none exists and chown it. +if [ ! -f /etc/filterproxy.conf ]; then + gzip -cd /usr/share/doc/filterproxy/examples/FilterProxy.conf.gz > /etc/filterproxy.conf + chown filterproxy:filterproxy /etc/filterproxy.conf +fi + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +# Is the daemon buggy? It hangs without this... +db_stop +exit 0 --- filterproxy-0.30.orig/debian/config +++ filterproxy-0.30/debian/config @@ -0,0 +1,11 @@ +#!/bin/sh -e + +# Source debconf library +. /usr/share/debconf/confmodule +db_version 2.0 + +# Display note from author +db_input medium filterproxy/readme || true +db_go + +exit 0 --- filterproxy-0.30.orig/debian/postrm +++ filterproxy-0.30/debian/postrm @@ -0,0 +1,51 @@ +#! /bin/sh +# postrm script for filterproxy +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' overwrit>r> +# for details, see /usr/share/doc/packaging-manual/ + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + if grep -q ^filterproxy: /etc/passwd; then + echo Removing system user: filterproxy + userdel filterproxy + fi + if grep -q ^filterproxy: /etc/group; then + echo Removing system group: filterproxy + groupdel filterproxy + fi + + if [ -f /var/run/filterproxy.pid ]; then + rm /var/run/filterproxy.pid + fi + ;; + + purge) + if [ -d /var/log/filterproxy ]; then + rm -rf /var/log/filterproxy + fi + ;; + + default) + echo "postrm called with unknown argument \`$1'" >&2 + exit 0 + ;; + +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# --- filterproxy-0.30.orig/debian/filterproxy.init +++ filterproxy-0.30/debian/filterproxy.init @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Startup script for FilterProxy + +# Source function library. +DAEMON=/usr/sbin/FilterProxy +NAME=FilterProxy + +# Insert your own options here, like "-f /etc/myconfig" to use /etc/myconf instead of +# /etc/filterproxy.conf +OPTIONS="-f /etc/filterproxy.conf" +PORT=8888 + +[ -x $DAEMON ] || exit 0; + +# See how we were called. +case "$1" in + start) + echo -n "Starting FilterProxy: " + start-stop-daemon --start --name $NAME --chuid filterproxy:filterproxy --exec $DAEMON -- -p $PORT $OPTIONS + echo "done" + ;; + stop) + echo -n "Shutting down FilterProxy: " + start-stop-daemon --stop --oknodo --retry KILL/5 --name $NAME + echo "done" + ;; + restart|force-reload) + $0 stop + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit 0 --- filterproxy-0.30.orig/debian/copyright +++ filterproxy-0.30/debian/copyright @@ -0,0 +1,14 @@ +This package was debianized by Kenneth Vestergaard Schmidt on +Sat, 10 Mar 2001 00:08:03 +0100. + +It was downloaded from http://filterproxy.sourceforge.net + +Upstream Author(s): Bob McElrath + +Copyright: + +FilterProxy is copyright 2000, 2001, 2002 by +Bob McElrath . + +This package is copyrighted under the GNU GPL, version 2. +The GNU GPL can on Debian systems be found in /usr/share/common-licenses/GPL. --- filterproxy-0.30.orig/debian/FilterProxy.8 +++ filterproxy-0.30/debian/FilterProxy.8 @@ -0,0 +1,38 @@ +.TH FILTERPROXY 8 "March 10, 2001" +.SH NAME +filterproxy \- a filtering web proxy +.SH SYNOPSIS +.B filterproxy +.RI [ -h -k -f -p -n] +.br +.SH DESCRIPTION +This manual page documents briefly the +.B filterproxy +command. +This manual page was written for the Debian GNU/Linux distribution +because the original program does not have a manual page. +.PP +\fBfilterproxy\fP is a perl script that acts as a generic web proxy. It is +unique in that it allows "Modules" to be installed that can perform +arbitrary transofrmations on HTML (or any other mime-type). Currently +it filters ads, and compresses HTML content (for a 5-1 speedup on +modems!) Configuration is done with web forms. +.SH OPTIONS +A summary of options is included below. +.TP +.B \-h +Show summary of options. +.TP +.B \-f +Specify an alternate config file (default is /etc/filterproxy/filterproxy.conf) +.TP +.B \-p +Specify the port to which FilterProxy will bind (default is 8888) +.TP +.B \-n +Do not daemonize: stay connected to the terminal from which it was started +and print debugging messages. +.br +.SH AUTHOR +This manual page was written by Kenneth Vestergaard Schmidt , +for the Debian GNU/Linux system (but may be used by others). --- filterproxy-0.30.orig/debian/templates +++ filterproxy-0.30/debian/templates @@ -0,0 +1,60 @@ +Template: filterproxy/readme +Type: note +Description: A note about filtered content: + It is clear to me that rewriting web pages for yourself should not pose any + kind of legal quandry. That is, removing banner ads from HTML is perfectly + legal, just as scribbling in a book you have bought, or ripping pages out of + a book you have bought is legal. + . + What is *not* legal is redistributing modified content. In most cases, HTML + is copyrighted by the site you downloaded it from, and I doubt they would be + very happy if you started redistributing modified copies of their site. + . + DO NOT install FilterProxy to filter other people's content (without their + knowledge and consent). You may be liable for copyright infringement on the + echo pages filtered. FilterProxy is meant to be a PERSONAL ad-filtering proxy. +Description-da: Note omkring filtereret indhold: + Det er selvfølgelig klart for mig, at omskrivning af websider for dig selv + ikke burde medføre nogen former for legale problemer. For eksempel, det er + lige så lovligt at fjerne banner-reklamer fra HTML som det er at skrive i en + bog man selv har købt, eller at rive sider ud af samme bog. + . + Hvad er *ikke* er legalt er at redistribuere modificeret indhold. I de + fleste tilfælde er HTML copyright'ed af den side du downloader det fra, og + jeg tror ikke de vil være særlig glade for at du startede med at + redistribuere modificerede kopier fra deres side. + . + Installer IKKE FilterProxy til at filtrere andre folks indhold (uden deres + kendskab og samtykke). Du kan være ansvarlig for copyrightbrud på de sider + du filtrere. FilterProxy er ment som en PERSONLIG reklame-filtrerende proxy. +Description-de: Hinweise zum gefiltertem inhalt + Es ist klar, das das Filtern von Websites für den privaten Zweck + auch keine Copyright-Rechte verletzen sollte. Das entfernen von + Werbebannern im HTML-Quelltext is legal, genau wie das übernehmen + von Texten aus Büchern, die Sie gekauft haben, oder auch Notizen + in Büchern, die Ihr Eigentum sind. + . + Es ist jedoch nicht legal, die Veränderten Websites weiterzuverteilen. + In den meisten Fällen liegt das Copyright für die HTML-Quelltexte bei + der Seite, von der Sie es haben. Die Seitenbetreiber sind bestimmt + nicht einverstanden, wenn Sie deren Seiten verändert weitergeben. + . + Installieren Sie FilterProxy NICHT, wenn Sie die Seiten anderer + filtern wollen (ohne deren Wissen und Zustimmung). Sie wären dann + für die mögliche Copyright-Verletzung verantwortlich. FilterProxy + ist als rein PRIVATER Werbefilter gedacht. +Description-pt_BR: Uma nota sobre conteúdo filtrado: + Está claro para mim que reescrever páginas web para você mesmo não deve + impor qualquer enquadramento legal. Isto é, remover banners publicitários + de HTML é perfeitamente legal, como também é escrever em um livro que + você comprou, ou retirar páginas de um livro que você comprou. + . + O que *não* é legal é a redistribuição de conteúdo modificado. Na maioria + dos casos, o site do qual você fez o download do HTML possui o copyright + sobre o mesmo e eu duvido que eles fiquem muito felizes caso você + comece a redistribuir cópias modificadas do site deles. + . + NÂO instale o FilterProxy para filtrar conteúdo de outras pessoas (sem + seu conhecimento e consentimento). Você pode ser condenado por infringir + copyright nas páginas filtradas. O FilterProxy foi criado para ser uma + adição de filtragem de proxy PESSOAL. --- filterproxy-0.30.orig/FilterProxy.conf +++ filterproxy-0.30/FilterProxy.conf @@ -15,7 +15,7 @@ 'http_proxy_password' => '', 'info' => 1, 'filtering' => 1, - 'logfile' => 'FilterProxy.log', + 'logfile' => '/var/log/filterproxy/filterproxy.log', 'localhostonly' => 1, 'filters' => { 'http://(\\w+\\.)*theonion\\.com' => { --- filterproxy-0.30.orig/FilterProxy.pl +++ filterproxy-0.30/FilterProxy.pl @@ -33,7 +33,7 @@ $LISTEN_PORT = 8888; # Is also a command-line option $VERSION = "0.30"; $NAME = "FilterProxy \$Revision: 0.35 $VERSION \$"; - chomp($HOME = `pwd`); # change if necessary (needs absolute paths) + chomp($HOME = "/usr/share/filterproxy"); # change if necessary (needs absolute paths) if($HOME =~ m{([-_A-Za-z0-9./]+)}) { # untaint $HOME $HOME = $1; } @@ -69,13 +69,6 @@ use Time::HiRes; # grab this from CPAN use HTML::Mason; # grab this from CPAN -# subclass UserAgent to disallow redirects. -@UserAgent::ISA = qw /LWP::UserAgent/; -sub UserAgent::redirect_ok {0;} -sub UserAgent::get_basic_credentials { - return ($CONFIG->{http_proxy_username}, $CONFIG->{http_proxy_password}); -} - # Configuration saved to config file (This is only in case this info isn't # already in the config file!) Don't change this! The config file overrides it! $CONFIG = {}; @@ -85,7 +78,7 @@ $CONFIG->{debug} = 0; # log debugging messages $CONFIG->{authenable} = 0; # enable authentication of users by password $CONFIG->{localhostonly} = 0;# accept connections from localhost only -$CONFIG->{logfile} = $HOME . "/FilterProxy.log"; # set to "" to disable logfile +$CONFIG->{logfile} = "/var/log/filterproxy/filterproxy.log"; # set to "" to disable logfile $CONFIG->{timeout} = 300; # wait 5 minutes before giving up on outgoing connections. $CONFIG->{filters} = {}; $CONFIG->{http_proxy} = ""; @@ -119,13 +112,7 @@ my(%options); getopts('nhkf:p:', \%options); if($options{'k'}) { # kill running FilterProxy. - if(-f "$HOME/FilterProxy.pid") { - my($pid) = `cat $HOME/FilterProxy.pid`; - if($pid =~ m{([0-9]+)}) { $pid = $1; } - kill 'INT', $pid; - } else { - print "Can't kill FilterProxy, I don't know it's pid!\n"; - } + print "Please use '/etc/init.d/filterproxy stop'"; exit(0); } if($options{'f'}) { @@ -138,7 +125,6 @@ print < Specify an alternate config file (default is $CONFIG_FILE) -p Specify the port to which FilterProxy will bind @@ -181,7 +167,7 @@ if($CONFIG->{logfile} !~ /^\//) { $CONFIG->{logfile} = $HOME . "/" . $CONFIG->{logfile}; } -open(LOGFILE, ">" . $CONFIG->{logfile}) || die "unable to open logfile ", $CONFIG->{logfile}, ".\n"; +open(LOGFILE, ">>" . $CONFIG->{logfile}) || die "unable to open logfile ", $CONFIG->{logfile}, ".\n"; autoflush LOGFILE 1; # Initialize the daemon. @@ -192,23 +178,37 @@ . "Is $HOSTNAME:$LISTEN_PORT correct?"; # Initialize agent. -$agent = new UserAgent; -$agent -> agent (0); # Preserve the request's User-Agent header". -if($CONFIG->{http_proxy}) { $agent->proxy('http', $CONFIG->{http_proxy}); } -$agent -> env_proxy(); # process http_proxy environment variable -$agent -> parse_head(0); # don't parse the section of HTML documents -$agent -> timeout($CONFIG->{timeout}); +my($env_proxy) = 0; # determine if we should read proxy environment variables +if(defined $ENV{http_proxy} && $ENV{http_proxy} =~ /http:\/\/.*$HOSTNAME\:$LISTEN_PORT/) { + $env_proxy = 0; +} else { $env_proxy = 1; } + +$agent = new LWP::UserAgent( + agent => undef, # "FilterProxy $VERSION" Preserve the request's User-Agent header. + timeout => $CONFIG->{timeout}, + protocols_allowed => ['http','https','ftp'], + protocols_forbidden => ['file','mailto'], + requests_redirectable => [], # We want to pass all redirects back to browser. + parse_head => 0, # don't parse the section of HTML documents + env_proxy => $env_proxy, # we will override env var http_proxy with CONFIG below + keep_alive => 10, # keep a connection cache with 10 hosts. + ); +if($CONFIG->{http_proxy}) { + $agent->proxy('http', $CONFIG->{http_proxy}); +} +$agent->no_proxy('localhost',`hostname`); # FIXME will this fix fork-bomb? # Initialize HTML::Mason -my($parser) = new HTML::Mason::Parser(allow_globals => ['$MODULECONFIG', '$SITECONFIG', '$SITE', +my($interp) = new HTML::Mason::Interp(comp_root => "$HOME/html", + data_dir => "$HOME/Mason", code_cache_max_size => 1024*1024); +my($compiler) = $interp->compiler; +$compiler->allow_globals('$MODULECONFIG', '$SITECONFIG', '$SITE', '$VERSION', '$MESSAGE', '$MODULES', '$AUTH_TYPE', '$CONTENT_LENGTH', '$CONTENT_TYPE', '$GATEWAY_INTERFACE', '$PATH_TRANSLATED', '$PATH_INFO', '$PATH_TRANSLATED', '$QUERY_STRING', '$REMOTE_PORT', '$REMOTE_ADDR', '$REMOTE_HOST', '$REMOTE_ADDR', '$REMOTE_USER', '$REQUEST_METHOD', '$SCRIPT_NAME', '$SERVER_NAME', '$SERVER_PORT', - '$SERVER_PROTOCOL', '$SERVER_SOFTWARE', '$CGI', '$r', '$CONFIG']); + '$SERVER_PROTOCOL', '$SERVER_SOFTWARE', '$CGI', '$r', '$CONFIG'); # CGI parameters. (FIXME there are more: HTTP headers) -my($interp) = new HTML::Mason::Interp(parser => $parser, comp_root => "$HOME/html", - data_dir => "$HOME/Mason", code_cache_max_size => 1024*1024); # perhaps unnecessary, but helpful... if($CONFIG->{'first_time'}) { @@ -226,12 +226,12 @@ STDOUT->autoflush(1); # autoflush stdout STDERR->autoflush(1); # autoflush stderr $0 = "FilterProxy"; - if(open(PIDFILE, ">$HOME/FilterProxy.pid")) { - print PIDFILE $$; - close(PIDFILE); - } else { - logger(ERROR, "Unable to open pid file! ($!)\n"); # so I can kill myself easily - } +# if(open(PIDFILE, ">/var/run/filterproxy/filterproxy.pid")) { +# print PIDFILE $$; +# close(PIDFILE); +# } else { +# logger(ERROR, "Unable to open pid file! ($!)\n"); # so I can kill myself easily +# } } # Make deaths give line numbers, and wait for children @@ -266,6 +266,9 @@ if(keys %children) { kill 'INT' => keys %children; } +# open(PIDFILE, ">/var/run/filterproxy/filterproxy.pid"); +# print PIDFILE ""; +# close(PIDFILE); logger(INFO, "Received signal SIGINT/SIGTERM/QUIT, exiting..."); exit; # clean up with dignity } @@ -312,6 +315,11 @@ if(!defined $client) { logger(ERROR, "Client died because: ", $daemon->reason); next; } else { my($peername) = getpeername($client); + if(!defined $peername) { + logger(WARNING, "getpeername returned an error"); + logger(WARNING, "\$client is " . (defined $client->connected)?("connected to " . $client->connected):"not connected"); + next; + } my($port, $iaddr, $name); ($port, $iaddr) = sockaddr_in($peername); $name = gethostbyaddr($iaddr, AF_INET); @@ -348,12 +356,12 @@ open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; umask 0; - if(open(PIDFILE, ">$HOME/FilterProxy.pid")) { - print PIDFILE $$; - close(PIDFILE); - } else { - logger(ERROR, "Unable to open pid file! ($!)\n"); # so I can kill myself easily - } +# if(open(PIDFILE, ">/var/run/filterproxy/filterproxy.pid")) { +# print PIDFILE $$; +# close(PIDFILE); +# } else { +# logger(ERROR, "Unable to open pid file! ($!)\n"); # so I can kill myself easily +# } } sub logger { @@ -594,6 +602,10 @@ sub data_handler { # this is only called on success. my($data, $res, $protocol) = @_; + if(!defined $client->connected()) { + logger(DEBUG, "Client aborted download"); + die("Client aborted download"); # Causes LWP to abort its download too. + } if($received == 0) { # if this is the first data block, do headers if($inreq->method ne 'HEAD' && # no content for HEAD requests. (!defined $res->content_length || grep {$res->content_type =~ $_} @filterable)) { @@ -618,6 +630,7 @@ } } } + return ""; } # Handle one proxy request. @@ -875,7 +888,7 @@ my($remote_port, $remote_addr) = sockaddr_in(getpeername($client)); # Globals for HTML::Mason - $interp->{out_method} = $res->content_ref; + $interp->out_method($res->content_ref); $interp->set_global(MESSAGE => defined $message?$message:""); $interp->set_global(SITE => $SITE); $interp->set_global(VERSION => defined $module?(defined ${$fullmodule . "::VERSION"}?${$fullmodule . "::VERSION"}:""):$VERSION); @@ -911,11 +924,13 @@ $param_name = "HTTP_" . $param_name; $interp->set_global($param_name => shift); }); - my($component) = $parser->make_component(script_file=>"$HOME/html/$file", error=>\$error); - if($error) { $client->send_error(RC_INTERNAL_SERVER_ERROR); logger(ERROR, "HTML::Mason::Parser error: $error"); return; } + + my($component) = + eval { $interp->make_component(comp_file=>"$HOME/html/$file"); + }; + if($@) { $client->send_error(RC_INTERNAL_SERVER_ERROR); logger(ERROR, "HTML::Mason::Parser error: $@"); return; } $error = $interp->exec($component); - if($error) { $client->send_error(RC_INTERNAL_SERVER_ERROR); logger(ERROR, "HTML::Mason error: $error"); return; } -# if($content) { $res->content($content); } + if($error) { $client->send_error(RC_INTERNAL_SERVER_ERROR); logger(ERROR, "HTML::Mason::Interp error: $error"); return; } $res->header('Pragma' => 'no-cache'); $res->content_length(length(${$res->content_ref})); } else {