summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-03-20 23:48:07 +0900
committerkali <kali@leap.se>2013-03-21 21:18:54 +0900
commit85166f4d12fbaafa5ab1cd5fca5ad37a4ba94774 (patch)
treed74859c69b74dd0cf18fa8a29331ab3cb3de3caa /src/leap
parent74600d1c73cfc2f958f2c64d57ea8fb85d348424 (diff)
fix osascript invocation
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/services/eip/vpn.py11
-rw-r--r--src/leap/services/eip/vpnlaunchers.py36
2 files changed, 33 insertions, 14 deletions
diff --git a/src/leap/services/eip/vpn.py b/src/leap/services/eip/vpn.py
index 66b39dd9..9a60cf73 100644
--- a/src/leap/services/eip/vpn.py
+++ b/src/leap/services/eip/vpn.py
@@ -159,6 +159,7 @@ class VPN(QtCore.QThread):
try:
self._subp = QtCore.QProcess()
self._subp.finished.connect(self.process_finished)
+ self._subp.finished.connect(self._dump_exitinfo)
self._subp.start(command[:1][0], command[1:])
logger.debug("Waiting for started...")
self._subp.waitForStarted()
@@ -174,6 +175,16 @@ class VPN(QtCore.QThread):
logger.warning("Something went wrong while starting OpenVPN: %r" %
(e,))
+ def _dump_exitinfo(self):
+ """
+ SLOT
+ Prints debug info when quitting the process
+
+ TRIGGER: self._subp.finished
+ """
+ logger.debug("stdout: %s", self._subp.readAllStandardOutput())
+ logger.debug("stderr: %s", self._subp.readAllStandardError())
+
def _get_openvpn_process(self):
"""
Looks for openvpn instances running
diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py
index 44dff4d0..773b1f92 100644
--- a/src/leap/services/eip/vpnlaunchers.py
+++ b/src/leap/services/eip/vpnlaunchers.py
@@ -235,14 +235,17 @@ class DarwinVPNLauncher(VPNLauncher):
VPN launcher for the Darwin Platform
"""
- OSASCRIPT_BIN = 'osascript'
- OSX_ASADMIN = 'do shell script "%s" with administrator privileges'
+ OSASCRIPT_BIN = '/usr/bin/osascript'
+ OSX_ASADMIN = "do shell script \"%s\" with administrator privileges"
OPENVPN_BIN = 'openvpn.leap'
INSTALL_PATH = "/Applications/LEAPClient.app/"
# OPENVPN_BIN = "/%s/Contents/Resources/openvpn.leap" % (
# self.INSTALL_PATH,)
- UP_DOWN_SCRIPT = "/etc/leap/resolv-update"
- OPENVPN_DOWN_ROOT = "/usr/lib/openvpn/openvpn-down-root.so"
+ UP_SCRIPT = "/%s/client.up.sh" % (INSTALL_PATH,)
+ DOWN_SCRIPT = "/%s/client.down.sh" % (INSTALL_PATH,)
+
+ # TODO: Add
+ # OPENVPN_DOWN_ROOT = "/usr/lib/openvpn/openvpn-down-root.so"
def get_vpn_command(self, eipconfig=None, providerconfig=None,
socket_host=None, socket_port="unix"):
@@ -276,12 +279,11 @@ class DarwinVPNLauncher(VPNLauncher):
raise OpenVPNNotFoundException()
openvpn = openvpn_possibilities[0]
- args = []
+ args = [openvpn]
# TODO: handle verbosity
gateway_ip = str(eipconfig.get_gateway_ip(0))
-
logger.debug("Using gateway ip %s" % (gateway_ip,))
args += [
@@ -317,12 +319,16 @@ class DarwinVPNLauncher(VPNLauncher):
'--script-security', '2'
]
- if _has_updown_scripts(self.UP_DOWN_SCRIPT):
+ if _has_updown_scripts(self.UP_SCRIPT):
args += [
- '--up', self.UP_DOWN_SCRIPT,
- '--down', self.UP_DOWN_SCRIPT,
- '--plugin', self.OPENVPN_DOWN_ROOT,
- '\'script_type=down %s\'' % self.UP_DOWN_SCRIPT
+ '--up', self.UP_SCRIPT,
+ ]
+ if _has_updown_scripts(self.DOWN_SCRIPT):
+ args += [
+ '--down', self.DOWN_SCRIPT,
+ # FIXME add down-plugin
+ # '--plugin', self.OPENVPN_DOWN_ROOT,
+ # '\'script_type=down %s\'' % self.DOWN_SCRIPT
]
args += [
@@ -331,11 +337,13 @@ class DarwinVPNLauncher(VPNLauncher):
'--ca', providerconfig.get_ca_cert_path()
]
+ command = self.OSASCRIPT_BIN
+ cmd_args = ["-e", self.OSX_ASADMIN % (' '.join(args),)]
+
logger.debug("Running VPN with command:")
- logger.debug("%s %s" % (openvpn, " ".join(args)))
+ logger.debug("%s %s" % (command, " ".join(cmd_args)))
- # return [self.OSASCRIPT_BIN, ["-e", self.OSX_ASADMIN % ' '.join(args)]]
- return [openvpn] + args
+ return [command] + cmd_args
if __name__ == "__main__":