app-admin/denyhosts: fix bug #577502
authorChristoph Junghans <ottxor@gentoo.org>
Wed, 16 Mar 2016 20:33:25 +0000 (14:33 -0600)
committerChristoph Junghans <ottxor@gentoo.org>
Wed, 16 Mar 2016 20:33:50 +0000 (14:33 -0600)
Package-Manager: portage-2.2.26

app-admin/denyhosts/denyhosts-3.0-r1.ebuild [new file with mode: 0644]
app-admin/denyhosts/files/denyhosts-3.0-python2.7.patch [new file with mode: 0644]

diff --git a/app-admin/denyhosts/denyhosts-3.0-r1.ebuild b/app-admin/denyhosts/denyhosts-3.0-r1.ebuild
new file mode 100644 (file)
index 0000000..106c9a7
--- /dev/null
@@ -0,0 +1,67 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+PYTHON_COMPAT=( python2_7 python3_3 python3_4 python3_5 )
+
+inherit distutils-r1 eutils readme.gentoo-r1 systemd
+
+DESCRIPTION="DenyHosts is a utility to help sys admins thwart ssh hackers"
+HOMEPAGE="https://github.com/denyhosts/denyhosts"
+SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ppc ~sparc ~x86"
+IUSE=""
+
+DEPEND=""
+RDEPEND=""
+
+DISABLE_AUTOFORMATTING="yes"
+DOC_CONTENTS="
+>=net-misc/openssh-6.7p1 dropped support for sys-apps/tcp-wrappers
+(see bug#531156) that means you either have patch openssh or use
+denyhosts' iptables feature to get any protection.
+
+You can configure DenyHosts to run as a daemon by running:
+# rc-update add denyhosts default
+or:
+# systemctl enable denyhosts.service
+(if you use systemd)
+
+To run DenyHosts as a cronjob instead of a daemon add the following
+to /etc/crontab
+# run DenyHosts every 10 minutes
+*/10  *  * * *    root    /usr/bin/denyhosts.py -c /etc/denyhosts.conf
+
+More information can be found at ${HOMEPAGE}faq.html"
+
+#bring back python-2.7 support  bug #577502
+PATCHES=( "${FILESDIR}"/"${P}"-python2.7.patch )
+
+src_prepare() {
+       sed -e '/^DENY_THRESHOLD_VALID =/s/=.*/= 5/' \
+               -e '/^SECURE_LOG/s/^/#/' \
+               -e '\@#SECURE_LOG.*/var/log/messages@s/^#//' \
+               -i denyhosts.conf || die "sed failed"
+
+       distutils-r1_src_prepare
+}
+
+src_install() {
+       readme.gentoo_create_doc
+
+       dodoc CHANGELOG.txt README.md
+       distutils-r1_src_install
+
+       dodir /etc/logrotate.d
+       insinto /etc/logrotate.d
+       newins "${FILESDIR}"/${PN}.logrotate-r2 ${PN}
+
+       newinitd "${FILESDIR}"/denyhosts.init-r2 denyhosts
+       systemd_dounit "${FILESDIR}"/${PN}.service
+
+       keepdir /var/lib/denyhosts
+}
diff --git a/app-admin/denyhosts/files/denyhosts-3.0-python2.7.patch b/app-admin/denyhosts/files/denyhosts-3.0-python2.7.patch
new file mode 100644 (file)
index 0000000..4b727c7
--- /dev/null
@@ -0,0 +1,51 @@
+From b5611dfa0510ec8fbaa2db4b6834d0bd7ecf0909 Mon Sep 17 00:00:00 2001
+From: Jesse <jessefrgsmith@yahoo.ca>
+Date: Sat, 27 Jun 2015 20:24:44 -0300
+Subject: [PATCH] Fixed a type check which was causing syntax/undefined errors
+ in DenyHosts/report.py when switching between Python2 and Python3.
+
+---
+ CHANGELOG.txt       | 8 ++++++++
+ DenyHosts/report.py | 4 +++-
+ 2 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/CHANGELOG.txt b/CHANGELOG.txt
+index ca173cb..b585332 100644
+--- a/CHANGELOG.txt
++++ b/CHANGELOG.txt
+@@ -1,5 +1,13 @@
+ DENYHOSTS CHANGELOG
++3.1
++======================
++
++Fixed a type check in DenyHosts/report.py which was causing
++problems when moving between Python2 and Python3.
++
++
++
+ 3.0
+ ======================
+diff --git a/DenyHosts/report.py b/DenyHosts/report.py
+index 05f3e3d..9560eab 100644
+--- a/DenyHosts/report.py
++++ b/DenyHosts/report.py
+@@ -3,6 +3,7 @@
+ import socket
+ # Removing this as it causes runtime errors on Python3.4
+ # from types import ListType, TupleType
++import types
+ from .util import is_true
+ try:
+     import syslog
+@@ -38,7 +39,8 @@ def get_report(self):
+     def add_section(self, message, iterable):
+         self.report += "%s:\n\n" % message
+         for i in iterable:
+-            if type(i) in (TupleType, ListType):
++            # if type(i) in (TupleType, ListType):
++            if (type(i) is types.ListType) or (type(i) is types.TupleType):
+                 extra = ": %d\n" % i[1]
+                 i = i[0]
+             else: