summaryrefslogtreecommitdiff
path: root/src/leap/eip/openvpnconnection.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/eip/openvpnconnection.py')
-rw-r--r--src/leap/eip/openvpnconnection.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py
index c280f70d..f4d1c449 100644
--- a/src/leap/eip/openvpnconnection.py
+++ b/src/leap/eip/openvpnconnection.py
@@ -99,12 +99,9 @@ to be triggered for each one of them.
ovpn_verbosity=self.ovpn_verbosity)
except eip_exceptions.EIPNoPolkitAuthAgentAvailable:
command = args = None
- # XXX deprecate
- #self.missing_auth_agent = True
raise
except eip_exceptions.EIPNoPkexecAvailable:
command = args = None
- #self.missing_pkexec = True
raise
# XXX if not command, signal error.
@@ -117,11 +114,10 @@ to be triggered for each one of them.
"""
try:
eip_config.check_vpn_keys()
- except eip_exceptions.EIPInitNoKeyFileError:
- self.missing_vpn_keyfile = True
except eip_exceptions.EIPInitBadKeyFilePermError:
- logger.error('error while checking vpn keys')
- self.bad_keyfile_perms = True
+ logger.error('Bad VPN Keys permission!')
+ # do nothing now
+ # and raise the rest ...
def _launch_openvpn(self):
"""
@@ -159,7 +155,7 @@ to be triggered for each one of them.
if self.command is None:
raise eip_exceptions.EIPNoCommandError
if self.subp is not None:
- print('cowardly refusing to launch subprocess again')
+ logger.debug('cowardly refusing to launch subprocess again')
return
self._launch_openvpn()
@@ -167,8 +163,14 @@ to be triggered for each one of them.
"""
terminates child subprocess
"""
+ # XXX we should send a quit process using management
+ # interface.
if self.subp:
- self.subp.terminate()
+ try:
+ self.subp.terminate()
+ except OSError:
+ logger.error('cannot terminate subprocess!'
+ '(maybe openvpn still running?)')
#
# management methods
@@ -234,16 +236,17 @@ to be triggered for each one of them.
"""
Send a command to openvpn and return response as list
"""
- #logger.debug('connected? %s' % self.connected())
if not self.connected():
try:
- #logger.debug('try to connect')
self.connect_to_management()
except eip_exceptions.MissingSocketError:
- #XXX capture more helpful error
- return self.make_error()
- except:
- raise
+ logger.warning('missing management socket')
+ # This should only happen briefly during
+ # the first invocation. Race condition make
+ # the polling begin before management socket
+ # is ready
+ return []
+ #return self.make_error()
try:
if hasattr(self, 'tn'):
self.tn.write(cmd + "\n")
@@ -311,6 +314,7 @@ to be triggered for each one of them.
"""
OpenVPN command: status
"""
+ #logger.debug('status called')
status = self._send_command("status")
return status