summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/fw
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/leap/bitmask/vpn/fw
parent580d45199a126a0cc8f0ba0698f4797e5a58997a (diff)
[bug] fix constants import error
Diffstat (limited to 'src/leap/bitmask/vpn/fw')
-rw-r--r--src/leap/bitmask/vpn/fw/firewall.py32
1 files changed, 19 insertions, 13 deletions
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):
"""