summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--paramiko/__init__.py2
-rw-r--r--paramiko/ssh_gss.py21
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