From b4c487f520bf11233bd0d9a81ee3bd4e7f9c1687 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 18 Aug 2015 21:23:02 +0530 Subject: [PATCH 1/3] package: Fix showing error during pre/post install When an ActionError is raised during pre_install or on_install action, the error is not being shown. Instead an error is being raised. This fixes that. --- plinth/package.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plinth/package.py b/plinth/package.py index 92c968f29..2c7b6d91a 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -263,7 +263,8 @@ def _should_show_install_view(request, package_names): return False else: messages.error(request, _('Error installing packages: {details}') - .format(details=exception.error_string)) + .format(details=getattr(exception, 'error_string', + str(exception)))) return True From ee521e098f77822fa7f4306ea4fe9572ea39f7bc Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 18 Aug 2015 21:25:01 +0530 Subject: [PATCH 2/3] tor: Move Tor setup from freedombox-setup We are still overwriting the entire configuration file instead of modifying it. --- actions/tor | 32 ++++++++++++++++++++++++++++++++ plinth/modules/tor/tor.py | 7 ++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/actions/tor b/actions/tor index d26b0bce4..18617a854 100755 --- a/actions/tor +++ b/actions/tor @@ -39,6 +39,7 @@ def parse_arguments(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') + subparsers.add_parser('setup', help='Setup Tor configuration') subparsers.add_parser('enable', help='Enable and start Tor service') subparsers.add_parser('disable', help='Disable and stop Tor service') subparsers.add_parser('get-hs', help='Get hidden service') @@ -49,6 +50,37 @@ def parse_arguments(): return parser.parse_args() +def subcommand_setup(_): + """Setup Tor configuration after installing it.""" + # XXX: Performing this as a post-install step instead of + # pre-install setup for now. Creating a configuration before hand + # leads dpkg to ask question about configuration overwrite which + # makes aptcc backend of packagekit to wait forever even with + # interactive=False. + lines = """ +# Run as non-exit bridge relay +SocksPort 0.0.0.0:9050 +ORPort auto +ControlPort 9051 +BridgeRelay 1 +Exitpolicy reject *:* + +# Enable obfsproxy +ServerTransportPlugin obfs3,scramblesuit exec /usr/bin/obfsproxy managed +ExtORPort auto + +# Enable transparent proxy +VirtualAddrNetworkIPv4 10.192.0.0/10 +AutomapHostsOnResolve 1 +TransPort 127.0.0.1:9040 +DNSPort 127.0.0.1:9053 +""" + with open(TOR_CONFIG, 'w') as conffile: + conffile.writelines(lines) + + action_utils.service_restart('tor') + + def subcommand_enable(_): """Enable and start the service.""" action_utils.service_enable('tor') diff --git a/plinth/modules/tor/tor.py b/plinth/modules/tor/tor.py index d87099bc1..5fae309df 100644 --- a/plinth/modules/tor/tor.py +++ b/plinth/modules/tor/tor.py @@ -50,7 +50,12 @@ def init(): 'tor:index', 100) -@package.required(['tor']) +def on_install(): + """Setup Tor configuration as soon as it is installed.""" + actions.superuser_run('tor', ['setup']) + + +@package.required(['tor', 'obfsproxy'], on_install=on_install) def index(request): """Service the index page""" status = get_status() From 13655f05bcd1b5bb38726b5b7b539a8dd39fe81d Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 21 Aug 2015 19:24:07 +0530 Subject: [PATCH 3/3] tor: Configure for IPv6 also --- actions/tor | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/actions/tor b/actions/tor index 18617a854..e08781811 100755 --- a/actions/tor +++ b/actions/tor @@ -59,11 +59,13 @@ def subcommand_setup(_): # interactive=False. lines = """ # Run as non-exit bridge relay +SocksPort [::]:9050 SocksPort 0.0.0.0:9050 ORPort auto ControlPort 9051 BridgeRelay 1 Exitpolicy reject *:* +Exitpolicy reject6 *:* # Enable obfsproxy ServerTransportPlugin obfs3,scramblesuit exec /usr/bin/obfsproxy managed @@ -73,7 +75,9 @@ ExtORPort auto VirtualAddrNetworkIPv4 10.192.0.0/10 AutomapHostsOnResolve 1 TransPort 127.0.0.1:9040 +TransPort [::1]:9040 DNSPort 127.0.0.1:9053 +DNSPort [::1]:9053 """ with open(TOR_CONFIG, 'w') as conffile: conffile.writelines(lines)