summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkali <kali@leap.se>2018-06-12 11:17:56 -0700
committerKali Kaneko <kali@leap.se>2018-06-13 20:25:33 +0200
commit5a68ef22ccc372c36ab9ba09290e6df8722b6043 (patch)
tree3b04fc57396717d27aacb0b3be0e5cbf42d875e0 /src
parent580d45199a126a0cc8f0ba0698f4797e5a58997a (diff)
[bug] fix constants import error
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/core/service.py3
-rw-r--r--src/leap/bitmask/vpn/fw/firewall.py32
-rw-r--r--src/leap/bitmask/vpn/launchers/darwin.py4
3 files changed, 24 insertions, 15 deletions
diff --git a/src/leap/bitmask/core/service.py b/src/leap/bitmask/core/service.py
index c3672843..a53bfd1d 100644
--- a/src/leap/bitmask/core/service.py
+++ b/src/leap/bitmask/core/service.py
@@ -40,6 +40,9 @@ try:
from leap.bitmask.vpn.service import VPNService
HAS_VPN = True
except ImportError as exc:
+ print "[!] Could not import VPN: %r" % exc
+ # graceful fail for mail-only builds.
+ # set a raise to investigate the full traceback
HAS_VPN = False
diff --git a/src/leap/bitmask/vpn/fw/firewall.py b/src/leap/bitmask/vpn/fw/firewall.py
index 1142b264..9ed2ad98 100644
--- a/src/leap/bitmask/vpn/fw/firewall.py
+++ b/src/leap/bitmask/vpn/fw/firewall.py
@@ -27,13 +27,16 @@ from twisted.logger import Logger
from leap.bitmask.util import STANDALONE
from leap.bitmask.system import IS_MAC, IS_LINUX, IS_SNAP
-from leap.bitmask.vpn.constants import BITMASK_ROOT_SYSTEM
-from leap.bitmask.vpn.constants import BITMASK_ROOT_LOCAL
-from leap.bitmask.vpn.constants import BITMASK_ROOT_SNAP
from leap.common.events import catalog, emit_async
from leap.bitmask.vpn.launchers import darwin
+if IS_LINUX:
+ from leap.bitmask.vpn.constants import BITMASK_ROOT_SYSTEM
+ from leap.bitmask.vpn.constants import BITMASK_ROOT_LOCAL
+ from leap.bitmask.vpn.constants import BITMASK_ROOT_SNAP
+
+
log = Logger()
# A regular user should not run bitmask as root, but we contemplate
@@ -90,7 +93,6 @@ class _LinuxFirewallManager(object):
exceptions.
This allows us to achieve fail close on a vpn connection.
"""
-
# TODO factor out choosing a version of bitmask-root.
# together with linux vpnlauncher.
@@ -101,15 +103,19 @@ class _LinuxFirewallManager(object):
# if this is a bundle, we pick local. bundles ask to install it there.
BITMASK_ROOT = BITMASK_ROOT_LOCAL
else:
- if os.path.isfile(BITMASK_ROOT_SYSTEM):
- # we can be running from the debian package,
- # or some other distro. it's the maintainer responsibility to put
- # bitmask-root there.
- BITMASK_ROOT = BITMASK_ROOT_SYSTEM
- else:
- # as a last case, we fall back to installing into the
- # /usr/local/sbin version.
- BITMASK_ROOT = BITMASK_ROOT_LOCAL
+ try:
+ if os.path.isfile(BITMASK_ROOT_SYSTEM):
+ # we can be running from the debian package,
+ # or some other distro. it's the maintainer responsibility to
+ # put bitmask-root there.
+ BITMASK_ROOT = BITMASK_ROOT_SYSTEM
+ else:
+ # as a last case, we fall back to installing into the
+ # /usr/local/sbin version.
+ BITMASK_ROOT = BITMASK_ROOT_LOCAL
+ except NameError:
+ # not defined for other platforms
+ pass
def __init__(self, remotes):
"""
diff --git a/src/leap/bitmask/vpn/launchers/darwin.py b/src/leap/bitmask/vpn/launchers/darwin.py
index d959b159..3b37e540 100644
--- a/src/leap/bitmask/vpn/launchers/darwin.py
+++ b/src/leap/bitmask/vpn/launchers/darwin.py
@@ -42,8 +42,8 @@ class HelperCommand(object):
self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
self._sock.connect(self.SOCKET_ADDR)
- except socket.error, msg:
- raise RuntimeError('Cannot connect to helper: ' + msg)
+ except socket.error as exc:
+ raise RuntimeError('Cannot connect to helper: %r' % exc)
def send(self, cmd, args=''):
self._connect()