diff options
author | Craig Andrews <candrews@gentoo.org> | 2020-10-19 13:13:20 -0400 |
---|---|---|
committer | Craig Andrews <candrews@gentoo.org> | 2020-10-19 16:07:09 -0400 |
commit | 53473dca46faaaa3a4e20d5f6998b0847a6dda4e (patch) | |
tree | 2afd1b0187b66b66967e08d14e354f3d158ea737 /net-mail | |
parent | net-print/hplip: Remove old hplip-3.20.9. (diff) | |
download | gentoo-53473dca46faaaa3a4e20d5f6998b0847a6dda4e.tar.gz gentoo-53473dca46faaaa3a4e20d5f6998b0847a6dda4e.tar.bz2 gentoo-53473dca46faaaa3a4e20d5f6998b0847a6dda4e.zip |
net-mail/onionrouter: .onion discovery via SRV DNS for postfix
Package-Manager: Portage-3.0.8, Repoman-3.0.2
Signed-off-by: Craig Andrews <candrews@gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/17974
Signed-off-by: Craig Andrews <candrews@gentoo.org>
Diffstat (limited to 'net-mail')
-rw-r--r-- | net-mail/onionrouter/Manifest | 1 | ||||
-rw-r--r-- | net-mail/onionrouter/files/conftest.py | 46 | ||||
-rw-r--r-- | net-mail/onionrouter/files/onionrouter-0.5.2-entrypoint.patch | 25 | ||||
-rw-r--r-- | net-mail/onionrouter/files/onionrouter-0.5.2-newline.patch | 30 | ||||
-rw-r--r-- | net-mail/onionrouter/files/onionrouter-0.5.2-python3.patch | 42 | ||||
-rw-r--r-- | net-mail/onionrouter/files/onionrouter-0.5.2-pyyaml-version.patch | 25 | ||||
-rw-r--r-- | net-mail/onionrouter/files/onionrouter.service | 25 | ||||
-rw-r--r-- | net-mail/onionrouter/metadata.xml | 8 | ||||
-rw-r--r-- | net-mail/onionrouter/onionrouter-0.5.2.ebuild | 54 |
9 files changed, 256 insertions, 0 deletions
diff --git a/net-mail/onionrouter/Manifest b/net-mail/onionrouter/Manifest new file mode 100644 index 000000000000..3da566565405 --- /dev/null +++ b/net-mail/onionrouter/Manifest @@ -0,0 +1 @@ +DIST onionrouter-0.5.2.tar.gz 23497 BLAKE2B f025385323b182350e3481be62bbb9ed037d197d83ee19341f27ec04c391d6e1ee809b5db461437287485496ce139718f774d39de7ebd307ea92d5409220e135 SHA512 9c23a17401c0d56fc8d0b6bc3a0c899d604f6981457643b84040e9cf60626990bbd03fead66bba1c7d5723bd43d95c128bf457380e255f995951970b4788f126 diff --git a/net-mail/onionrouter/files/conftest.py b/net-mail/onionrouter/files/conftest.py new file mode 100644 index 000000000000..d08b5f3aabf3 --- /dev/null +++ b/net-mail/onionrouter/files/conftest.py @@ -0,0 +1,46 @@ +from __future__ import unicode_literals +import pytest +import io +try: + import configparser +except ImportError: + import ConfigParser as configparser +from onionrouter import rerouter, config_handlers + + +config = """ +[RESOLVER] +resolver_ip: 127.0.0.1 +resolver_port: 53 +tcp: True + +[DOMAIN] +hostname: myself.net, myself2.net + +[DNS] +srv_record: _onion-mx._tcp. + +[REROUTE] +onion_transport: smtptor + +[IGNORED] +domains: ignore.me, ignore2.me +""" + + +@pytest.fixture(scope="session", name="dummy_config") +def fixture_config(): + return config + + +@pytest.fixture(scope="function", name="dummy_onionrouter") +def fixture_onionrouter(monkeypatch, dummy_config): + monkeypatch.setattr( + config_handlers, "get_conffile", + lambda *args, **kwargs: rerouter.OnionRouter.ref_config) + custom_config = configparser.ConfigParser() + custom_config._read(io.StringIO(dummy_config), None) + monkeypatch.setattr(config_handlers, "config_reader", + lambda *args: custom_config) + return rerouter.OnionRouter("nothing?") + diff --git a/net-mail/onionrouter/files/onionrouter-0.5.2-entrypoint.patch b/net-mail/onionrouter/files/onionrouter-0.5.2-entrypoint.patch new file mode 100644 index 000000000000..397387483b6f --- /dev/null +++ b/net-mail/onionrouter/files/onionrouter-0.5.2-entrypoint.patch @@ -0,0 +1,25 @@ +https://github.com/ehloonion/onionrouter/pull/16 + +From 06d5c15d61790c9444641de18b9ff23f1c104207 Mon Sep 17 00:00:00 2001 +From: Craig Andrews <candrews@integralblue.com> +Date: Mon, 19 Oct 2020 12:46:08 -0400 +Subject: [PATCH] Change the entry point to rerouter + +Aligns the entry point with the changes made in commit 2e8f7be "Rename onionrouter module to rerouter" +--- + setup.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index baf6041..e487614 100644 +--- a/setup.py ++++ b/setup.py +@@ -40,7 +40,7 @@ + 'onionrouter', + ], + entry_points={ +- "console_scripts": ['onionrouter = onionrouter.onionrouter:main'] ++ "console_scripts": ['onionrouter = onionrouter.rerouter:main'] + }, + include_package_data=True, + install_requires=requirements, diff --git a/net-mail/onionrouter/files/onionrouter-0.5.2-newline.patch b/net-mail/onionrouter/files/onionrouter-0.5.2-newline.patch new file mode 100644 index 000000000000..d75e797f6ac3 --- /dev/null +++ b/net-mail/onionrouter/files/onionrouter-0.5.2-newline.patch @@ -0,0 +1,30 @@ +https://github.com/ehloonion/onionrouter/pull/21 + +From 670690f03fd700e2b06892e2231a8e078cfb41b3 Mon Sep 17 00:00:00 2001 +From: Craig Andrews <candrews@integralblue.com> +Date: Mon, 19 Oct 2020 15:47:41 -0400 +Subject: [PATCH] Send a newline when replying to postfix + +Postfix requires all replies to end in a newline. + +Without this change, postfix logs a warning: +`warning: read TCP map reply from localhost:23000: text longer than 4096` + +See http://www.postfix.org/tcp_table.5.html +--- + onionrouter/msockets.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/onionrouter/msockets.py b/onionrouter/msockets.py +index 8769a2e..8c93693 100644 +--- a/onionrouter/msockets.py ++++ b/onionrouter/msockets.py +@@ -27,7 +27,7 @@ def resolve(rerouter, conn, resolve_callback=lambda q, a: (q, a)): + return + except BaseException as err: + # todo log +- conn.sendall("500 {0}".format(err).encode()) ++ conn.sendall("500 {0}\n".format(err).encode()) + + + def daemonize_server(rerouter, host, port, resolver=resolve): diff --git a/net-mail/onionrouter/files/onionrouter-0.5.2-python3.patch b/net-mail/onionrouter/files/onionrouter-0.5.2-python3.patch new file mode 100644 index 000000000000..a5d017603eef --- /dev/null +++ b/net-mail/onionrouter/files/onionrouter-0.5.2-python3.patch @@ -0,0 +1,42 @@ +https://github.com/ehloonion/onionrouter/pull/20 + +From d059ee499a0ed30239f6c4ee6ea8f144069fbb7d Mon Sep 17 00:00:00 2001 +From: Craig Andrews <candrews@integralblue.com> +Date: Mon, 19 Oct 2020 14:53:46 -0400 +Subject: [PATCH] Perform bytes to string and vice versa conversions + +Python 3 handles bytes and strings as different types + +Fixes https://github.com/ehloonion/onionrouter/issues/19 +--- + onionrouter/msockets.py | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/onionrouter/msockets.py b/onionrouter/msockets.py +index 8769a2e..b77d750 100644 +--- a/onionrouter/msockets.py ++++ b/onionrouter/msockets.py +@@ -13,7 +13,7 @@ def close_socket(sock): + def resolve(rerouter, conn, resolve_callback=lambda q, a: (q, a)): + try: + while True: +- addr = conn.recv(1024).strip() ++ addr = conn.recv(1024).decode().strip() + if not addr: + # connection ended + return +@@ -22,12 +22,12 @@ def resolve(rerouter, conn, resolve_callback=lambda q, a: (q, a)): + else: + result = rerouter.run(addr) + resolve_callback(addr, result) +- conn.sendall("{0}\n".format(result)) ++ conn.sendall("{0}\n".format(result).encode()) + except socket.timeout: + return + except BaseException as err: + # todo log +- conn.sendall("500 {0}".format(err)) ++ conn.sendall("500 {0}".format(err).encode()) + + + def daemonize_server(rerouter, host, port, resolver=resolve): diff --git a/net-mail/onionrouter/files/onionrouter-0.5.2-pyyaml-version.patch b/net-mail/onionrouter/files/onionrouter-0.5.2-pyyaml-version.patch new file mode 100644 index 000000000000..f8c7304a977f --- /dev/null +++ b/net-mail/onionrouter/files/onionrouter-0.5.2-pyyaml-version.patch @@ -0,0 +1,25 @@ +https://github.com/ehloonion/onionrouter/pull/17 + +From cdac2f500b24abaf5833266ad740c56df360e602 Mon Sep 17 00:00:00 2001 +From: Craig Andrews <candrews@integralblue.com> +Date: Mon, 19 Oct 2020 12:56:19 -0400 +Subject: [PATCH] Allow for use of later versions of PyYAML + +commit 5fe349a "Update PyYAML to 4.2b1 due to CVE-2017-18342" set `install_requires` to `PyYAML==4.2b1`. This exact version requirement prohibits the use of later versions of PyYAML. +--- + setup.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index baf6041..85e0b81 100644 +--- a/setup.py ++++ b/setup.py +@@ -11,7 +11,7 @@ + + requirements = [ + "dnspython", +- "PyYAML==4.2b1", ++ "PyYAML>=4.2b1", + ] + + test_requirements = [ diff --git a/net-mail/onionrouter/files/onionrouter.service b/net-mail/onionrouter/files/onionrouter.service new file mode 100644 index 000000000000..bf5d7811f823 --- /dev/null +++ b/net-mail/onionrouter/files/onionrouter.service @@ -0,0 +1,25 @@ +[Unit] +Description=onionrouter +After=network.target tor.service +Before=postfix.service + +[Service] +ExecStart=/usr/bin/onionrouter +Restart=on-failure +RestartSec=10s +DynamicUser=true +PrivateDevices=true +PrivateUsers=true +ProtectClock=true +ProtectControlGroups=true +ProtectHome=true +ProtectKernelLogs=true +ProtectKernelModules=true +ProtectKernelTunables=true +ProtectHostname=true +RestrictRealtime=true +MemoryDenyWriteExecute=true + +[Install] +WantedBy=default.target + diff --git a/net-mail/onionrouter/metadata.xml b/net-mail/onionrouter/metadata.xml new file mode 100644 index 000000000000..fbb8d54dbc4d --- /dev/null +++ b/net-mail/onionrouter/metadata.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>candrews@gentoo.org</email> + <name>Craig Andrews</name> + </maintainer> +</pkgmetadata> diff --git a/net-mail/onionrouter/onionrouter-0.5.2.ebuild b/net-mail/onionrouter/onionrouter-0.5.2.ebuild new file mode 100644 index 000000000000..f8875c8a7400 --- /dev/null +++ b/net-mail/onionrouter/onionrouter-0.5.2.ebuild @@ -0,0 +1,54 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{7,8,9} ) +DISTUTILS_SINGLE_IMPL=1 +DISTUTILS_USE_SETUPTOOLS=rdepend + +inherit distutils-r1 systemd + +DESCRIPTION=".onion discovery via SRV DNS lookups for use with postfix" +HOMEPAGE="https://pypi.org/project/onionrouter/ https://github.com/ehloonion/onionrouter/" +SRC_URI="https://pypi.io/packages/source/${PN::1}/${PN}/${P}.tar.gz" +IUSE="test" +RESTRICT="!test? ( test )" + +LICENSE="GPL-3+" +SLOT="0" +KEYWORDS="~amd64" + +RDEPEND="$(python_gen_cond_dep ' + dev-python/dnspython[${PYTHON_USEDEP}] + dev-python/pyyaml[${PYTHON_USEDEP}] +')" +BDEPEND="$(python_gen_cond_dep ' + test? ( + dev-python/pytest[${PYTHON_USEDEP}] + dev-python/wheel[${PYTHON_USEDEP}] + ) +')" + +PATCHES=( + "${FILESDIR}/${P}-entrypoint.patch" + "${FILESDIR}/${P}-python3.patch" + "${FILESDIR}/${P}-pyyaml-version.patch" + "${FILESDIR}/${P}-newline.patch" +) + +distutils_enable_tests pytest + +src_prepare() { + # https://github.com/ehloonion/onionrouter/pull/15 + cp "${FILESDIR}/conftest.py" "${S}" || die + + distutils-r1_src_prepare +} + +src_install() { + distutils-r1_src_install + systemd_dounit "${FILESDIR}/${PN}.service" + insinto /etc/onionrouter + doins "${S}/onionrouter/configs/onionrouter.ini" +} |