diff options
author | antialias <antialias@leap.se> | 2012-10-15 12:28:54 -0400 |
---|---|---|
committer | antialias <antialias@leap.se> | 2012-10-15 12:28:54 -0400 |
commit | a6c587edad293996e4015876d7e59432d6a4e8ea (patch) | |
tree | 36017039e6e8295e97077f72310153d6ea5f5bb7 /src | |
parent | 0875a3d498c30187a40a788d3bd1eefa9c5924e2 (diff) |
attempts to stop exisiting instances of openvpn when discovered at start up.
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/eip/openvpnconnection.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py index 96df4f1d..d93bc40f 100644 --- a/src/leap/eip/openvpnconnection.py +++ b/src/leap/eip/openvpnconnection.py @@ -168,7 +168,9 @@ to be triggered for each one of them. for process in psutil.get_process_list(): if process.name == "openvpn": logger.debug('an openvpn instance is already running.') - raise eip_exceptions.OpenVPNAlreadyRunning + logger.debug('attempting to stop openvpn instance.') + if not self._stop(): + raise eip_exceptions.OpenVPNAlreadyRunning logger.debug('no openvpn instance found.') @@ -190,7 +192,34 @@ to be triggered for each one of them. logger.debug("disconnecting...") self._send_command("signal SIGTERM\n") - # + if self.subp: + return True + + #shutting openvpn failured + #try patching in old openvpn host and trying again + process = self._get_openvpn_process() + if process: + self.host = \ + process.cmdline[process.cmdline.index("--management") + 1] + self._send_command("signal SIGTERM\n") + + #make sure the process was terminated + process = self._get_openvpn_process() + if not process: + logger.debug("Exisiting OpenVPN Process Terminated") + return True + else: + logger.error("Unable to terminate exisiting OpenVPN Process.") + return False + + return True + + def _get_openvpn_process(self): + for process in psutil.get_process_list(): + if process.name == "openvpn": + return process + return None + # management methods # # XXX REVIEW-ME |