Commit e7d52a4d authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen
Browse files

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
parent f9e7c67e
2012-12-24 Lars Ingebrigtsen <larsi@gnus.org>
* 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 (bug#12424).
2012-12-22 Michael Albinus <michael.albinus@gmx.de> 2012-12-22 Michael Albinus <michael.albinus@gmx.de>
   
* notifications.el (notifications-notify): Protect body with * notifications.el (notifications-notify): Protect body with
......
...@@ -529,6 +529,18 @@ The list is in preference order.") ...@@ -529,6 +529,18 @@ The list is in preference order.")
password (plist-get auth-info :secret))) password (plist-get auth-info :secret)))
(when (functionp password) (when (functionp password)
(setq password (funcall password))) (setq password (funcall password)))
(let ((result (catch 'done
(smtpmail-try-auth-method process mech user password))))
(if (stringp result)
(progn
(auth-source-forget+ :host host :port port)
(throw 'done result))
(when save-function
(funcall save-function))
result))))
(defun smtpmail-try-auth-method (process mech user password)
(let (ret)
(cond (cond
((or (not mech) ((or (not mech)
(not user) (not user)
...@@ -554,16 +566,11 @@ The list is in preference order.") ...@@ -554,16 +566,11 @@ The list is in preference order.")
;; are taken as a response to the server, and the ;; are taken as a response to the server, and the
;; authentication fails. ;; authentication fails.
(encoded (base64-encode-string response t))) (encoded (base64-encode-string response t)))
(smtpmail-command-or-throw process encoded) (smtpmail-command-or-throw process encoded))))
(when save-function
(funcall save-function)))))
((eq mech 'login) ((eq mech 'login)
(smtpmail-command-or-throw process "AUTH LOGIN") (smtpmail-command-or-throw process "AUTH LOGIN")
(smtpmail-command-or-throw (smtpmail-command-or-throw process (base64-encode-string user t))
process (base64-encode-string user t)) (smtpmail-command-or-throw process (base64-encode-string password t)))
(smtpmail-command-or-throw process (base64-encode-string password t))
(when save-function
(funcall save-function)))
((eq mech 'plain) ((eq mech 'plain)
;; We used to send an empty initial request, and wait for an ;; We used to send an empty initial request, and wait for an
;; empty response, and then send the password, but this ;; empty response, and then send the password, but this
...@@ -574,9 +581,7 @@ The list is in preference order.") ...@@ -574,9 +581,7 @@ The list is in preference order.")
process process
(concat "AUTH PLAIN " (concat "AUTH PLAIN "
(base64-encode-string (concat "\0" user "\0" password) t)) (base64-encode-string (concat "\0" user "\0" password) t))
235) 235))
(when save-function
(funcall save-function)))
(t (t
(error "Mechanism %s not implemented" mech))))) (error "Mechanism %s not implemented" mech)))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment