summaryrefslogtreecommitdiff
path: root/src/leap/services/eip
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/services/eip')
-rw-r--r--src/leap/services/eip/eipconfig.py20
-rw-r--r--src/leap/services/eip/vpnlaunchers.py33
-rw-r--r--src/leap/services/eip/vpnprocess.py27
3 files changed, 51 insertions, 29 deletions
diff --git a/src/leap/services/eip/eipconfig.py b/src/leap/services/eip/eipconfig.py
index 2f2f6e7c..d69e1fd8 100644
--- a/src/leap/services/eip/eipconfig.py
+++ b/src/leap/services/eip/eipconfig.py
@@ -138,25 +138,13 @@ class EIPConfig(BaseConfig):
BaseConfig.__init__(self)
self._api_version = None
- def _get_spec(self):
+ def _get_schema(self):
"""
- Returns the spec object for the specific configuration
- """
- leap_assert(self._api_version is not None,
- "You should set the API version.")
-
- return get_schema(self._api_version)
+ Returns the schema corresponding to the version given.
- def set_api_version(self, version):
+ :rtype: dict or None if the version is not supported.
"""
- Sets the supported api version.
-
- :param api_version: the version of the api supported by the provider.
- :type api_version: str
- """
- self._api_version = version
- leap_assert(get_schema(self._api_version) is not None,
- "Version %s is not supported." % (version, ))
+ return get_schema(self._api_version)
def get_clusters(self):
# TODO: create an abstraction for clusters
diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py
index 526f1ba4..17950a25 100644
--- a/src/leap/services/eip/vpnlaunchers.py
+++ b/src/leap/services/eip/vpnlaunchers.py
@@ -352,7 +352,7 @@ class LinuxVPNLauncher(VPNLauncher):
return None
def get_vpn_command(self, eipconfig=None, providerconfig=None,
- socket_host=None, socket_port="unix"):
+ socket_host=None, socket_port="unix", openvpn_verb=1):
"""
Returns the platform dependant vpn launching command. It will
look for openvpn in the regular paths and algo in
@@ -375,6 +375,9 @@ class LinuxVPNLauncher(VPNLauncher):
socket, or port otherwise
:type socket_port: str
+ :param openvpn_verb: openvpn verbosity wanted
+ :type openvpn_verb: int
+
:return: A VPN command ready to be launched
:rtype: list
"""
@@ -404,7 +407,8 @@ class LinuxVPNLauncher(VPNLauncher):
args.append(openvpn)
openvpn = first(pkexec)
- # TODO: handle verbosity
+ if openvpn_verb is not None:
+ args += ['--verb', '%d' % (openvpn_verb,)]
gateway_selector = VPNGatewaySelector(eipconfig)
gateways = gateway_selector.get_gateways()
@@ -516,9 +520,9 @@ class DarwinVPNLauncher(VPNLauncher):
COCOASUDO = "cocoasudo"
# XXX need the good old magic translate for these strings
# (look for magic in 0.2.0 release)
- SUDO_MSG = ("LEAP needs administrative privileges to run "
+ SUDO_MSG = ("Bitmask needs administrative privileges to run "
"Encrypted Internet.")
- INSTALL_MSG = ("\"LEAP needs administrative privileges to install "
+ INSTALL_MSG = ("\"Bitmask needs administrative privileges to install "
"missing scripts and fix permissions.\"")
INSTALL_PATH = os.path.realpath(os.getcwd() + "/../../")
@@ -604,7 +608,7 @@ class DarwinVPNLauncher(VPNLauncher):
return self.COCOASUDO, args
def get_vpn_command(self, eipconfig=None, providerconfig=None,
- socket_host=None, socket_port="unix"):
+ socket_host=None, socket_port="unix", openvpn_verb=1):
"""
Returns the platform dependant vpn launching command
@@ -623,6 +627,9 @@ class DarwinVPNLauncher(VPNLauncher):
socket, or port otherwise
:type socket_port: str
+ :param openvpn_verb: openvpn verbosity wanted
+ :type openvpn_verb: int
+
:return: A VPN command ready to be launched
:rtype: list
"""
@@ -651,7 +658,8 @@ class DarwinVPNLauncher(VPNLauncher):
openvpn = first(openvpn_possibilities)
args = [openvpn]
- # TODO: handle verbosity
+ if openvpn_verb is not None:
+ args += ['--verb', '%d' % (openvpn_verb,)]
gateway_selector = VPNGatewaySelector(eipconfig)
gateways = gateway_selector.get_gateways()
@@ -768,9 +776,10 @@ class WindowsVPNLauncher(VPNLauncher):
OPENVPN_BIN = 'openvpn_leap.exe'
# XXX UPDOWN_FILES ... we do not have updown files defined yet!
+ # (and maybe we won't)
def get_vpn_command(self, eipconfig=None, providerconfig=None,
- socket_host=None, socket_port="9876"):
+ socket_host=None, socket_port="9876", openvpn_verb=1):
"""
Returns the platform dependant vpn launching command. It will
look for openvpn in the regular paths and algo in
@@ -780,14 +789,20 @@ class WindowsVPNLauncher(VPNLauncher):
:param eipconfig: eip configuration object
:type eipconfig: EIPConfig
+
:param providerconfig: provider specific configuration
:type providerconfig: ProviderConfig
+
:param socket_host: either socket path (unix) or socket IP
:type socket_host: str
+
:param socket_port: either string "unix" if it's a unix
socket, or port otherwise
:type socket_port: str
+ :param openvpn_verb: the openvpn verbosity wanted
+ :type openvpn_verb: int
+
:return: A VPN command ready to be launched
:rtype: list
"""
@@ -810,8 +825,8 @@ class WindowsVPNLauncher(VPNLauncher):
openvpn = first(openvpn_possibilities)
args = []
-
- # TODO: handle verbosity
+ if openvpn_verb is not None:
+ args += ['--verb', '%d' % (openvpn_verb,)]
gateway_selector = VPNGatewaySelector(eipconfig)
gateways = gateway_selector.get_gateways()
diff --git a/src/leap/services/eip/vpnprocess.py b/src/leap/services/eip/vpnprocess.py
index c4bdb30c..5b07a3cf 100644
--- a/src/leap/services/eip/vpnprocess.py
+++ b/src/leap/services/eip/vpnprocess.py
@@ -80,7 +80,9 @@ class VPN(object):
TERMINATE_MAXTRIES = 10
TERMINATE_WAIT = 1 # secs
- def __init__(self):
+ OPENVPN_VERB = "openvpn_verb"
+
+ def __init__(self, **kwargs):
"""
Instantiate empty attributes and get a copy
of a QObject containing the QSignals that we will pass along
@@ -92,6 +94,8 @@ class VPN(object):
self._reactor = reactor
self._qtsigs = VPNSignals()
+ self._openvpn_verb = kwargs.get(self.OPENVPN_VERB, None)
+
@property
def qtsigs(self):
return self._qtsigs
@@ -108,9 +112,12 @@ class VPN(object):
"""
self._stop_pollers()
kwargs['qtsigs'] = self.qtsigs
+ kwargs['openvpn_verb'] = self._openvpn_verb
# start the main vpn subprocess
vpnproc = VPNProcess(*args, **kwargs)
+ #qtsigs=self.qtsigs,
+ #openvpn_verb=self._openvpn_verb)
if vpnproc.get_openvpn_process():
logger.info("Another vpn process is running. Will try to stop it.")
@@ -566,7 +573,12 @@ class VPNManager(object):
# we should check that cmdline BEGINS
# with openvpn or with our wrapper
# (pkexec / osascript / whatever)
- if "openvpn" in ' '.join(p.cmdline):
+
+ # This needs more work, see #3268, but for the moment
+ # we need to be able to filter out arguments in the form
+ # --openvpn-foo, since otherwise we are shooting ourselves
+ # in the feet.
+ if any(map(lambda s: s.startswith("openvpn"), p.cmdline)):
openvpn_process = p
break
except psutil.error.AccessDenied:
@@ -645,7 +657,7 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager):
"""
def __init__(self, eipconfig, providerconfig, socket_host, socket_port,
- qtsigs):
+ qtsigs, openvpn_verb):
"""
:param eipconfig: eip configuration object
:type eipconfig: EIPConfig
@@ -663,6 +675,10 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager):
:param qtsigs: a QObject containing the Qt signals used to notify the
UI.
:type qtsigs: QObject
+
+ :param openvpn_verb: the desired level of verbosity in the
+ openvpn invocation
+ :type openvpn_verb: int
"""
VPNManager.__init__(self, qtsigs=qtsigs)
leap_assert_type(eipconfig, EIPConfig)
@@ -682,6 +698,8 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager):
self._last_status = None
self._alive = False
+ self._openvpn_verb = openvpn_verb
+
# processProtocol methods
def connectionMade(self):
@@ -757,7 +775,8 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager):
eipconfig=self._eipconfig,
providerconfig=self._providerconfig,
socket_host=self._socket_host,
- socket_port=self._socket_port)
+ socket_port=self._socket_port,
+ openvpn_verb=self._openvpn_verb)
return map(str, cmd)
# shutdown