summaryrefslogtreecommitdiff
path: root/paramiko/auth_handler.py
diff options
context:
space:
mode:
Diffstat (limited to 'paramiko/auth_handler.py')
-rw-r--r--paramiko/auth_handler.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py
index 9a5fd0f6..04ee2d75 100644
--- a/paramiko/auth_handler.py
+++ b/paramiko/auth_handler.py
@@ -21,6 +21,8 @@
"""
import weakref
+import time
+
from paramiko.common import (
cMSG_SERVICE_REQUEST,
cMSG_DISCONNECT,
@@ -57,7 +59,6 @@ from paramiko.common import (
MSG_USERAUTH_GSSAPI_MIC,
MSG_NAMES,
)
-
from paramiko.message import Message
from paramiko.py3compat import bytestring
from paramiko.ssh_exception import (
@@ -214,6 +215,9 @@ class AuthHandler(object):
return m.asbytes()
def wait_for_response(self, event):
+ max_ts = None
+ if self.transport.auth_timeout is not None:
+ max_ts = time.time() + self.transport.auth_timeout
while True:
event.wait(0.1)
if not self.transport.is_active():
@@ -223,6 +227,9 @@ class AuthHandler(object):
raise e
if event.is_set():
break
+ if max_ts is not None and max_ts <= time.time():
+ raise AuthenticationException('Authentication timeout.')
+
if not self.is_authenticated():
e = self.transport.get_exception()
if e is None: