summaryrefslogtreecommitdiff
path: root/src/leap/eip/openvpnconnection.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-11-14 03:39:14 +0900
committerkali <kali@leap.se>2012-11-14 03:39:14 +0900
commit834b04317535cb6d18c02e3aa4d37b09fcf99868 (patch)
treea9a4fda0b2d425b7db449b46bb5564788be57020 /src/leap/eip/openvpnconnection.py
parente111e9de0d33d12503233e754e2e4b01133acec9 (diff)
delete temp folder for management socket after client shutdown
Close #742
Diffstat (limited to 'src/leap/eip/openvpnconnection.py')
-rw-r--r--src/leap/eip/openvpnconnection.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py
index 4104bd0e..45a1847c 100644
--- a/src/leap/eip/openvpnconnection.py
+++ b/src/leap/eip/openvpnconnection.py
@@ -3,7 +3,9 @@ OpenVPN Connection
"""
from __future__ import (print_function)
import logging
+import os
import psutil
+import shutil
import socket
import time
from functools import partial
@@ -187,6 +189,7 @@ to be triggered for each one of them.
'connection refused.')
# XXX kali --
+ # XXX review-me
# I think this will block if child process
# does not return.
# Maybe we can .poll() for a given
@@ -198,6 +201,26 @@ to be triggered for each one of them.
'cannot terminate subprocess! Retcode %s'
'(We might have left openvpn running)' % RETCODE)
+ self.cleanup_tempfiles()
+
+ def cleanup_tempfiles(self):
+ """
+ remove all temporal files
+ we might have left behind
+ """
+ # if self.port is 'unix', we have
+ # created a temporal socket path that, under
+ # normal circumstances, we should be able to
+ # delete
+
+ if self.port == "unix":
+ # I'm tempted to catch a generic exception here,
+ # but I prefer to let it crash so we can catch
+ # specific errors that right now I'm not able
+ # to think of.
+ logger.debug('cleaning socket file temp folder')
+ shutil.rmtree(os.path.split(self.host)[0])
+
def _get_openvpn_process(self):
# plist = [p for p in psutil.get_process_list() if p.name == "openvpn"]
# return plist[0] if plist else None