diff options
author | Anselm Kruis <a.kruis@science-computing.de> | 2017-08-01 21:26:21 +0200 |
---|---|---|
committer | Anselm Kruis <a.kruis@science-computing.de> | 2017-08-04 17:42:57 +0200 |
commit | 0595ee447ded0ab5bd178e1c3299a77706328a09 (patch) | |
tree | 5f8c788b6deafcb3b6494a97c83d191868460dcd | |
parent | 853a37f5a47ce1b0a9719e8e201e0ee48207631e (diff) |
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.
-rw-r--r-- | paramiko/__init__.py | 2 | ||||
-rw-r--r-- | paramiko/ssh_gss.py | 21 |
2 files changed, 17 insertions, 6 deletions
diff --git a/paramiko/__init__.py b/paramiko/__init__.py index 197f519a..01dc973c 100644 --- a/paramiko/__init__.py +++ b/paramiko/__init__.py @@ -34,7 +34,7 @@ from paramiko.client import ( WarningPolicy, ) from paramiko.auth_handler import AuthHandler -from paramiko.ssh_gss import GSSAuth, GSS_AUTH_AVAILABLE +from paramiko.ssh_gss import GSSAuth, GSS_AUTH_AVAILABLE, GSS_EXCEPTIONS from paramiko.channel import Channel, ChannelFile from paramiko.ssh_exception import ( SSHException, PasswordRequiredException, BadAuthenticationType, 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 |