summaryrefslogtreecommitdiff
path: root/paramiko/ssh_gss.py
diff options
context:
space:
mode:
authorAnselm Kruis <a.kruis@science-computing.de>2017-08-01 21:26:21 +0200
committerAnselm Kruis <a.kruis@science-computing.de>2017-08-04 17:42:57 +0200
commit0595ee447ded0ab5bd178e1c3299a77706328a09 (patch)
tree5f8c788b6deafcb3b6494a97c83d191868460dcd /paramiko/ssh_gss.py
parent853a37f5a47ce1b0a9719e8e201e0ee48207631e (diff)
downloadparamiko-0595ee447ded0ab5bd178e1c3299a77706328a09.tar.gz
Added paramiko.GSS_EXCEPTIONS: exception types used by GSSAPI
This new constant is a tuple of the exception types used by the underlying GSSAPI/SSPI implementation.
Diffstat (limited to 'paramiko/ssh_gss.py')
-rw-r--r--paramiko/ssh_gss.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/paramiko/ssh_gss.py b/paramiko/ssh_gss.py
index 414485f9..d8d32b5d 100644
--- a/paramiko/ssh_gss.py
+++ b/paramiko/ssh_gss.py
@@ -39,11 +39,15 @@ import sys
"""
GSS_AUTH_AVAILABLE = True
+"""
+:var tuple GSS_EXCEPTIONS:
+ The exception types used by the underlying GSSAPI implementation.
+"""
+GSS_EXCEPTIONS = ()
+
from pyasn1.type.univ import ObjectIdentifier
from pyasn1.codec.der import encoder, decoder
-from paramiko.common import MSG_USERAUTH_REQUEST
-from paramiko.ssh_exception import SSHException
"""
:var str _API: Constraint for the used API
@@ -52,15 +56,21 @@ _API = "MIT"
try:
import gssapi
+ GSS_EXCEPTIONS = (gssapi.GSSException,)
except (ImportError, OSError):
try:
+ import pywintypes
import sspicon
import sspi
_API = "SSPI"
+ GSS_EXCEPTIONS = (pywintypes.error,)
except ImportError:
GSS_AUTH_AVAILABLE = False
_API = None
+from paramiko.common import MSG_USERAUTH_REQUEST
+from paramiko.ssh_exception import SSHException
+
def GSSAuth(auth_method, gss_deleg_creds=True):
"""
@@ -438,9 +448,10 @@ class _SSH_SSPI(_SSH_GSSAuth):
targetspn=targ_name)
error, token = self._gss_ctxt.authorize(recv_token)
token = token[0].Buffer
- except:
- raise Exception("{0}, Target: {1}".format(sys.exc_info()[1],
- self._gss_host))
+ except pywintypes.error as e:
+ e.strerror += ", Target: {1}".format(e, self._gss_host)
+ raise
+
if error == 0:
"""
if the status is GSS_COMPLETE (error = 0) the context is fully