summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/app.py2
-rw-r--r--src/leap/bitmask/crypto/srpauth.py18
-rw-r--r--src/leap/bitmask/services/eip/linuxvpnlauncher.py10
-rw-r--r--src/leap/bitmask/util/leap_log_handler.py2
4 files changed, 25 insertions, 7 deletions
diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py
index c1859478..5982fe91 100644
--- a/src/leap/bitmask/app.py
+++ b/src/leap/bitmask/app.py
@@ -99,7 +99,7 @@ def add_logger_handlers(debug=False, logfile=None):
logger = logging.getLogger(name='leap')
logger.setLevel(level)
- log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
+ log_format = '%(asctime)s - %(name)s:%(funcName)s:L#%(lineno)s - %(levelname)s - %(message)s'
formatter = logging.Formatter(log_format)
# Console handler
diff --git a/src/leap/bitmask/crypto/srpauth.py b/src/leap/bitmask/crypto/srpauth.py
index cbff4b49..47ed21b0 100644
--- a/src/leap/bitmask/crypto/srpauth.py
+++ b/src/leap/bitmask/crypto/srpauth.py
@@ -25,6 +25,7 @@ import json
#this error is raised from requests
from simplejson.decoder import JSONDecodeError
from functools import partial
+from requests.adapters import HTTPAdapter
from PySide import QtCore
from twisted.internet import threads
@@ -154,7 +155,8 @@ class SRPAuth(QtCore.QObject):
self._ng = self._srp.NG_1024
# **************************************************** #
- self._session = self._fetcher.session()
+ self._reset_session()
+
self._session_id = None
self._session_id_lock = QtCore.QMutex()
self._uid = None
@@ -172,6 +174,18 @@ class SRPAuth(QtCore.QObject):
self._username = None
self._password = None
+ def _reset_session(self):
+ """
+ Resets the current session and sets max retries to 30.
+ """
+ self._session = self._fetcher.session()
+ # We need to bump the default retries, otherwise logout
+ # fails most of the times
+ # NOTE: This is a workaround for the moment, the server
+ # side seems to return correctly every time, but it fails
+ # on the client end.
+ self._session.mount('https://', HTTPAdapter(max_retries=30))
+
def _safe_unhexlify(self, val):
"""
Rounds the val to a multiple of 2 and returns the
@@ -508,7 +522,7 @@ class SRPAuth(QtCore.QObject):
self._username = username
self._password = password
- self._session = self._fetcher.session()
+ self._reset_session()
d = threads.deferToThread(self._authentication_preprocessing,
username=username,
diff --git a/src/leap/bitmask/services/eip/linuxvpnlauncher.py b/src/leap/bitmask/services/eip/linuxvpnlauncher.py
index c2c28627..efb23285 100644
--- a/src/leap/bitmask/services/eip/linuxvpnlauncher.py
+++ b/src/leap/bitmask/services/eip/linuxvpnlauncher.py
@@ -61,9 +61,13 @@ def _is_auth_agent_running():
:return: True if it's running, False if it's not.
:rtype: boolean
"""
- ps = 'ps aux | grep polkit-%s-authentication-agent-1'
- opts = (ps % case for case in ['[g]nome', '[k]de'])
- is_running = map(lambda l: commands.getoutput(l), opts)
+ # the [x] thing is to avoid grep match itself
+ polkit_options = [
+ 'ps aux | grep polkit-[g]nome-authentication-agent-1',
+ 'ps aux | grep polkit-[k]de-authentication-agent-1',
+ 'ps aux | grep [l]xpolkit'
+ ]
+ is_running = [commands.getoutput(cmd) for cmd in polkit_options]
return any(is_running)
diff --git a/src/leap/bitmask/util/leap_log_handler.py b/src/leap/bitmask/util/leap_log_handler.py
index 98924c12..262f2f65 100644
--- a/src/leap/bitmask/util/leap_log_handler.py
+++ b/src/leap/bitmask/util/leap_log_handler.py
@@ -52,7 +52,7 @@ class LogHandler(logging.Handler):
:param logging_level: the debug level to define the color.
:type logging_level: str.
"""
- log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
+ log_format = '%(asctime)s - %(name)s:%(funcName)s:L#%(lineno)s - %(levelname)s - %(message)s'
formatter = logging.Formatter(log_format)
return formatter