summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-03 10:18:50 +0900
committerkali <kali@leap.se>2012-08-03 10:18:50 +0900
commit5c34052ef9261a47947e3e03616fe34b099b9fa4 (patch)
tree0a952bf7ed1ce44b5f771260134263ad224f1373
parent81613b2ef70e5d73b7c34eb4b78ee63189b45ab6 (diff)
stub for daemon mode; disabled by now until #383 is fixed
-rw-r--r--src/leap/baseapp/mainwindow.py10
-rw-r--r--src/leap/eip/conductor.py9
-rw-r--r--src/leap/eip/config.py22
3 files changed, 24 insertions, 17 deletions
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index fec4928..cd6600b 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -59,19 +59,23 @@ class LeapWindow(QMainWindow):
mainLayout.addWidget(self.loggerBox)
widget.setLayout(mainLayout)
+ self.trayIcon.show()
+ config_file = getattr(opts, 'config_file', None)
+
#
# conductor is in charge of all
# vpn-related configuration / monitoring.
# we pass a tuple of signals that will be
# triggered when status changes.
#
- self.trayIcon.show()
- config_file = getattr(opts, 'config_file', None)
self.conductor = EIPConductor(
watcher_cb=self.newLogLine.emit,
config_file=config_file,
- status_signals=(self.statusChange.emit, ))
+ status_signals=(self.statusChange.emit, ),
+ debug=self.debugmode)
+
+ print('debugmode:%s' % self.debugmode)
if self.conductor.missing_pkexec is True:
dialog = ErrorDialog()
diff --git a/src/leap/eip/conductor.py b/src/leap/eip/conductor.py
index 2d6ad76..eeb7f8f 100644
--- a/src/leap/eip/conductor.py
+++ b/src/leap/eip/conductor.py
@@ -59,7 +59,8 @@ class OpenVPNConnection(object):
"""
# Connection Methods
- def __init__(self, config_file=None, watcher_cb=None):
+ def __init__(self, config_file=None,
+ watcher_cb=None, debug=False):
#XXX FIXME
#change watcher_cb to line_observer
"""
@@ -74,6 +75,8 @@ to be triggered for each one of them.
"""
# XXX get host/port from config
self.manager = OpenVPNManager()
+ self.debug = debug
+ print('conductor:%s' % debug)
self.config_file = config_file
self.watcher_cb = watcher_cb
@@ -99,7 +102,6 @@ to be triggered for each one of them.
home file, or config file passed in command line.
populates command and args to be passed to subprocess.
"""
- #print('get or create config')
config = get_config(config_file=self.config_file)
self.config = config
@@ -128,7 +130,8 @@ to be triggered for each one of them.
# no command in config, we build it up.
# XXX check also for command-line --command flag
try:
- command, args = build_ovpn_command(config)
+ command, args = build_ovpn_command(config,
+ debug=self.debug)
except EIPNoPkexecAvailable:
command = args = None
self.missing_pkexec = True
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py
index c632ba4..4577837 100644
--- a/src/leap/eip/config.py
+++ b/src/leap/eip/config.py
@@ -11,7 +11,7 @@ class EIPNoPkexecAvailable(Exception):
pass
-def build_ovpn_options():
+def build_ovpn_options(daemon=False):
"""
build a list of options
to be passed in the
@@ -68,10 +68,16 @@ def build_ovpn_options():
opts.append('--config')
opts.append(ovpncnf)
+ # we cannot run in daemon mode
+ # with the current subp setting.
+ # see: https://leap.se/code/issues/383
+ #if daemon is True:
+ # opts.append('--daemon')
+
return opts
-def build_ovpn_command(config):
+def build_ovpn_command(config, debug=False):
"""
build a string with the
complete openvpn invocation
@@ -116,7 +122,9 @@ def build_ovpn_command(config):
if ovpn:
command.append(ovpn)
- for opt in build_ovpn_options():
+ daemon_mode = not debug
+
+ for opt in build_ovpn_options(daemon=daemon_mode):
command.append(opt)
# XXX check len and raise proper error
@@ -191,11 +199,3 @@ def get_config(config_file=None):
config.readfp(config_file)
return config
-
-
-def get_vpn_stdout_mockup():
- # XXX REMOVE ME
- command = "python"
- args = ["-u", "-c", ("from eip_client import fakeclient;"
- "fakeclient.write_output()")]
- return command, args