summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Wijsman <tomwij@gentoo.org>2013-05-30 16:44:03 +0000
committerTom Wijsman <tomwij@gentoo.org>2013-05-30 16:44:03 +0000
commitff2c0a86218d9c5d0e77dbb68561f2d3e5889dd7 (patch)
treeb80e57fe233af8bcfdb3c291e33a0ff5343c2977 /net-proxy
parenttc-export RANLIB too, by Michael Mair-Keimberger (iamnr3), bug #465746 (diff)
downloadgentoo-2-ff2c0a86218d9c5d0e77dbb68561f2d3e5889dd7.tar.gz
gentoo-2-ff2c0a86218d9c5d0e77dbb68561f2d3e5889dd7.tar.bz2
gentoo-2-ff2c0a86218d9c5d0e77dbb68561f2d3e5889dd7.zip
Use /run instead of /var/run, fixes bug #444167. Apply DoS Prevention patches, temporary fixes for bug #432046. Fix ChangeLog issues; there was an empty log message above header by flameeyes and an empty message by jer.
(Portage version: 2.1.12.2/cvs/Linux x86_64, signed Manifest commit with key 6D34E57D)
Diffstat (limited to 'net-proxy')
-rw-r--r--net-proxy/tinyproxy/ChangeLog11
-rw-r--r--net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2-DoS-Prevention.patch183
-rw-r--r--net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2.initd41
-rw-r--r--net-proxy/tinyproxy/tinyproxy-1.8.3-r2.ebuild83
4 files changed, 311 insertions, 7 deletions
diff --git a/net-proxy/tinyproxy/ChangeLog b/net-proxy/tinyproxy/ChangeLog
index a51c6f5edb26..0055f9e3a5e6 100644
--- a/net-proxy/tinyproxy/ChangeLog
+++ b/net-proxy/tinyproxy/ChangeLog
@@ -1,15 +1,12 @@
-
-*tinyproxy-1.8.3-r1 (29 May 2013)
+# ChangeLog for net-proxy/tinyproxy
+# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/tinyproxy/ChangeLog,v 1.42 2013/05/30 16:44:03 tomwij Exp $
29 May 2013; Diego E. Pettenò <flameeyes@gentoo.org>
+files/tinyproxy-1.8.3.initd, +tinyproxy-1.8.3-r1.ebuild:
Cleanup ebuild, use REQUIRED_USE, always install docs, improve init script so
that now it actually works.
-# ChangeLog for net-proxy/tinyproxy
-# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-proxy/tinyproxy/ChangeLog,v 1.41 2013/05/29 17:48:35 flameeyes Exp $
-
24 Apr 2013; Jeroen Roovers <jer@gentoo.org> tinyproxy-1.8.3.ebuild:
Disable silent make rules. Fix building with automake-1.13.
@@ -26,7 +23,7 @@
27 Aug 2011; Jeroen Roovers <jer@gentoo.org> -tinyproxy-1.6.3-r1.ebuild,
-tinyproxy-1.6.4.ebuild, -tinyproxy-1.6.5.ebuild, -tinyproxy-1.8.2.ebuild,
-files/tinyproxy-no-via.patch:
- ^
+ Removed old.
27 Aug 2011; Raúl Porcel <armin76@gentoo.org> tinyproxy-1.8.3.ebuild:
alpha/ia64/sparc stable wrt #363425
diff --git a/net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2-DoS-Prevention.patch b/net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2-DoS-Prevention.patch
new file mode 100644
index 000000000000..059f178c1ee2
--- /dev/null
+++ b/net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2-DoS-Prevention.patch
@@ -0,0 +1,183 @@
+https://banu.com/bugzilla/show_bug.cgi?id=110#c4
+
+From 526215dbb4abb1cff9a170343fa50dbda9492eb1 Mon Sep 17 00:00:00 2001
+From: Michael Adam <obnox@samba.org>
+Date: Fri, 15 Mar 2013 12:34:01 +0100
+Subject: [PATCH 1/2] [BB#110] secure the hashmaps by adding a seed
+
+Based on patch provided by gpernot@praksys.org on bugzilla.
+
+Signed-off-by: Michael Adam <obnox@samba.org>
+---
+ configure.ac | 2 ++
+ src/child.c | 1 +
+ src/hashmap.c | 14 ++++++++------
+ 3 files changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index ecbcba0..cc40e85 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,8 @@ AC_CHECK_FUNCS([gethostname inet_ntoa memchr memset select socket strcasecmp \
+ AC_CHECK_FUNCS([isascii memcpy setrlimit ftruncate regcomp regexec])
+ AC_CHECK_FUNCS([strlcpy strlcat])
+
++AC_CHECK_FUNCS([time rand srand])
++
+
+ dnl Enable extra warnings
+ DESIRED_FLAGS="-fdiagnostics-show-option -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wfloat-equal -Wundef -Wformat=2 -Wlogical-op -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Waggregate-return -Winit-self -Wpacked --std=c89 -ansi -pedantic -Wno-overlength-strings -Wc++-compat -Wno-long-long -Wno-overlength-strings -Wdeclaration-after-statement -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-qual -Wcast-align -Wwrite-strings -Wp,-D_FORTIFY_SOURCE=2 -fno-common"
+diff --git a/src/child.c b/src/child.c
+index 34e20e0..0d778d9 100644
+--- a/src/child.c
++++ b/src/child.c
+@@ -196,6 +196,7 @@ static void child_main (struct child_s *ptr)
+ }
+
+ ptr->connects = 0;
++ srand(time(NULL));
+
+ while (!config.quit) {
+ ptr->status = T_WAITING;
+diff --git a/src/hashmap.c b/src/hashmap.c
+index f46fdcb..8cf7c6b 100644
+--- a/src/hashmap.c
++++ b/src/hashmap.c
+@@ -50,6 +50,7 @@ struct hashbucket_s {
+ };
+
+ struct hashmap_s {
++ uint32_t seed;
+ unsigned int size;
+ hashmap_iter end_iterator;
+
+@@ -65,7 +66,7 @@ struct hashmap_s {
+ *
+ * If any of the arguments are invalid a negative number is returned.
+ */
+-static int hashfunc (const char *key, unsigned int size)
++static int hashfunc (const char *key, unsigned int size, uint32_t seed)
+ {
+ uint32_t hash;
+
+@@ -74,7 +75,7 @@ static int hashfunc (const char *key, unsigned int size)
+ if (size == 0)
+ return -ERANGE;
+
+- for (hash = tolower (*key++); *key != '\0'; key++) {
++ for (hash = seed; *key != '\0'; key++) {
+ uint32_t bit = (hash & 1) ? (1 << (sizeof (uint32_t) - 1)) : 0;
+
+ hash >>= 1;
+@@ -104,6 +105,7 @@ hashmap_t hashmap_create (unsigned int nbuckets)
+ if (!ptr)
+ return NULL;
+
++ ptr->seed = (uint32_t)rand();
+ ptr->size = nbuckets;
+ ptr->buckets = (struct hashbucket_s *) safecalloc (nbuckets,
+ sizeof (struct
+@@ -201,7 +203,7 @@ hashmap_insert (hashmap_t map, const char *key, const void *data, size_t len)
+ if (!data || len < 1)
+ return -ERANGE;
+
+- hash = hashfunc (key, map->size);
++ hash = hashfunc (key, map->size, map->seed);
+ if (hash < 0)
+ return hash;
+
+@@ -382,7 +384,7 @@ ssize_t hashmap_search (hashmap_t map, const char *key)
+ if (map == NULL || key == NULL)
+ return -EINVAL;
+
+- hash = hashfunc (key, map->size);
++ hash = hashfunc (key, map->size, map->seed);
+ if (hash < 0)
+ return hash;
+
+@@ -416,7 +418,7 @@ ssize_t hashmap_entry_by_key (hashmap_t map, const char *key, void **data)
+ if (!map || !key || !data)
+ return -EINVAL;
+
+- hash = hashfunc (key, map->size);
++ hash = hashfunc (key, map->size, map->seed);
+ if (hash < 0)
+ return hash;
+
+@@ -451,7 +453,7 @@ ssize_t hashmap_remove (hashmap_t map, const char *key)
+ if (map == NULL || key == NULL)
+ return -EINVAL;
+
+- hash = hashfunc (key, map->size);
++ hash = hashfunc (key, map->size, map->seed);
+ if (hash < 0)
+ return hash;
+
+--
+1.7.9.5
+
+https://banu.com/bugzilla/show_bug.cgi?id=110#c5
+
+From f1189daec6866efeb44f24073cd19d7ece86e537 Mon Sep 17 00:00:00 2001
+From: Michael Adam <obnox@samba.org>
+Date: Fri, 15 Mar 2013 13:10:01 +0100
+Subject: [PATCH 2/2] [BB#110] limit the number of headers per request to
+ prevent DoS
+
+Based on patch provided by gpernot@praksys.org on bugzilla.
+
+Signed-off-by: Michael Adam <obnox@samba.org>
+---
+ src/reqs.c | 17 ++++++++++++++++-
+ 1 file changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/src/reqs.c b/src/reqs.c
+index 2de43a8..af014ba 100644
+--- a/src/reqs.c
++++ b/src/reqs.c
+@@ -611,12 +611,19 @@ add_header_to_connection (hashmap_t hashofheaders, char *header, size_t len)
+ }
+
+ /*
++ * define max number of headers.
++ * big enough to handle legitimate cases, but limited to avoid DoS
++ */
++#define MAX_HEADERS 10000
++
++/*
+ * Read all the headers from the stream
+ */
+ static int get_all_headers (int fd, hashmap_t hashofheaders)
+ {
+ char *line = NULL;
+ char *header = NULL;
++ int count;
+ char *tmp;
+ ssize_t linelen;
+ ssize_t len = 0;
+@@ -625,7 +632,7 @@ static int get_all_headers (int fd, hashmap_t hashofheaders)
+ assert (fd >= 0);
+ assert (hashofheaders != NULL);
+
+- for (;;) {
++ for (count = 0; count < MAX_HEADERS; count++) {
+ if ((linelen = readline (fd, &line)) <= 0) {
+ safefree (header);
+ safefree (line);
+@@ -691,6 +698,14 @@ static int get_all_headers (int fd, hashmap_t hashofheaders)
+
+ safefree (line);
+ }
++
++ /*
++ * if we get there, this is we reached MAX_HEADERS count
++ * bail out with error
++ */
++ safefree (header);
++ safefree (line);
++ return -1;
+ }
+
+ /*
+--
+1.7.9.5
diff --git a/net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2.initd b/net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2.initd
new file mode 100644
index 000000000000..6ae617907303
--- /dev/null
+++ b/net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2.initd
@@ -0,0 +1,41 @@
+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/tinyproxy/files/tinyproxy-1.8.3-r2.initd,v 1.1 2013/05/30 16:44:03 tomwij Exp $
+
+get_config() {
+ res=$(awk '$1 == "'$1'" { s=$2 } END { print s }' "$CONFFILE")
+
+ if [ "x$res" = "x" ]; then
+ echo "$2"
+ else
+ eval echo "$res"
+ fi
+}
+
+: ${CONFFILE:="/etc/${SVCNAME}.conf"}
+
+command=/usr/sbin/tinyproxy
+command_args="-c ${CONFFILE}"
+pidfile=$(get_config PidFile /run/tinyproxy/${SVCNAME}.pid)
+
+depend() {
+ config "$CONFFILE"
+
+ use dns
+
+ [ "$(get_config Syslog Off)" = "On" ] && \
+ use logger
+}
+
+start_pre() {
+ piddir=$(dirname ${pidfile})
+
+ if [ "${piddir}" = "/run" ]; then
+ eerror "Please change your PidFile settings to be within the"
+ eerror "/run/tinyproxy directory"
+ eend 1
+ else
+ checkpath -d -o $(get_config User tinyproxy):$(get_config Group tinyproxy) ${piddir}
+ fi
+}
diff --git a/net-proxy/tinyproxy/tinyproxy-1.8.3-r2.ebuild b/net-proxy/tinyproxy/tinyproxy-1.8.3-r2.ebuild
new file mode 100644
index 000000000000..10f3953d11d4
--- /dev/null
+++ b/net-proxy/tinyproxy/tinyproxy-1.8.3-r2.ebuild
@@ -0,0 +1,83 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/tinyproxy/tinyproxy-1.8.3-r2.ebuild,v 1.1 2013/05/30 16:44:03 tomwij Exp $
+
+EAPI="5"
+
+inherit autotools eutils user
+
+DESCRIPTION="A lightweight HTTP/SSL proxy"
+HOMEPAGE="http://www.banu.com/tinyproxy/"
+SRC_URI="http://www.banu.com/pub/${PN}/1.8/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~ia64 ~ppc ~sparc ~x86"
+
+IUSE="test debug +filter-proxy minimal reverse-proxy
+ transparent-proxy +upstream-proxy +xtinyproxy-header"
+
+REQUIRED_USE="test? ( xtinyproxy-header )"
+
+DEPEND="!minimal? ( app-text/asciidoc )"
+
+pkg_setup() {
+ enewgroup ${PN}
+ enewuser ${PN} "" "" "" ${PN}
+}
+
+src_prepare() {
+ epatch "${FILESDIR}"/${PN}-1.8.1-ldflags.patch
+ epatch "${FILESDIR}"/${PF}-DoS-Prevention.patch
+
+ use minimal && epatch "${FILESDIR}/${PN}-1.8.1-minimal.patch"
+
+ sed -i \
+ -e "s|nobody|${PN}|g" \
+ -e 's|/var/run/|/run/|g' \
+ etc/${PN}.conf.in || die "sed failed"
+
+ sed -i \
+ -e 's|AM_CONFIG_HEADER|AC_CONFIG_HEADERS|g' \
+ configure.ac || die
+
+ eautoreconf
+}
+
+src_configure() {
+ if use minimal; then
+ ln -s /bin/true "${T}"/a2x
+ export PATH="${T}:${PATH}"
+ fi
+
+ econf \
+ $(use_enable debug) \
+ $(use_enable filter-proxy filter) \
+ $(use_enable reverse-proxy reverse) \
+ $(use_enable transparent-proxy transparent) \
+ $(use_enable upstream-proxy upstream) \
+ $(use_enable xtinyproxy-header xtinyproxy) \
+ --disable-silent-rules \
+ --localstatedir=/var
+}
+
+src_test() {
+ # The make check target does not run the test suite
+ emake test
+}
+
+src_install() {
+ default
+
+ dodoc AUTHORS ChangeLog NEWS README TODO
+
+ diropts -m0775 -o ${PN} -g ${PN}
+ keepdir /var/log/${PN}
+
+ newinitd "${FILESDIR}"/${PF}.initd tinyproxy
+}
+
+pkg_postinst() {
+ elog "For filtering domains and URLs, enable filter option in the configuration"
+ elog "file and add them to the filter file (one domain or URL per line)."
+}