From 8cb5716f76472a817df214fccca86a44f6ef34db Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 20 May 2020 16:45:26 -0700 Subject: [PATCH] tor: Fix problems with running a relay This is a fix for regression introduced by ebe6a0ed026e27dc650b4c2fed8426357f959ddc. I have incorrectly assumed that providing only IPv6 ORPort is sufficient to listen on IPv4 and IPv6. As a result, Tor does not run when relay is enabled. Fix this by adding ORPorts for both IPv6 and IPv4. Tests performed: - Tor shows as running after enabling relay functionality. - Adding single or multiple ORPort values in the configuration file leads to actions/tor get-status reporting that relay is enabled. - Functional tests for Tor run properly. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- actions/tor | 10 ++++++---- plinth/modules/tor/__init__.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/actions/tor b/actions/tor index a8ae6c510..bfdcd1c16 100755 --- a/actions/tor +++ b/actions/tor @@ -65,7 +65,7 @@ def parse_arguments(): def subcommand_setup(arguments): """Setup Tor configuration after installing it.""" - if arguments.old_version and arguments.old_version <= 3: + if arguments.old_version and arguments.old_version <= 4: _upgrade_orport_value() return @@ -148,7 +148,8 @@ def _upgrade_orport_value(): aug = augeas_load() if _is_relay_enabled(aug): - aug.set(TOR_CONFIG + '/ORPort', '[::]:9001') + aug.set(TOR_CONFIG + '/ORPort[1]', '9001') + aug.set(TOR_CONFIG + '/ORPort[2]', '[::]:9001') aug.save() @@ -241,7 +242,7 @@ def _get_upstream_bridges(aug): def _is_relay_enabled(aug): """Return whether a relay is enabled.""" - orport = aug.get(TOR_CONFIG + '/ORPort') + orport = aug.get(TOR_CONFIG + '/ORPort[1]') return bool(orport) and orport != '0' @@ -390,7 +391,8 @@ def _enable_relay(relay=None, bridge=None, aug=None): use_upstream_bridges = _are_upstream_bridges_enabled(aug) if relay == 'enable' and not use_upstream_bridges: - aug.set(TOR_CONFIG + '/ORPort', '[::]:9001') + aug.set(TOR_CONFIG + '/ORPort[1]', '9001') + aug.set(TOR_CONFIG + '/ORPort[2]', '[::]:9001') elif relay == 'disable': aug.remove(TOR_CONFIG + '/ORPort') diff --git a/plinth/modules/tor/__init__.py b/plinth/modules/tor/__init__.py index 6c55029f2..f074526f1 100644 --- a/plinth/modules/tor/__init__.py +++ b/plinth/modules/tor/__init__.py @@ -14,13 +14,13 @@ from plinth.daemon import Daemon, diagnose_netcat, diagnose_port_listening from plinth.modules.apache.components import diagnose_url from plinth.modules.firewall.components import Firewall from plinth.modules.names.components import DomainType -from plinth.signals import domain_added, domain_removed from plinth.modules.users.components import UsersAndGroups +from plinth.signals import domain_added, domain_removed from . import utils from .manifest import backup, clients # noqa, pylint: disable=unused-import -version = 4 +version = 5 depends = ['names']