summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-03-27 13:31:12 +0200
committerKali Kaneko <kali@leap.se>2018-03-28 23:51:26 +0200
commit60903c2515391384b67f9d3a7c6d5c810db0e946 (patch)
tree23b0f70bbb6967f22d3bb2030a51dec1044edff8 /src/leap/bitmask/vpn
parentdcbbda4dbd442340cbc46e2f1a476cb21e12ca0f (diff)
[refactor] move autostart code into core
All the logic to autostart bitmask should not be vpn dependent.
Diffstat (limited to 'src/leap/bitmask/vpn')
-rw-r--r--src/leap/bitmask/vpn/autostart.py45
-rw-r--r--src/leap/bitmask/vpn/service.py16
2 files changed, 3 insertions, 58 deletions
diff --git a/src/leap/bitmask/vpn/autostart.py b/src/leap/bitmask/vpn/autostart.py
deleted file mode 100644
index 1c361d82..00000000
--- a/src/leap/bitmask/vpn/autostart.py
+++ /dev/null
@@ -1,45 +0,0 @@
-import os
-import os.path
-
-from leap.bitmask.system import IS_LINUX, IS_MAC
-from leap.bitmask.util import STANDALONE
-from leap.common.config import get_path_prefix
-
-if IS_LINUX:
- AUTOSTART = r"""[Desktop Entry]
-Name=Bitmask
-Type=Application
-Exec=bitmask
-Terminal=false
-"""
- config = get_path_prefix(standalone=False)
- autostart_file = os.path.join(config, 'autostart', 'bitmask.desktop')
-
- def autostart_app(status):
- """
- Leave an autostart file in the user's autostart path.
-
- The bundle could in principle find its own path and add
- the path to the bitmaskd binary in the Exec entry.
- But for now it's simpler to do autostart only for the debian packages
- or any other method that puts bitmask in the path.
- On the other hand, we want to reduce the modifications that the bundle
- leaves behind.
- """
- if not STANDALONE:
- if status == 'on':
- _dir = os.path.split(autostart_file)[0]
- if not os.path.isdir(_dir):
- os.makedirs(_dir)
- with open(autostart_file, 'w') as f:
- f.write(AUTOSTART)
- elif status == 'off':
- try:
- os.unlink(autostart_file)
- except OSError:
- pass
-
-if IS_MAC:
-
- def autostart_app(status):
- pass
diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py
index 95751ca0..4ce573ba 100644
--- a/src/leap/bitmask/vpn/service.py
+++ b/src/leap/bitmask/vpn/service.py
@@ -40,7 +40,6 @@ from leap.bitmask.vpn._checks import (
from leap.bitmask.system import IS_LINUX
from leap.bitmask.vpn import privilege, helpers
-from leap.bitmask.vpn import autostart
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
@@ -118,7 +117,6 @@ class VPNService(HookableService):
def start_vpn(self, domain=None):
self.log.debug('Starting VPN')
self._cfg.set('autostart', True)
- autostart.autostart_app('on')
if self.do_status()['status'] == 'on':
exc = Exception('VPN already started')
@@ -162,11 +160,11 @@ class VPNService(HookableService):
def stop_vpn(self, shutdown=False):
if shutdown:
if self._tunnel and self._tunnel.status.get('status') == 'on':
- self._set_autostart('on')
+ self._cfg.set('autostart', True)
else:
- self._set_autostart('off')
+ self._cfg.set('autostart', False)
else:
- self._set_autostart('off')
+ self._cfg.set('autostart', False)
if self._firewall.is_up():
fw_ok = self._firewall.stop()
@@ -184,14 +182,6 @@ class VPNService(HookableService):
self.watchdog.stop()
return {'result': 'vpn stopped'}
- def _set_autostart(self, status):
- if status.lower() == 'on':
- self._cfg.set('autostart', True)
- autostart.autostart_app('on')
- elif status.lower() == 'off':
- self._cfg.set('autostart', False)
- autostart.autostart_app('off')
-
def push_status(self):
try:
statusdict = self.do_status()