diff options
| author | Lars Ingebrigtsen | 2012-12-24 13:14:04 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2012-12-24 13:14:04 +0100 |
| commit | e7d52a4de53b86c780c9ee0fbd6239450550756f (patch) | |
| tree | d1444791462619b2e8933f91650050cf22d0416e | |
| parent | f9e7c67e4ccdaf160c0506748f776d628a38eeba (diff) | |
| download | emacs-e7d52a4de53b86c780c9ee0fbd6239450550756f.tar.gz emacs-e7d52a4de53b86c780c9ee0fbd6239450550756f.zip | |
Make smtpmail forget the password if the server says it's invalid
* mail/smtpmail.el (smtpmail-try-auth-method): Refactored out into
its own function.
(smtpmail-try-auth-methods): Forget the user name/password if the
login is unsuccessful.
Fixes: debbugs:12424
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/mail/smtpmail.el | 27 |
2 files changed, 23 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fa5985de74d..1438a230550 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-12-24 Lars Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * mail/smtpmail.el (smtpmail-try-auth-method): Refactored out into | ||
| 4 | its own function. | ||
| 5 | (smtpmail-try-auth-methods): Forget the user name/password if the | ||
| 6 | login is unsuccessful (bug#12424). | ||
| 7 | |||
| 1 | 2012-12-22 Michael Albinus <michael.albinus@gmx.de> | 8 | 2012-12-22 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 9 | ||
| 3 | * notifications.el (notifications-notify): Protect body with | 10 | * notifications.el (notifications-notify): Protect body with |
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 69a405436a7..db7b003ca5c 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el | |||
| @@ -529,6 +529,18 @@ The list is in preference order.") | |||
| 529 | password (plist-get auth-info :secret))) | 529 | password (plist-get auth-info :secret))) |
| 530 | (when (functionp password) | 530 | (when (functionp password) |
| 531 | (setq password (funcall password))) | 531 | (setq password (funcall password))) |
| 532 | (let ((result (catch 'done | ||
| 533 | (smtpmail-try-auth-method process mech user password)))) | ||
| 534 | (if (stringp result) | ||
| 535 | (progn | ||
| 536 | (auth-source-forget+ :host host :port port) | ||
| 537 | (throw 'done result)) | ||
| 538 | (when save-function | ||
| 539 | (funcall save-function)) | ||
| 540 | result)))) | ||
| 541 | |||
| 542 | (defun smtpmail-try-auth-method (process mech user password) | ||
| 543 | (let (ret) | ||
| 532 | (cond | 544 | (cond |
| 533 | ((or (not mech) | 545 | ((or (not mech) |
| 534 | (not user) | 546 | (not user) |
| @@ -554,16 +566,11 @@ The list is in preference order.") | |||
| 554 | ;; are taken as a response to the server, and the | 566 | ;; are taken as a response to the server, and the |
| 555 | ;; authentication fails. | 567 | ;; authentication fails. |
| 556 | (encoded (base64-encode-string response t))) | 568 | (encoded (base64-encode-string response t))) |
| 557 | (smtpmail-command-or-throw process encoded) | 569 | (smtpmail-command-or-throw process encoded)))) |
| 558 | (when save-function | ||
| 559 | (funcall save-function))))) | ||
| 560 | ((eq mech 'login) | 570 | ((eq mech 'login) |
| 561 | (smtpmail-command-or-throw process "AUTH LOGIN") | 571 | (smtpmail-command-or-throw process "AUTH LOGIN") |
| 562 | (smtpmail-command-or-throw | 572 | (smtpmail-command-or-throw process (base64-encode-string user t)) |
| 563 | process (base64-encode-string user t)) | 573 | (smtpmail-command-or-throw process (base64-encode-string password t))) |
| 564 | (smtpmail-command-or-throw process (base64-encode-string password t)) | ||
| 565 | (when save-function | ||
| 566 | (funcall save-function))) | ||
| 567 | ((eq mech 'plain) | 574 | ((eq mech 'plain) |
| 568 | ;; We used to send an empty initial request, and wait for an | 575 | ;; We used to send an empty initial request, and wait for an |
| 569 | ;; empty response, and then send the password, but this | 576 | ;; empty response, and then send the password, but this |
| @@ -574,9 +581,7 @@ The list is in preference order.") | |||
| 574 | process | 581 | process |
| 575 | (concat "AUTH PLAIN " | 582 | (concat "AUTH PLAIN " |
| 576 | (base64-encode-string (concat "\0" user "\0" password) t)) | 583 | (base64-encode-string (concat "\0" user "\0" password) t)) |
| 577 | 235) | 584 | 235)) |
| 578 | (when save-function | ||
| 579 | (funcall save-function))) | ||
| 580 | (t | 585 | (t |
| 581 | (error "Mechanism %s not implemented" mech))))) | 586 | (error "Mechanism %s not implemented" mech))))) |
| 582 | 587 | ||