summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/vpn')
-rw-r--r--src/leap/bitmask/vpn/_checks.py3
-rw-r--r--src/leap/bitmask/vpn/_config.py2
-rw-r--r--src/leap/bitmask/vpn/autostart.py2
-rw-r--r--src/leap/bitmask/vpn/constants.py13
-rw-r--r--src/leap/bitmask/vpn/fw/firewall.py2
-rw-r--r--src/leap/bitmask/vpn/helpers/__init__.py4
-rw-r--r--src/leap/bitmask/vpn/launcher.py4
-rw-r--r--src/leap/bitmask/vpn/launchers/linux.py3
-rw-r--r--src/leap/bitmask/vpn/privilege.py4
-rw-r--r--src/leap/bitmask/vpn/process.py2
-rw-r--r--src/leap/bitmask/vpn/service.py2
-rw-r--r--src/leap/bitmask/vpn/tunnel.py2
-rw-r--r--src/leap/bitmask/vpn/utils.py2
13 files changed, 14 insertions, 31 deletions
diff --git a/src/leap/bitmask/vpn/_checks.py b/src/leap/bitmask/vpn/_checks.py
index 2549e366..b4fadb78 100644
--- a/src/leap/bitmask/vpn/_checks.py
+++ b/src/leap/bitmask/vpn/_checks.py
@@ -4,12 +4,11 @@ from datetime import datetime
from time import mktime
from twisted.logger import Logger
+from leap.bitmask.system import IS_LINUX
from leap.bitmask.vpn.privilege import is_pkexec_in_system, NoPkexecAvailable
from leap.common.certs import get_cert_time_boundaries
from leap.common.config import get_path_prefix
-from .constants import IS_LINUX
-
log = Logger()
diff --git a/src/leap/bitmask/vpn/_config.py b/src/leap/bitmask/vpn/_config.py
index 5bb61e78..63b57a78 100644
--- a/src/leap/bitmask/vpn/_config.py
+++ b/src/leap/bitmask/vpn/_config.py
@@ -1,7 +1,7 @@
import os.path
import pkg_resources
-from .constants import IS_LINUX
+from leap.bitmask.system import IS_LINUX
from leap.bitmask.util import STANDALONE, here
if IS_LINUX:
diff --git a/src/leap/bitmask/vpn/autostart.py b/src/leap/bitmask/vpn/autostart.py
index 0572e9d5..1c361d82 100644
--- a/src/leap/bitmask/vpn/autostart.py
+++ b/src/leap/bitmask/vpn/autostart.py
@@ -1,7 +1,7 @@
import os
import os.path
-from leap.bitmask.vpn.constants import IS_LINUX, IS_MAC
+from leap.bitmask.system import IS_LINUX, IS_MAC
from leap.bitmask.util import STANDALONE
from leap.common.config import get_path_prefix
diff --git a/src/leap/bitmask/vpn/constants.py b/src/leap/bitmask/vpn/constants.py
index 868ac193..dce5e81c 100644
--- a/src/leap/bitmask/vpn/constants.py
+++ b/src/leap/bitmask/vpn/constants.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# constants.py
-# Copyright (C) 2015-2017 LEAP
+# Copyright (C) 2015-2018 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,16 +18,7 @@
"""
System constants
"""
-import os
-import platform
-
-_system = platform.system()
-
-IS_LINUX = _system == "Linux"
-IS_MAC = _system == "Darwin"
-IS_UNIX = IS_MAC or IS_LINUX
-IS_WIN = _system == "Windows"
-IS_SNAP = os.environ.get('SNAP')
+from leap.bitmask.system import IS_LINUX
if IS_LINUX:
BITMASK_ROOT_SYSTEM = '/usr/sbin/bitmask-root'
diff --git a/src/leap/bitmask/vpn/fw/firewall.py b/src/leap/bitmask/vpn/fw/firewall.py
index d5b1f018..98b317b0 100644
--- a/src/leap/bitmask/vpn/fw/firewall.py
+++ b/src/leap/bitmask/vpn/fw/firewall.py
@@ -25,7 +25,7 @@ import subprocess
from twisted.logger import Logger
-from leap.bitmask.vpn.constants import IS_MAC, IS_LINUX
+from leap.bitmask.system import IS_MAC, IS_LINUX
from leap.common.events import catalog, emit_async
from leap.bitmask.vpn.launchers import darwin
diff --git a/src/leap/bitmask/vpn/helpers/__init__.py b/src/leap/bitmask/vpn/helpers/__init__.py
index 54b29cb0..e932422d 100644
--- a/src/leap/bitmask/vpn/helpers/__init__.py
+++ b/src/leap/bitmask/vpn/helpers/__init__.py
@@ -7,15 +7,13 @@ from hashlib import sha512
from twisted.logger import Logger
-from leap.bitmask.vpn.constants import IS_LINUX, IS_MAC
from leap.bitmask.vpn import _config
+from leap.bitmask.system import IS_LINUX, IS_MAC, IS_SNAP
from leap.bitmask.util import STANDALONE
log = Logger()
-IS_SNAP = os.environ.get('SNAP')
-
if IS_LINUX:
from leap.bitmask.vpn.constants import BITMASK_ROOT_SYSTEM
diff --git a/src/leap/bitmask/vpn/launcher.py b/src/leap/bitmask/vpn/launcher.py
index 890e1862..93be5fe7 100644
--- a/src/leap/bitmask/vpn/launcher.py
+++ b/src/leap/bitmask/vpn/launcher.py
@@ -27,14 +27,12 @@ from twisted.logger import Logger
from abc import ABCMeta, abstractmethod
-from leap.bitmask.vpn.constants import IS_MAC
+from leap.bitmask.system import IS_MAC, IS_SNAP
from leap.bitmask.vpn.utils import force_eval
log = Logger()
-IS_SNAP = os.environ.get('SNAP')
-
class VPNLauncherException(Exception):
pass
diff --git a/src/leap/bitmask/vpn/launchers/linux.py b/src/leap/bitmask/vpn/launchers/linux.py
index 5e05bea4..748fe858 100644
--- a/src/leap/bitmask/vpn/launchers/linux.py
+++ b/src/leap/bitmask/vpn/launchers/linux.py
@@ -28,6 +28,7 @@ from twisted.internet import defer, reactor
from twisted.internet.endpoints import clientFromString, connectProtocol
from twisted.logger import Logger
+from leap.bitmask.system import IS_SNAP
from leap.bitmask.vpn.utils import first, force_eval
from leap.bitmask.vpn import constants
from leap.bitmask.vpn import _config
@@ -35,8 +36,6 @@ from leap.bitmask.vpn.privilege import LinuxPolicyChecker
from leap.bitmask.vpn.management import ManagementProtocol
from leap.bitmask.vpn.launcher import VPNLauncher
-IS_SNAP = os.environ.get('SNAP')
-
TERMINATE_MAXTRIES = 10
TERMINATE_WAIT = 1 # secs
RESTART_WAIT = 2 # secs
diff --git a/src/leap/bitmask/vpn/privilege.py b/src/leap/bitmask/vpn/privilege.py
index 8a922cfe..528e3551 100644
--- a/src/leap/bitmask/vpn/privilege.py
+++ b/src/leap/bitmask/vpn/privilege.py
@@ -29,11 +29,9 @@ from twisted.logger import Logger
from twisted.python.procutils import which
from leap.bitmask.util import STANDALONE, here
-from .constants import IS_LINUX
+from leap.bitmask.system import IS_LINUX, IS_SNAP
from . import polkit
-IS_SNAP = os.environ.get('SNAP')
-
log = Logger()
diff --git a/src/leap/bitmask/vpn/process.py b/src/leap/bitmask/vpn/process.py
index 35ccf9f6..17d8fddc 100644
--- a/src/leap/bitmask/vpn/process.py
+++ b/src/leap/bitmask/vpn/process.py
@@ -37,7 +37,7 @@ from zope.interface import implementer
from leap.bitmask.vpn.utils import get_vpn_launcher
from leap.bitmask.vpn.management import ManagementProtocol
from leap.bitmask.vpn.launchers import darwin
-from leap.bitmask.vpn.constants import IS_MAC, IS_LINUX
+from leap.bitmask.system import IS_MAC, IS_LINUX
from leap.common.events import catalog, emit_async
from zope.interface import Interface
diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py
index 78443323..95751ca0 100644
--- a/src/leap/bitmask/vpn/service.py
+++ b/src/leap/bitmask/vpn/service.py
@@ -38,9 +38,9 @@ from leap.bitmask.vpn._checks import (
cert_expires
)
+from leap.bitmask.system import IS_LINUX
from leap.bitmask.vpn import privilege, helpers
from leap.bitmask.vpn import autostart
-from leap.bitmask.vpn.constants import IS_LINUX
from leap.common.config import get_path_prefix
from leap.common.files import check_and_fix_urw_only
from leap.common.events import catalog, emit_async
diff --git a/src/leap/bitmask/vpn/tunnel.py b/src/leap/bitmask/vpn/tunnel.py
index f2bd20a1..9904b365 100644
--- a/src/leap/bitmask/vpn/tunnel.py
+++ b/src/leap/bitmask/vpn/tunnel.py
@@ -25,8 +25,8 @@ import tempfile
from twisted.internet import reactor, defer
from twisted.logger import Logger
+from leap.bitmask.system import IS_WIN
from ._config import _TempVPNConfig, _TempProviderConfig
-from .constants import IS_WIN
from .process import VPNProcess
diff --git a/src/leap/bitmask/vpn/utils.py b/src/leap/bitmask/vpn/utils.py
index 8fa51783..98332fe2 100644
--- a/src/leap/bitmask/vpn/utils.py
+++ b/src/leap/bitmask/vpn/utils.py
@@ -57,7 +57,7 @@ def get_vpn_launcher():
"""
Return the VPN launcher for the current platform.
"""
- from leap.bitmask.vpn.constants import IS_LINUX, IS_MAC, IS_WIN
+ from leap.bitmask.system import IS_LINUX, IS_MAC, IS_WIN
if not (IS_LINUX or IS_MAC or IS_WIN):
error_msg = "VPN Launcher not implemented for this platform."