Skip to content

Commit

Permalink
Merge branch '1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Jun 23, 2012
2 parents 5f5ad7b + 86193c2 commit 61f8365
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions fabric/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,20 @@ def connect(user, host, port):
ssh.PasswordRequiredException,
ssh.SSHException
), e:
# For whatever reason, empty password + no ssh key or agent results
# in an SSHException instead of an AuthenticationException. Since
# it's difficult to do otherwise, we must assume empty password +
# SSHException == auth exception. Conversely: if we get
# SSHException and there *was* a password -- it is probably
# something non auth related, and should be sent upwards.
if e.__class__ is ssh.SSHException and password:
raise NetworkError(str(e), e)
msg = str(e)
# For whatever reason, empty password + no ssh key or agent
# results in an SSHException instead of an
# AuthenticationException. Since it's difficult to do
# otherwise, we must assume empty password + SSHException ==
# auth exception. Conversely: if we get SSHException and there
# *was* a password -- it is probably something non auth
# related, and should be sent upwards.
#
# This also holds true for rejected/unknown host keys: we have to
# guess based on other heuristics.
if e.__class__ is ssh.SSHException \
and (password or msg.startswith('Unknown server')):
raise NetworkError(msg, e)

# Otherwise, assume an auth exception, and prompt for new/better
# password.
Expand Down

0 comments on commit 61f8365

Please sign in to comment.