--- polipo-1.0.4.1.orig/debian/docs
+++ polipo-1.0.4.1/debian/docs
@@ -0,0 +1 @@
+README
--- polipo-1.0.4.1.orig/debian/watch
+++ polipo-1.0.4.1/debian/watch
@@ -0,0 +1,2 @@
+version=3
+http://www.pps.jussieu.fr/~jch/software/files/polipo/ polipo-(\d*\.\d*\.\d*)\.tar\.gz
--- polipo-1.0.4.1.orig/debian/polipo.cron.daily
+++ polipo-1.0.4.1/debian/polipo.cron.daily
@@ -0,0 +1,20 @@
+#!/bin/sh        
+set -e
+
+FORBIDDEN_FILE=/etc/polipo/forbidden
+CONFIG_FILE=/etc/polipo/config
+
+if [ ! -x /usr/bin/polipo ]; then
+  exit 0
+fi
+
+if [ ! -f $FORBIDDEN_FILE ]; then
+  FORBIDDEN_FILE=/dev/null
+fi  
+
+PIDFILE=/var/run/polipo/polipo.pid
+[ -f "$PIDFILE" ] && kill -USR1 $(cat "$PIDFILE")
+su -c \
+	"nice polipo -x -c $CONFIG_FILE forbiddenFile=$FORBIDDEN_FILE > /dev/null" \
+	proxy
+[ -f "$PIDFILE" ] && kill -USR2 $(cat "$PIDFILE")
--- polipo-1.0.4.1.orig/debian/polipo.preinst
+++ polipo-1.0.4.1/debian/polipo.preinst
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+set -e
+
+# Remove a no-longer used conffile
+rm_conffile() {
+    local PKGNAME="$1"
+    local CONFFILE="$2"
+
+    [ -e "$CONFFILE" ] || return 0
+
+    local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')"
+    local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PKGNAME | \
+            sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
+    if [ "$md5sum" != "$old_md5sum" ]; then
+        echo "Obsolete conffile $CONFFILE has been modified by you."
+        echo "Saving as $CONFFILE.dpkg-bak ..."
+        mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
+    else
+        echo "Removing obsolete conffile $CONFFILE ..."
+        mv -f "$CONFFILE" "$CONFFILE".dpkg-del
+    fi
+}
+
+case "$1" in
+install|upgrade)
+    if dpkg --compare-versions "$2" le "1.0.4.1-1"; then
+        rm_conffile polipo /etc/ppp/ip-up.d/1polipo
+        rm_conffile polipo /etc/ppp/ip-down.d/1polipo
+        rm_conffile polipo /etc/network/if-up.d/01polipo
+        rm_conffile polipo /etc/network/if-down.d/01polipo
+    fi
+esac
+
+#DEBHELPER#
--- polipo-1.0.4.1.orig/debian/compat
+++ polipo-1.0.4.1/debian/compat
@@ -0,0 +1 @@
+5
--- polipo-1.0.4.1.orig/debian/polipo.info
+++ polipo-1.0.4.1/debian/polipo.info
@@ -0,0 +1 @@
+polipo.info
--- polipo-1.0.4.1.orig/debian/polipo.manpages
+++ polipo-1.0.4.1/debian/polipo.manpages
@@ -0,0 +1 @@
+polipo.man
--- polipo-1.0.4.1.orig/debian/init.d
+++ polipo-1.0.4.1/debian/init.d
@@ -0,0 +1,79 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          polipo
+# Required-Start:    $remote_fs
+# Required-Stop:     $remote_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start or stop the polipo web cache
+### END INIT INFO
+#
+# Author:	Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>
+#
+
+set -e
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+PPCTL=/usr/lib/polipo/polipo-control
+test -x $PPCTL  || exit 0
+
+NAME=polipo
+DESC=polipo
+
+# Include polipo defaults if available
+#if [ -f /etc/default/polipo ] ; then
+#	. /etc/default/polipo
+#fi
+
+# Make sure /var/run/polipo exists.
+if [ ! -e /var/run/$NAME ] ; then
+	mkdir -p /var/run/$NAME
+	chown proxy:proxy /var/run/$NAME
+	chmod 755 /var/run/$NAME
+fi
+
+case "$1" in
+  start)
+	echo -n "Starting $DESC: "
+        $PPCTL start
+	echo "$NAME."
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+        $PPCTL stop
+	echo "$NAME."
+	;;
+  #reload)
+	#
+	#	If the daemon can reload its config files on the fly
+	#	for example by sending it SIGHUP, do it here.
+	#
+	#	If the daemon responds to changes in its config file
+	#	directly anyway, make this a do-nothing entry.
+	#
+	# echo "Reloading $DESC configuration files."
+	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
+	#	/var/run/$NAME.pid --exec $DAEMON
+  #;;
+  restart|force-reload)
+	#
+	#	If the "reload" option is implemented, move the "force-reload"
+	#	option to the "reload" entry above. If not, "force-reload" is
+	#	just the same as "restart".
+	#
+	echo -n "Restarting $DESC: "
+        $PPCTL stop
+	sleep 1
+        $PPCTL start
+	echo "$NAME."
+	;;
+  *)
+	N=/etc/init.d/$NAME
+	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
--- polipo-1.0.4.1.orig/debian/README.Debian
+++ polipo-1.0.4.1/debian/README.Debian
@@ -0,0 +1,50 @@
+polipo for Debian
+-----------------
+
+Polipo is available from http://www.pps.jussieu.fr/~jch/software/polipo/.
+
+There was a webpage devoted to this Debian package which you can find at
+http://www.srcf.ucam.org/~teh30/debian/polipo/. But due new maintainer,
+new versions not available there. Look up the Debian repository for it.
+
+
+How to use polipo for Debian
+----------------------------
+
+Configure your browser to use a proxy on host 'localhost', port '8123'.
+
+
+  Online documentation
+  --------------------
+
+Once polipo is running, online documentation is available at
+http://127.0.0.1:8123/doc/.  Alternatively you can find the same information
+on the Polipo website: http://www.pps.jussieu.fr/~jch/software/polipo/manual/
+
+
+  Allowing other computers to access polipo
+  -----------------------------------------
+
+By default polipo will only accept local connections.  If you want other
+computers on your network to be able to use this machine as a web cache,
+then uncomment the 'proxyAddress' line in /etc/polipo/config.  For
+security's sake you should enable the 'allowedClients' variable and add the
+address of your network, e.g. 'allowedClients = 127.0.0.1, 194.168.42.0/24'. 
+You might also want to set 'disableLocalInterface=true', otherwise all the
+proxy's users can see what pages the others have been accessing.
+
+
+  Using polipo with a modem or a mobile connection
+  ------------------------------------------------
+
+Polipo will go on- and offline automatically whenever PPP (modem) or
+other network connections are established or brought down. You can
+specify on which type of connection this behaviour will occur by editing
+the file /etc/polipo/options and setting the method option to the
+appropriate value, i.e. `method ppp'. For IPv4 the following methods
+allowed: any for any method (default), static, manual, dhcp, bootp, ppp,
+wvdial. The loopback method is not applicable. You can find a list of
+these methods in the interfaces(5) manpage. Note: you can add multiple
+`method' lines in the options file.
+
+ -- Denis V. Sirotkin <fechiny@gmail.com>, Sun, 29 Jul 2007 18:26:38 +0600
--- polipo-1.0.4.1.orig/debian/copyright
+++ polipo-1.0.4.1/debian/copyright
@@ -0,0 +1,28 @@
+This package was debianized by Tom Huckstep <t.huckstep@bigfoot.com> on
+Sun, 14 Dec 2003 12:55:35 +0000.
+
+It was downloaded from: http://www.pps.jussieu.fr/~jch/software/files/
+
+Upstream Author: Juliusz Chroboczek <jch@pps.jussieu.fr>
+
+Copyright:
+
+Copyright (c) 2003 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
--- polipo-1.0.4.1.orig/debian/changelog
+++ polipo-1.0.4.1/debian/changelog
@@ -0,0 +1,358 @@
+polipo (1.0.4.1-1.2.6.201403261801) ucs4-0-0-0; urgency=low
+
+  * UCS auto build. No patches were applied to the original source package
+
+ -- Univention builddaemon <buildd@univention.de>  Wed, 26 Mar 2014 18:01:24 +0100
+
+polipo (1.0.4.1-1.2) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Enable hardened build flags, patch by Steven Chamberlain (Closes: #666451)
+  * Fix CVE-2011-3596 (Closes: #644289)	
+
+ -- Moritz Muehlenhoff <jmm@debian.org>  Fri, 01 Jun 2012 16:46:13 +0200
+
+polipo (1.0.4.1-1.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Delete obsolete /etc/network/if-{up,down}.d and /etc/ppp/ip-{up,down}.d
+    scripts (closes: #578684).
+  * Add patch cherry-picked from upstream git to stop ignoring CNAMEs after a
+    DNS timeout (closes: #540912).
+  * Add dependency on $remote_fs to init.d script (it needs /usr).  Pointed
+    out by lintian.
+  * Change doc-base section from web to Network/Web Browsing.  Pointed out by
+    lintian.
+
+ -- Julien Cristau <jcristau@debian.org>  Sat, 22 May 2010 14:09:29 +0200
+
+polipo (1.0.4.1-1) unstable; urgency=low
+
+  * New maintainer.
+  * New upstream release.
+  * Update Standards-Version to 3.8.4. 
+  * Remove duplicate word in long description (closes: #574613) 
+  * Remove 30_log-permission patch. (closes: #481601)
+  * Remove 40_segfault_max_age.dpatch. (closes: #547047)
+  * Remove 50_integer_overflow.dpatch. Fixed upstream.
+  * Remove 60_security_fixes.dpatch. Fixed upstream.
+  * Put /var/cache/polipo and /var/log/polipo in the .deb and 
+    stop managing them in postinst and postrm.
+  * Remove offline and online options from polipo-control.
+
+ -- Erinn Clark <erinn@torproject.org>  Wed, 31 Mar 2010 19:26:20 -0700
+
+polipo (1.0.4-3) unstable; urgency=high
+
+  * QA upload.
+  * Backport various security related bug fixes from upstream git.
+
+ -- Stefan Fritsch <sf@debian.org>  Fri, 29 Jan 2010 19:02:07 +0100
+
+polipo (1.0.4-2) unstable; urgency=high
+
+  [ Andreas Kirschbaum ]
+  * Apply upstream commit to fix DoS via overly large "Content-Length"
+    header; fixes CVE-2009-3305 (closes: #560779)
+
+  [ Julien Cristau ]
+  * QA upload.
+  * Set Maintainer to Debian QA Group (see #566150).
+  * High urgency for RC bugfix.
+
+ -- Julien Cristau <jcristau@debian.org>  Wed, 27 Jan 2010 15:01:52 +0100
+
+polipo (1.0.4-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload for RC bug fix.
+  * Fix segfault when server sends Cache-Control: max-age without a value
+    (closes: #547047).
+
+ -- Stefan Fritsch <sf@debian.org>  Wed, 23 Sep 2009 21:29:43 +0200
+
+polipo (1.0.4-1) unstable; urgency=low
+
+  * New upstream release
+  * Create /var/cache/polipo, /var/log/polipo and /var/run/polipo
+    directories by postinst script. /var/log/polipo now has proxy:adm
+    owners and 2755 rights, log files are proxy:adm 640 (closes: #291822)
+  * Remove /var/cache/polipo, /var/log/polipo and /var/run/polipo
+    directories by postrm script, make full cleanup on purging package
+  * debian/control: change Standards-Version to 3.7.3
+  * debian/control: move Homepage to pseudo-header
+  * init.d: make sure /var/run/polipo exists
+  * init.d: remove the S runlevel from Default-Stop
+
+ -- Denis V. Sirotkin <fechiny@gmail.com>  Fri, 11 Jan 2008 23:13:27 +0500
+
+polipo (1.0.3-1) unstable; urgency=low
+
+  * New upstream release
+  * Changed pattern in the debian/watch to avoid searching testing versions
+    like `polipo-20071001'
+
+ -- Denis V. Sirotkin <fechiny@gmail.com>  Mon, 08 Oct 2007 19:21:32 +0600
+
+polipo (1.0.2-1) unstable; urgency=low
+
+  * New upstream release (closes: #439441)
+
+ -- Denis V. Sirotkin <fechiny@gmail.com>  Mon, 27 Aug 2007 18:25:05 +0600
+
+polipo (1.0.1-2) unstable; urgency=low
+
+  * Install the sample forbidden file into /etc/polipo
+  * Added network if-up/down scripts similar to ppp ip-up/down
+    (closes: #305852, #418715)
+  * Added debian/watch file
+  * debian/compat: changed debhelper compatibility to 5
+  * debian/control: changed Build-Depends on debhelper (>= 5)
+  * dpatch applied
+
+ -- Denis V. Sirotkin <fechiny@gmail.com>  Sun, 29 Jul 2007 18:25:25 +0600
+
+polipo (1.0.1-1) unstable; urgency=low
+
+  * New upstream release
+  * New maintainer (closes: #430411)
+
+ -- Denis V. Sirotkin <fechiny@gmail.com>  Wed, 27 Jun 2007 14:37:06 +0600
+
+polipo (1.0.0-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Fri, 15 Jun 2007 10:29:16 +0100
+
+polipo (0.9.12-1) unstable; urgency=low
+
+  * New upstream release (closes: #405962, #409998, #405283, #402490)
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Mon, 12 Feb 2007 14:29:39 +0000
+
+polipo (0.9.10-1) unstable; urgency=low
+
+  * New upstream release (closes: #349942, #385751)
+  * Add 'Index' field to 'Info' section of doc-base control file
+    (closes: #372245)
+  * Remove debiandoc-sgml entry from doc-base control file.  This has never
+    existed, as far as I remember, and I don't know what it was doing there.
+  * Added LSB-compliant init script header
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Mon,  4 Sep 2006 13:51:33 +0100
+
+polipo (0.9.9-1) unstable; urgency=low
+
+  * New upstream release (closes: #315655, #332411 CAN-2005-3163)
+  * Fixed bug in logrotate script which causes an error when the pidfile
+    does not exist (closes: #294442, thanks to Vineet Kumar)
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Tue,  4 Oct 2005 14:35:02 +0100
+
+polipo (0.9.8-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Mon, 24 Jan 2005 23:22:46 +0000
+
+polipo (0.9.7-2) unstable; urgency=low
+
+  * Apply lax HTTP parser patch so that Polipo continues to talk to servers
+    whose HTTP is buggy (closes: #265128)
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Fri, 14 Jan 2005 11:22:18 +0000
+
+polipo (0.9.7-1) unstable; urgency=low
+
+  * New upstream release
+  * /var/cache/polipo, /var/log/polipo and /var/run/polipo now have
+    permissions 750, for privacy  (closes: #283523, thanks to Hugo Haas)
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Mon, 27 Dec 2004 17:58:22 +0000
+
+polipo (0.9.6-1) unstable; urgency=low
+
+  * New upstream release (closes #277985, #265128)
+  * forbiddenFile can be a directory: fix polipo-control accordingly, closes #277929
+    (thanks to VSJ)
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Sun, 31 Oct 2004 19:32:21 +0000
+
+polipo (0.9.5-1) unstable; urgency=low
+
+  * New upstream release (closes: #253150, #253156)
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Mon, 21 Jun 2004 22:04:28 +0100
+
+polipo (0.9.4-3) unstable; urgency=low
+
+  * Append ".patch" suffix to "debian/patches/polipo--devel--0--patch-23",
+    so that it actually applies.
+  * polipo-control: Quote "`nameOfPID $PID`".  Thanks to Gergely Nagy,
+    closes: #251071
+  * Applied polipo--devel--0--patch-25 to fix char signedness issues. 
+    Thanks to Gergely Nagy, closes #250419
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Sun, 30 May 2004 22:20:36 +0100
+
+polipo (0.9.4-2) unstable; urgency=low
+
+  * Applied polipo--devel--0--patch-23 to fix 'connection->flags &
+    2' assertion bug
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Sun, 16 May 2004 10:34:41 +0100
+
+polipo (0.9.4-1) unstable; urgency=low
+
+  * New upstream release
+  * Renamed /etc/ppp/ip-up/down.d/polipo to /etc/ppp/ip-up/down.d/1polipo,
+    so that polipo comes online pretty soon after PPP is brought up,
+    closes: #249051
+  * Put polipo.ppp.ip-up/down in ip-up/down directories, because I'm now
+    using the name '1polipo' instead of 'polipo'.  A CDBS script I wrote
+    (debian/cdbs/ip-updown.mk) deals with installing these files.
+  * polipo.postinst: move ip-up/down.d/polipo to polipo.old,
+    because we are now using the name '1polipo', but we do not want to
+    delete a former conffile.  'polipo.old' will not be run by run-parts.
+  * Actually set the variable $OPTION_FILE in ip-up/down.d/polipo, instead
+    of stupidly leaving it dangling.
+
+ -- Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Sat, 15 May 2004 11:04:36 +0100
+
+polipo (0.9.3-4) unstable; urgency=low
+
+  * Standards-Version: 3.6.1
+  * Lengthed package description, closes: #245160
+
+ -- Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Sun, 25 Apr 2004 12:25:26 +0100
+
+polipo (0.9.3-3) unstable; urgency=low
+
+  * Override DEB_MAKE_INVOKE, since the upstream Makefile expects CFLAGS to
+    be left untouched.  Fixes LOCAL_ROOT, DISK_CACHE_ROOT exchange bug.
+
+ -- Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Fri,  9 Apr 2004 21:45:17 +0100
+
+polipo (0.9.3-2) unstable; urgency=low
+
+  * Build system is now CDBS
+  * Added Build-Depends: debhelper (>= 4.1.0), cdbs
+  * CDBS: debian/cbds/helper-scripts.mk installs all the scripts in
+          debian/helper-scripts/$PACKAGE_NAME
+  * PATCH: Upstream request->ohandler crash bug patch
+
+ -- Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Thu,  8 Apr 2004 14:44:08 +0100
+
+polipo (0.9.3-1) unstable; urgency=low
+
+  * New upstream release
+  * /usr/lib/polipo/polipo-control removes stale pidfiles before running
+    polipo.  Now polipo will start even if the last one crashed.
+
+ -- Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Tue,  6 Apr 2004 22:06:41 +0100
+
+polipo (0.9.2-2) unstable; urgency=low
+
+  * Created /var/lib/polipo/polipo-control as an abstraction for starting,
+    stopping, going offline and online
+  * init.d and ppp.ip-up/down now use polipo-control
+
+ -- Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Tue, 30 Mar 2004 15:08:05 +0100
+
+polipo (0.9.2-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Mon, 29 Mar 2004 00:08:41 +0100
+
+polipo (0.9.1-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Fri, 12 Mar 2004 21:53:46 +0000
+
+polipo (0.9-2) unstable; urgency=low
+
+  * server.c: upstream patch to fix "Connection to (host) is broken" in
+    Konqueror
+
+ -- Tom Ellis Huckstep <tom-debian-polipo@jaguarpaw.co.uk>  Sun,  7 Mar 2004 10:35:00 +0000
+
+polipo (0.9-1) unstable; urgency=low
+
+  * New upstream release
+  * Use in scripts: proxyOffline=true/false rather than proxyOffline=3/0. 
+    The latter is no longer valid.
+  * control/Build-Depends: added texinfo (for makeinfo)
+
+ -- Tom Ellis Huckstep <t.huckstep@bigfoot.com>  Sat, 21 Feb 2004 12:37:57 +0000
+
+polipo (0.8.4-1) unstable; urgency=low
+
+  * New upstream release
+  * init.d: fix off/online mode detection bug
+  * polipo.logrotate: reopen logfile with -USR1
+  * polipo.cron.daily: run purge command as user "proxy"
+  * polipo.ppp.ip-up/down: fix $HOME expansion bug
+
+ -- Tom Ellis Huckstep <t.huckstep@bigfoot.com>  Sun, 11 Jan 2004 13:15:03 +0000
+
+polipo (0.8.3-3) unstable; urgency=low
+
+  * polipo.cron.daily: redirect stdout of purge command to /dev/null. 
+    Closes another bug reported by Martin Bretschneider.
+  * init.d script now decides to start in online or offline mode by seeing
+    if the kernel has a default route.  It no longer takes
+    /etc/polipo/options into account.
+  * init.d script runs polipo with config file and forbidden file specified.
+    This fixes complaints about not being able to expand $HOME.
+  * cron.daily script runs polipo with config file and forbidden file
+    specified.  This fixes complaints about not being able to expand $HOME. 
+  * ip-up/down come into action unless "noppp" is specified in
+    /etc/polipo/options
+
+ -- Tom Ellis Huckstep <t.huckstep@bigfoot.com>  Sat, 27 Dec 2003 23:09:27 +0000
+
+polipo (0.8.3-2) unstable; urgency=low
+
+  * init.d script now decides whether to start in offline mode by looking at
+    /etc/polipo/options
+  * Added ip-up/down scripts to switch between offline and online modes
+  * Fixed bug in init.d/polipo: restart and force-reload targets now start
+    polipo as proxy:proxy rather than root:root
+  * Added cache purging to cron.daily
+  * Changed initscript S and K priorities to 30, because that's what 'oops'
+    has
+  * Decided on permissions polipo:polipo 644 for /var/log/polipo/*
+  * Create /var/log/polipo in postinst.  Closes bug reported by Martin
+    Bretschneider
+
+ -- Tom Ellis Huckstep <t.huckstep@bigfoot.com>  Tue, 23 Dec 2003 15:41:58 +0000
+
+polipo (0.8.3-1) unstable; urgency=low
+
+  * New upstream release
+  * rules install target is now install.binary
+  * init.d/polipo now uses the new daemonise and pidFile options to give
+    correct 'start' behaviour
+  * added a logrotate config
+
+ -- Tom Ellis Huckstep <t.huckstep@bigfoot.com>  Mon, 22 Dec 2003 00:09:16 +0000
+
+polipo (0.8.2-2) unstable; urgency=low
+
+  * Changed package synopsis and description in accordance with the
+    packaging manual best practices
+  * Use dh_installinfo and dh_installman instead of entries in the
+    upstream Makefile
+
+ -- Tom Ellis Huckstep <t.huckstep@bigfoot.com>  Wed, 17 Dec 2003 12:21:55 +0000
+
+polipo (0.8.2-1) unstable; urgency=low
+
+  * Initial Release.
+  * Changed the Makfile to install into DESTDIR
+  * Install the sample config file into /etc/polipo
+
+ -- Tom Ellis Huckstep <t.huckstep@bigfoot.com>  Sun, 14 Dec 2003 12:55:35 +0000
+
--- polipo-1.0.4.1.orig/debian/polipo.logrotate
+++ polipo-1.0.4.1/debian/polipo.logrotate
@@ -0,0 +1,10 @@
+/var/log/polipo/polipo.log {
+        create 644 proxy proxy
+        rotate 7
+        compress
+        daily
+        postrotate
+		PIDFILE=/var/run/polipo/polipo.pid
+		if [ -f "$PIDFILE" ] ; then kill -USR1 $(cat "$PIDFILE") ; fi
+        endscript
+}
--- polipo-1.0.4.1.orig/debian/polipo.doc-base
+++ polipo-1.0.4.1/debian/polipo.doc-base
@@ -0,0 +1,13 @@
+Document: polipo
+Title: Debian polipo Manual
+Author: Juliusz Chroboczek
+Abstract: The Polipo web cache
+Section: Network/Web Browsing
+
+Format: Info
+Index: /usr/share/info/polipo.info.gz
+Files: /usr/share/info/polipo.info.gz
+
+Format: HTML
+Index: /usr/share/polipo/www/index.html
+Files: /usr/share/polipo/www/*.html
--- polipo-1.0.4.1.orig/debian/polipo.postinst
+++ polipo-1.0.4.1/debian/polipo.postinst
@@ -0,0 +1,59 @@
+#!/bin/sh
+# postinst script for polipo
+
+set -e
+
+CACHE_DIR=/var/cache/polipo
+LOG_DIR=/var/log/polipo
+
+IPUP_D=/etc/ppp/ip-up.d
+IPDOWN_D=/etc/ppp/ip-down.d
+
+rm_conffile() {
+    local PKGNAME="$1" # Unused
+    local CONFFILE="$2"
+    if [ -f "$CONFFILE".dpkg-del ]; then
+        rm -f "$CONFFILE".dpkg-del
+    fi
+}
+
+case "$1" in
+    configure)
+
+        # delete obsolete conffiles
+        if dpkg --compare-versions "$2" le 1.0.4.1-1; then
+            rm_conffile polipo /etc/ppp/ip-up.d/1polipo
+            rm_conffile polipo /etc/ppp/ip-down.d/1polipo
+            rm_conffile polipo /etc/network/if-up.d/01polipo
+            rm_conffile polipo /etc/network/if-down.d/01polipo
+        fi
+
+# Creating needed directories
+        mkdir -p "$CACHE_DIR"
+	chown proxy:proxy "$CACHE_DIR"
+	chmod 750 "$CACHE_DIR"
+
+	if [ -e "$LOG_DIR" ]; then
+	    chmod -R 640 "$LOG_DIR"
+	fi
+	mkdir -p "$LOG_DIR"
+	chown proxy:adm "$LOG_DIR"
+	chmod 2755 "$LOG_DIR"
+
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
+
--- polipo-1.0.4.1.orig/debian/control
+++ polipo-1.0.4.1/debian/control
@@ -0,0 +1,37 @@
+Source: polipo
+Section: web
+Priority: optional
+Maintainer: Erinn Clark <erinn@torproject.org>
+Build-Depends: debhelper (>= 5), cdbs, texinfo, dpatch
+Standards-Version: 3.8.4
+Homepage: http://www.pps.jussieu.fr/~jch/software/polipo/
+
+Package: polipo
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: a small, caching web proxy
+ Polipo is a caching web proxy (a web cache) designed to be used by one
+ person or a small group of people. It is similar in spirit to WWWOFFLE, but
+ the implementation techniques are more like the ones used by Squid.
+ .
+ Polipo has some features that are unique among currently available proxies:
+ .
+  o Polipo will use HTTP/1.1 pipelining if it believes that the remote
+  server supports it, whether the incoming requests are pipelined or
+  come in simultaneously on multiple connections (this is more than the
+  simple usage of persistent connections, which is done by e.g. Squid);
+ .
+  o Polipo will cache the initial segment of an instance if the
+  download has been interrupted, and, if necessary, complete it later
+  using Range requests;
+ .
+  o Polipo will upgrade client requests to HTTP/1.1 even if they come
+  in as HTTP/1.0, and up- or downgrade server replies to the client's
+  capabilities (this may involve conversion to or from the HTTP/1.1
+  chunked encoding);
+ .
+  o Polipo has fairly complete support for IPv6 (except for scoped
+  (link-local) addresses).
+ .
+ Optionally, Polipo can use a technique known as Poor Man's Multiplexing
+ to reduce latency.
--- polipo-1.0.4.1.orig/debian/polipo.postrm
+++ polipo-1.0.4.1/debian/polipo.postrm
@@ -0,0 +1,55 @@
+#!/bin/sh
+# postrm script for polipo
+
+set -e
+
+CACHE_DIR=/var/cache/polipo
+PID_DIR=/var/run/polipo
+LOG_DIR=/var/log/polipo
+
+IPUP_D=/etc/ppp/ip-up.d
+IPDOWN_D=/etc/ppp/ip-down.d
+
+rm_conffile() {
+    local PKGNAME="$1" # Unused
+    local CONFFILE="$2"
+
+    if [ -f "$CONFFILE".dpkg-del ]; then
+        mv -f "$CONFFILE".dpkg-del "$CONFFILE"
+    fi
+}
+
+case "$1" in
+    purge)
+
+# Remove polipo related directories
+	for DIR in "$CACHE_DIR" "$PID_DIR" "$LOG_DIR"; do
+	    echo -n "Purging $DIR..."
+	    rm -rf "$DIR"
+	    echo " done"
+	done
+
+    ;;
+
+    abort-install|abort-upgrade)
+        if dpkg --compare-versions "$2" le 1.0.4.1-1; then
+            rm_conffile polipo /etc/ppp/ip-up.d/1polipo
+            rm_conffile polipo /etc/ppp/ip-down.d/1polipo
+            rm_conffile polipo /etc/network/if-up.d/01polipo
+            rm_conffile polipo /etc/network/if-down.d/01polipo
+        fi
+    ;;
+
+    remove|upgrade|failed-upgrade|disappear)
+
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+
+esac
+
+#DEBHELPER#
+
+exit 0
--- polipo-1.0.4.1.orig/debian/options
+++ polipo-1.0.4.1/debian/options
@@ -0,0 +1,9 @@
+# See the /usr/share/doc/polipo/README.Debian file for details on this file
+
+method any
+#method static
+#method manual
+#method dhcp
+#method bootp
+#method ppp
+#method wvdial
--- polipo-1.0.4.1.orig/debian/rules
+++ polipo-1.0.4.1/debian/rules
@@ -0,0 +1,16 @@
+#!/usr/bin/make -f
+include /usr/share/cdbs/1/rules/dpatch.mk
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/makefile.mk
+include debian/cdbs/helper-scripts.mk
+include debian/cdbs/options.mk
+
+DPKG_EXPORT_BUILDFLAGS = 1
+include /usr/share/dpkg/buildflags.mk
+
+DEB_MAKE_INVOKE = $(DEB_MAKE_ENVVARS) make -C $(DEB_BUILDDIR)
+
+DEB_MAKE_BUILD_TARGET = all
+DEB_MAKE_INSTALL_TARGET = install.binary DESTDIR=$(DEB_DESTDIR)
+
+DEB_FIXPERMS_EXCLUDE = /var/cache/polipo /var/log/polipo
--- polipo-1.0.4.1.orig/debian/patches/20_config.dpatch
+++ polipo-1.0.4.1/debian/patches/20_config.dpatch
@@ -0,0 +1,56 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 20_config.dpatch by Denis V. Sirotkin <fechiny@gmail.com>
+## Original changes was done by Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>
+##
+## DP: Change description
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+	echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+	exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+
+--- polipo-1.0.1.orig/config.sample
++++ polipo-1.0.1/config.sample
+@@ -1,8 +1,7 @@
+ # Sample configuration file for Polipo. -*-sh-*-
+ 
+-# You should not need to use a configuration file; all configuration
+-# variables have reasonable defaults.  If you want to use one, you
+-# can copy this to /etc/polipo/config or to ~/.polipo and modify.
++# You should not need to edit this configuration file; all configuration
++# variables have reasonable defaults.
+ 
+ # This file only contains some of the configuration variables; see the
+ # list given by ``polipo -v'' and the manual for more.
+@@ -17,11 +16,11 @@
+ # proxyAddress = "::0"        # both IPv4 and IPv6
+ # proxyAddress = "0.0.0.0"    # IPv4 only
+ 
+-# If you do that, you'll want to restrict the set of hosts allowed to
+-# connect:
+-
+-# allowedClients = "127.0.0.1, 134.157.168.57"
+-# allowedClients = "127.0.0.1, 134.157.168.0/24"
++# If you are enabling 'proxyAddress' above, then you want to enable the
++# 'allowedClients' variable to the address of your network, e.g.
++# allowedClients = 127.0.0.1, 192.168.42.0/24
++                                            
++# allowedClients = 127.0.0.1              
+ 
+ # Uncomment this if you want your Polipo to identify itself by
+ # something else than the host name:
--- polipo-1.0.4.1.orig/debian/patches/30_Don-t-spuriously-ignore-CNAMEs-after-a-DNS-timeout.dpatch
+++ polipo-1.0.4.1/debian/patches/30_Don-t-spuriously-ignore-CNAMEs-after-a-DNS-timeout.dpatch
@@ -0,0 +1,45 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 30_Don-t-spuriously-ignore-CNAMEs-after-a-DNS-timeout.dpatch by Alan Jenkins
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Don't spuriously ignore CNAMEs after a DNS timeout
+## DP: cherry-picked from 1144bc9a25fe685bf5a8d18a22d4fa79b9ade75b
+
+@DPATCH@
+
+From 1144bc9a25fe685bf5a8d18a22d4fa79b9ade75b Mon Sep 17 00:00:00 2001
+From: Juliusz Chroboczek <jch@pps.jussieu.fr>
+Date: Tue, 10 Nov 2009 16:48:04 -0800
+Subject: [PATCH] Don't spuriously ignore CNAMEs after a DNS timeout.
+
+Ignore-this: 60fbb7453699ecbff6961bf1622dfb3
+From Alan Jenkins.
+
+darcs-hash:20091111004804-4cc09-0d24709fbdebd5a7bdc5ce01a6a76aab5bc1241c.gz
+---
+ dns.c |    9 +++++++++
+ 1 files changed, 9 insertions(+), 0 deletions(-)
+
+diff --git a/dns.c b/dns.c
+index 8d4ac75..1a5b39b 100644
+--- a/dns.c
++++ b/dns.c
+@@ -1181,6 +1181,15 @@ dnsReplyHandler(int abort, FdEventHandlerPtr event)
+         } else
+             releaseAtom(value);
+     } else if(af == 0) {
++        /* Ignore errors in this case. */
++        if(query->inet4 && query->inet4->length == 0) {
++            releaseAtom(query->inet4);
++            query->inet4 = NULL;
++        }
++        if(query->inet6 && query->inet6->length == 0) {
++            releaseAtom(query->inet6);
++            query->inet6 = NULL;
++        }
+         if(query->inet4 || query->inet6) {
+             do_log(L_WARN, "Host %s has both %s and CNAME -- "
+                    "ignoring CNAME.\n", scrub(query->name->string),
+-- 
+1.7.1
+
--- polipo-1.0.4.1.orig/debian/patches/00list
+++ polipo-1.0.4.1/debian/patches/00list
@@ -0,0 +1,4 @@
+10_makefile.dpatch
+20_config.dpatch
+30_Don-t-spuriously-ignore-CNAMEs-after-a-DNS-timeout.dpatch
+40_CVE-2011-3596.dpatch
\ No newline at end of file
--- polipo-1.0.4.1.orig/debian/patches/10_makefile.dpatch
+++ polipo-1.0.4.1/debian/patches/10_makefile.dpatch
@@ -0,0 +1,58 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 10_makefile.dpatch by Denis V. Sirotkin <fechiny@gmail.com>
+## Original changes was done by Tom Huckstep <tom-debian-polipo@jaguarpaw.co.uk>
+##
+## DP: Change description
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+	echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+	exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+
+--- polipo-1.0.1.orig/Makefile
++++ polipo-1.0.1/Makefile
+@@ -1,4 +1,5 @@
+-PREFIX = /usr/local
++PREFIX = /usr
++TARGET = $(DESTDIR)
+ BINDIR = $(PREFIX)/bin
+ MANDIR = $(PREFIX)/man
+ INFODIR = $(PREFIX)/info
+@@ -62,7 +63,7 @@
+ 
+ DEFINES = $(FILE_DEFINES) $(PLATFORM_DEFINES)
+ 
+-CFLAGS = $(MD5INCLUDES) $(CDEBUGFLAGS) $(DEFINES) $(EXTRA_DEFINES)
++override CFLAGS += $(MD5INCLUDES) $(CDEBUGFLAGS) $(DEFINES) $(EXTRA_DEFINES)
+ 
+ SRCS = util.c event.c io.c chunk.c atom.c object.c log.c diskcache.c main.c \
+        config.c local.c http.c client.c server.c auth.c tunnel.c \
+@@ -91,10 +92,13 @@
+ 	mkdir -p $(TARGET)$(BINDIR)
+ 	mkdir -p $(TARGET)$(LOCAL_ROOT)
+ 	mkdir -p $(TARGET)$(LOCAL_ROOT)/doc
++	mkdir -p $(TARGET)/etc/polipo
+ 	rm -f $(TARGET)$(BINDIR)/polipo
+ 	cp -f polipo $(TARGET)$(BINDIR)/
+ 	cp -f html/* $(TARGET)$(LOCAL_ROOT)/doc
+ 	cp -f localindex.html $(TARGET)$(LOCAL_ROOT)/index.html
++	cp -f config.sample $(TARGET)/etc/polipo/config
++	cp -f forbidden.sample $(TARGET)/etc/polipo/forbidden
+ 
+ install.man: all
+ 	mkdir -p $(TARGET)$(MANDIR)/man1
--- polipo-1.0.4.1.orig/debian/patches/40_CVE-2011-3596.dpatch
+++ polipo-1.0.4.1/debian/patches/40_CVE-2011-3596.dpatch
@@ -0,0 +1,217 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+
+@DPATCH@
+
+From 0e2b44af619e46e365971ea52b97457bc0778cd3 Mon Sep 17 00:00:00 2001
+From: Christopher Davis <chrisd@mangrin.org>
+Date: Mon, 11 Jan 2010 18:55:41 -0800
+Subject: [PATCH] Try to read POST requests to local configuration interface correctly.
+
+---
+ client.c |    1 -
+ local.c  |  113 +++++++++++++++++++++++++++++++++++++++++--------------------
+ 2 files changed, 76 insertions(+), 38 deletions(-)
+
+diff --git a/client.c b/client.c
+index 18f1d72..2404c81 100644
+--- a/client.c
++++ b/client.c
+@@ -987,7 +987,6 @@ httpClientDiscardBody(HTTPConnectionPtr connection)
+         connection->reqlen = 0;
+         httpConnectionDestroyReqbuf(connection);
+     }
+-    connection->reqte = TE_UNKNOWN;
+ 
+     if(connection->bodylen > 0) {
+         httpSetTimeout(connection, clientTimeout);
+diff --git a/local.c b/local.c
+index 82106c4..f59ab63 100644
+--- a/local.c
++++ b/local.c
+@@ -67,8 +67,8 @@ httpLocalRequest(ObjectPtr object, int method, int from, int to,
+                                   requestor, closure);
+ 
+     if(method >= METHOD_POST) {
++        httpClientDiscardBody(requestor->connection);
+         httpClientError(requestor, 405, internAtom("Method not allowed"));
+-        requestor->connection->flags &= ~CONN_READER;
+         return 1;
+     }
+ 
+@@ -295,11 +295,47 @@ httpSpecialRequest(ObjectPtr object, int method, int from, int to,
+     return 1;
+ }
+ 
++#define MAXBODY(c) (((c)->flags & CONN_BIGREQBUF)? bigBufferSize : CHUNK_SIZE)
++
++static void
++writeContinue(HTTPConnectionPtr client)
++{
++    static char httpContinue[] = "HTTP/1.1 100 Continue\r\n\r\n";
++
++    /* don't bother writing continue if the post is already completed */
++    if (client->reqlen - client->reqbegin < client->bodylen) {
++        do_stream(IO_WRITE, client->fd, 0, httpContinue, 25,
++                  httpErrorNofinishStreamHandler, client);
++    }
++}
++
++static int
++validateRequest(HTTPConnectionPtr client)
++{
++    ObjectPtr object = client->request->object;
++  
++    if (disableConfiguration) {
++        abortObject(object, 403, internAtom("Action not allowed"));
++    } else if (client->bodylen > MAXBODY(client)) {
++        abortObject(object, 411, internAtom("POST too large"));
++    } else if (!matchUrl("/polipo/status", object) &&
++               !matchUrl("/polipo/config", object)) {
++        abortObject(object, 404, internAtom("Not found"));
++    } else
++        return 0;
++
++    httpClientDiscardBody(client);
++    notifyObject(object);
++    
++    return -1;
++}
++
+ int 
+ httpSpecialSideRequest(ObjectPtr object, int method, int from, int to,
+                        HTTPRequestPtr requestor, void *closure)
+ {
+     HTTPConnectionPtr client = requestor->connection;
++    int waiting = 0;
+ 
+     assert(client->request == requestor);
+ 
+@@ -309,13 +345,24 @@ httpSpecialSideRequest(ObjectPtr object, int method, int from, int to,
+         return 1;
+     }
+ 
++    if (requestor->flags & REQUEST_WAIT_CONTINUE) {
++        requestor->flags &= ~REQUEST_WAIT_CONTINUE;
++        waiting = 1;
++    }
++
++    if (validateRequest(client) < 0)
++        return 1;
++
++    if (waiting)
++        writeContinue(client);
++
+     return httpSpecialDoSide(requestor);
+ }
+ 
+-int
+-httpSpecialDoSide(HTTPRequestPtr requestor)
++static int
++readFinished(HTTPConnectionPtr client)
+ {
+-    HTTPConnectionPtr client = requestor->connection;
++    HTTPRequestPtr request = client->request;
+ 
+     if(client->reqlen - client->reqbegin >= client->bodylen) {
+         AtomPtr data;
+@@ -325,19 +372,25 @@ httpSpecialDoSide(HTTPRequestPtr requestor)
+         client->reqlen = 0;
+         if(data == NULL) {
+             do_log(L_ERROR, "Couldn't allocate data.\n");
+-            httpClientError(requestor, 500,
++            httpClientError(request, 500,
+                             internAtom("Couldn't allocate data"));
+             return 1;
+         }
+-        httpSpecialDoSideFinish(data, requestor);
++        httpSpecialDoSideFinish(data, request);
+         return 1;
+     }
+ 
+-    if(client->reqlen - client->reqbegin >= CHUNK_SIZE) {
+-        httpClientError(requestor, 500, internAtom("POST too large"));
+-        return 1;
+-    }
++    return 0;
++}
+ 
++int
++httpSpecialDoSide(HTTPRequestPtr requestor)
++{
++    HTTPConnectionPtr client = requestor->connection;
++
++    if (readFinished(client))
++        return 1;   
++ 
+     if(client->reqbegin > 0 && client->reqlen > client->reqbegin) {
+         memmove(client->reqbuf, client->reqbuf + client->reqbegin,
+                 client->reqlen - client->reqbegin);
+@@ -346,7 +399,7 @@ httpSpecialDoSide(HTTPRequestPtr requestor)
+     client->reqbegin = 0;
+ 
+     do_stream(IO_READ | IO_NOTNOW, client->fd,
+-              client->reqlen, client->reqbuf, CHUNK_SIZE,
++              client->reqlen, client->reqbuf, MAXBODY(client),
+               httpSpecialClientSideHandler, client);
+     return 1;
+ }
+@@ -358,36 +411,22 @@ httpSpecialClientSideHandler(int status,
+ {
+     HTTPConnectionPtr connection = srequest->data;
+     HTTPRequestPtr request = connection->request;
+-    int push;
+ 
+-    if((request->object->flags & OBJECT_ABORTED) || 
+-       !(request->object->flags & OBJECT_INPROGRESS)) {
+-        httpClientDiscardBody(connection);
+-        httpClientError(request, 503, internAtom("Post aborted"));
+-        return 1;
+-    }
+-        
+-    if(status < 0) {
+-        do_log_error(L_ERROR, -status, "Reading from client");
+-        if(status == -EDOGRACEFUL)
+-            httpClientFinish(connection, 1);
+-        else
+-            httpClientFinish(connection, 2);
++    if(status) {
++        connection->flags &= ~CONN_READER;
++        if (request->chandler) {
++            unregisterConditionHandler(request->chandler);
++            request->chandler = NULL;
++        }
++        do_log(L_ERROR, "Incomplete client request.\n");
++        httpClientRawError(connection, 502,
++                           internAtom("Incomplete client request"), 1);
+         return 1;
+     }
+ 
+-    push = MIN(srequest->offset - connection->reqlen,
+-               connection->bodylen - connection->reqoffset);
+-    if(push > 0) {
+-        connection->reqlen += push;
+-        httpSpecialDoSide(request);
+-    }
++    connection->reqlen = srequest->offset;
+ 
+-    do_log(L_ERROR, "Incomplete client request.\n");
+-    connection->flags &= ~CONN_READER;
+-    httpClientRawError(connection, 502,
+-                       internAtom("Incomplete client request"), 1);
+-    return 1;
++    return readFinished(connection);
+ }
+ 
+ int
+@@ -480,7 +519,7 @@ httpSpecialDoSideFinish(AtomPtr data, HTTPRequestPtr requestor)
+         object->flags &= ~OBJECT_INITIAL;
+         object->length = 0;
+     } else {
+-        abortObject(object, 405, internAtom("Method not allowed"));
++        abortObject(object, 404, internAtom("Not found"));
+     }
+ 
+  out:
+-- 
+1.7.2.5
+
--- polipo-1.0.4.1.orig/debian/helper-scripts/polipo/polipo-control
+++ polipo-1.0.4.1/debian/helper-scripts/polipo/polipo-control
@@ -0,0 +1,104 @@
+#!/bin/sh
+
+set -e
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+DAEMON=/usr/bin/polipo
+test -x $DAEMON || exit 0
+
+CONFIG_FILE=/etc/polipo/config
+FORBIDDEN_FILE=/etc/polipo/forbidden
+
+NAME=polipo
+
+PIDFILE=/var/run/$NAME/$NAME.pid
+LOGFILE=/var/log/$NAME/$NAME.log
+USER=proxy
+GROUP=proxy
+DAEMON_OPTS="-c $CONFIG_FILE pidFile=$PIDFILE daemonise=true logFile=$LOGFILE"
+
+forbiddenFile() {
+        if [ -f $FORBIDDEN_FILE ] || [ -d $FORBIDDEN_FILE ]; then
+                echo -n $FORBIDDEN_FILE
+        else
+                echo -n /dev/null
+        fi
+}
+
+waitForPIDRemove() {
+        T=30
+        for i in `seq 1 $T`; do
+                if [ ! -f $PIDFILE ]; then return; fi
+                sleep 1
+        done
+        echo "Waited $T seconds and $PIDFILE did not disappear.  Giving up." 2>&1
+}
+
+# Outputs the binary name of the process with PID $1, e.g. /usr/sbin/polipo
+nameOfPID() {
+	ps -o command= -p $1 | cut -f1 '-d '
+}
+
+# Returns true if the pidfile exists, and there is a polipo process running
+# with the PID therein.  False otherwise.
+alreadyRunning() {
+	if [ -r $PIDFILE ]; then
+		PID=`cat $PIDFILE`
+		if [ "`nameOfPID $PID`" = $DAEMON ]; then
+			return 0 # TRUE
+		fi
+	fi
+	return 1 # FALSE
+}
+
+# Deletes polipo's pidfile if it exists
+# This is designed to remove the pidfile from a crashed polipo before
+# starting a new one
+removePIDFile() {
+	if [ -e $PIDFILE ]; then
+		echo -n "Removing stale pidfile"
+		rm $PIDFILE
+		echo "."
+	fi
+}
+
+DAEMON_OPTS="$DAEMON_OPTS forbiddenFile=`forbiddenFile`"
+
+polipo_start() {
+
+	if alreadyRunning; then
+		echo "$DAEMON already running -- doing nothing"
+		exit
+	fi	
+
+	removePIDFile
+
+        start-stop-daemon --start --quiet --pidfile $PIDFILE \
+                --chuid $USER:$GROUP --exec $DAEMON -- $DAEMON_OPTS
+}
+
+polipo_stop() {
+        start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+                --oknodo --exec $DAEMON
+}
+
+case "$1" in
+  start)
+        polipo_start
+        ;;
+  stop)
+        polipo_stop
+        ;;
+  restart)
+        polipo_stop
+        waitForPIDRemove
+        polipo_start
+        ;;
+  *)
+        N=polipo-control
+        echo "Usage: $N {start|stop}" >&2
+        exit 1         
+esac
+
+exit 0
--- polipo-1.0.4.1.orig/debian/cdbs/helper-scripts.mk
+++ polipo-1.0.4.1/debian/cdbs/helper-scripts.mk
@@ -0,0 +1,10 @@
+common-install-arch::
+	shopt nullglob; \
+	for p in debian/helper-scripts/*; do \
+		PACKAGE=`basename $$p` ;\
+		for script in $$p/*; do \
+			S=`basename $$script` ;\
+			install --mode=755 -D $$script \
+				$(DEB_DESTDIR)/usr/lib/$$PACKAGE/$$S ;\
+		done ;\
+	done
--- polipo-1.0.4.1.orig/debian/cdbs/options.mk
+++ polipo-1.0.4.1/debian/cdbs/options.mk
@@ -0,0 +1,9 @@
+common-install-arch::
+	shopt nullglob; \
+	install --mode=644 -D debian/options $(DEB_DESTDIR)/etc/polipo/
+	mkdir -p $(DEB_DESTDIR)/var/cache/polipo
+	chown proxy:proxy $(DEB_DESTDIR)/var/cache/polipo
+	chmod 755 $(DEB_DESTDIR)/var/cache/polipo
+	mkdir -p $(DEB_DESTDIR)/var/log/polipo
+	chown proxy:adm $(DEB_DESTDIR)/var/log/polipo
+	chmod 2755 $(DEB_DESTDIR)/var/log/polipo
