Subject: bug#19047: Acknowledgement (Tramp reuses bad ssh passphrase several times without asking)

From: Michael Albinus <[email-masked]>
Date: Sat, 22 Nov 2014 18:00:57 +0100

Stephane Chauveau <[email-masked]> writes:

> In function tramp-action-password, some codes were added to clear the
> 'wrong' password:
>
>  ;; Let's check whether a wrong password has been sent already.
>  ;; Sometimes, the process returns a new password request
>  ;; immediately after rejecting the previous (wrong) one.
>  (goto-char (point-min))
>  (when (search-forward-regexp tramp-wrong-passwd-regexp nil t)
>    (tramp-clear-passwd vec))
>
> That code probably does not work because there is nothing to match with
> tramp-password-prompt-regexp after the Enter passphrase prompt.

Finally, I have pushed a patch towards the emacs-24 branch, which shall
fix it. For testing:

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs-24/lisp/net/tramp.el	2014-11-22 18:54:33.000000000 +0200
--- /home/albinus/src/emacs-24/lisp/net/tramp.el.~6ec5ee8872bfb8b0ebc53d98fcb8f284e08c147f~	2014-11-22 18:54:33.000000000 +0200
***************
*** 3445,3453 ****
        ;; Let's check whether a wrong password has been sent already.
        ;; Sometimes, the process returns a new password request
        ;; immediately after rejecting the previous (wrong) one.
!       (goto-char (point-min))
!       (when (search-forward-regexp tramp-wrong-passwd-regexp nil t)
  	(tramp-clear-passwd vec))
        (tramp-check-for-regexp proc tramp-password-prompt-regexp)
        (tramp-message vec 3 "Sending %s" (match-string 1))
        ;; We don't call `tramp-send-string' in order to hide the
--- 3445,3453 ----
        ;; Let's check whether a wrong password has been sent already.
        ;; Sometimes, the process returns a new password request
        ;; immediately after rejecting the previous (wrong) one.
!       (unless (tramp-get-connection-property vec "first-password-request" nil)
  	(tramp-clear-passwd vec))
+       (goto-char (point-min))
        (tramp-check-for-regexp proc tramp-password-prompt-regexp)
        (tramp-message vec 3 "Sending %s" (match-string 1))
        ;; We don't call `tramp-send-string' in order to hide the
--8<---------------cut here---------------end--------------->8---

Thanks for your report, and best regards, Michael.