summaryrefslogtreecommitdiff
path: root/src/leap/eip/conductor.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-03 09:42:14 +0900
committerkali <kali@leap.se>2012-08-03 09:42:14 +0900
commit81613b2ef70e5d73b7c34eb4b78ee63189b45ab6 (patch)
tree126f60090306475820cefd1c0c175ea6c1c9272e /src/leap/eip/conductor.py
parentb9c9b5536f9d1648a196e741cdf4570f64c3fb11 (diff)
pkexec check
Diffstat (limited to 'src/leap/eip/conductor.py')
-rw-r--r--src/leap/eip/conductor.py37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/leap/eip/conductor.py b/src/leap/eip/conductor.py
index bf7f0fb2..2d6ad764 100644
--- a/src/leap/eip/conductor.py
+++ b/src/leap/eip/conductor.py
@@ -8,7 +8,9 @@ import logging
from leap.util.coroutines import spawn_and_watch_process
-from leap.eip.config import get_config, build_ovpn_command
+
+from leap.eip.config import (get_config, build_ovpn_command,
+ EIPNoPkexecAvailable)
from leap.eip.vpnwatcher import EIPConnectionStatus, status_watcher
from leap.eip.vpnmanager import OpenVPNManager, ConnectionRefusedError
@@ -17,6 +19,9 @@ logger = logging.getLogger(name=__name__)
# TODO Move exceptions to their own module
+class EIPNoCommandError(Exception):
+ pass
+
class ConnectionError(Exception):
"""
@@ -81,6 +86,10 @@ to be triggered for each one of them.
self.port = None
self.proto = None
+ self.missing_pkexec = False
+ self.command = None
+ self.args = None
+
self.autostart = True
self._get_or_create_config()
@@ -94,6 +103,14 @@ to be triggered for each one of them.
config = get_config(config_file=self.config_file)
self.config = config
+ if config.has_option('openvpn', 'autostart'):
+ autostart = config.getboolean('openvpn', 'autostart')
+ self.autostart = autostart
+ else:
+ if config.has_option('DEFAULT', 'autostart'):
+ autostart = config.getboolean('DEFAULT', 'autostart')
+ self.autostart = autostart
+
if config.has_option('openvpn', 'command'):
commandline = config.get('openvpn', 'command')
@@ -110,18 +127,16 @@ to be triggered for each one of them.
else:
# no command in config, we build it up.
# XXX check also for command-line --command flag
- command, args = build_ovpn_command(config)
+ try:
+ command, args = build_ovpn_command(config)
+ except EIPNoPkexecAvailable:
+ command = args = None
+ self.missing_pkexec = True
+
+ # XXX if not command, signal error.
self.command = command
self.args = args
- if config.has_option('openvpn', 'autostart'):
- autostart = config.getboolean('openvpn', 'autostart')
- self.autostart = autostart
- else:
- if config.has_option('DEFAULT', 'autostart'):
- autostart = config.getboolean('DEFAULT', 'autostart')
- self.autostart = autostart
-
def _launch_openvpn(self):
"""
invocation of openvpn binaries in a subprocess.
@@ -152,6 +167,8 @@ to be triggered for each one of them.
"""
attempts to connect
"""
+ if self.command is None:
+ raise EIPNoCommandError
if self.subp is not None:
print('cowardly refusing to launch subprocess again')
return