summaryrefslogtreecommitdiff
path: root/src/leap/services/eip
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-03-15 13:30:01 -0300
committerkali <kali@leap.se>2013-03-21 23:01:50 +0900
commit8f54774f6c3f779527718a0158ebd0efc4aab588 (patch)
tree8a746424f81698b03cabcc481196273672b5601e /src/leap/services/eip
parentddbad58fc2b3f44a293eeac7790a06f13b56944a (diff)
Handle configuration and paths in a standalone way
Also, abstracts QSettings under LeapSettings and adds a way to define the VPN env in a platform dependant way.
Diffstat (limited to 'src/leap/services/eip')
-rw-r--r--src/leap/services/eip/vpn.py7
-rw-r--r--src/leap/services/eip/vpnlaunchers.py38
2 files changed, 43 insertions, 2 deletions
diff --git a/src/leap/services/eip/vpn.py b/src/leap/services/eip/vpn.py
index 66b39dd9..4ac7f8a2 100644
--- a/src/leap/services/eip/vpn.py
+++ b/src/leap/services/eip/vpn.py
@@ -157,7 +157,14 @@ class VPN(QtCore.QThread):
socket_host=socket_host,
socket_port=socket_port)
try:
+ env = QtCore.QProcessEnvironment.systemEnvironment()
+ for key, val in self._launcher.get_vpn_env(providerconfig).items():
+ env.insert(key, val)
+
self._subp = QtCore.QProcess()
+
+ self._subp.setProcessEnvironment(env)
+
self._subp.finished.connect(self.process_finished)
self._subp.start(command[:1][0], command[1:])
logger.debug("Waiting for started...")
diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py
index f9e8e366..c58649b9 100644
--- a/src/leap/services/eip/vpnlaunchers.py
+++ b/src/leap/services/eip/vpnlaunchers.py
@@ -79,6 +79,20 @@ class VPNLauncher:
"""
return []
+ @abstractmethod
+ def get_vpn_env(self, providerconfig):
+ """
+ Returns a dictionary with the custom env for the platform.
+ This is mainly used for setting LD_LIBRARY_PATH to the correct
+ path when distributing a standalone client
+
+ @param providerconfig: provider specific configuration
+ @type providerconfig: ProviderConfig
+
+ @rtype: dict
+ """
+ return {}
+
def get_platform_launcher():
launcher = globals()[platform.system() + "VPNLauncher"]
@@ -125,7 +139,9 @@ class LinuxVPNLauncher(VPNLauncher):
def get_vpn_command(self, eipconfig=None, providerconfig=None,
socket_host=None, socket_port="unix"):
"""
- Returns the platform dependant vpn launching command
+ Returns the platform dependant vpn launching command. It will
+ look for openvpn in the regular paths and algo in
+ path_prefix/apps/eip/ (in case standalone is set)
Might raise VPNException.
@@ -149,7 +165,11 @@ class LinuxVPNLauncher(VPNLauncher):
leap_assert(socket_host, "We need a socket host!")
leap_assert(socket_port, "We need a socket port!")
- openvpn_possibilities = which(self.OPENVPN_BIN)
+ openvpn_possibilities = which(
+ self.OPENVPN_BIN,
+ path_extension=os.path.join(providerconfig.get_path_prefix(),
+ "..", "apps", "eip"))
+
if len(openvpn_possibilities) == 0:
raise OpenVPNNotFoundException()
@@ -227,6 +247,20 @@ class LinuxVPNLauncher(VPNLauncher):
return [openvpn] + args
+ def get_vpn_env(self, providerconfig):
+ """
+ Returns a dictionary with the custom env for the platform.
+ This is mainly used for setting LD_LIBRARY_PATH to the correct
+ path when distributing a standalone client
+
+ @rtype: dict
+ """
+ leap_assert(providerconfig, "We need a provider config")
+ leap_assert_type(providerconfig, ProviderConfig)
+
+ return {"LD_LIBRARY_PATH": os.path.join(
+ providerconfig.get_path_prefix(),
+ "..", "lib")}
if __name__ == "__main__":
logger = logging.getLogger(name='leap')