(nnimap-login): Prefer AUTH=CRAM-MD5, if it's available.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 2 Jan 2011 22:28:40 +0000 (23:28 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 2 Jan 2011 22:28:40 +0000 (23:28 +0100)
This avoids sending passwords in plain text over non-encrypted
channels.

lisp/ChangeLog
lisp/nnimap.el

index 7e5abde..0fb65b8 100644 (file)
@@ -1,5 +1,9 @@
 2011-01-02  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * nnimap.el (nnimap-login): Prefer AUTH=CRAM-MD5, if it's available.
+       This avoids sending passwords in plain text over non-encrypted
+       channels.
+
        * shr.el (shr-rescale-image): Display all GIF images as animated images.
 
        * nnimap.el (nnimap-login): Refactored out into own function, and
index d316015..51fa532 100644 (file)
@@ -411,15 +411,6 @@ textual parts.")
 
 (defun nnimap-login (user password)
   (cond
-   ((not (nnimap-capability "LOGINDISABLED"))
-    (nnimap-command "LOGIN %S %S" user password))
-   ((nnimap-capability "AUTH=PLAIN")
-    (nnimap-command
-     "AUTHENTICATE PLAIN %s"
-     (base64-encode-string
-      (format "\000%s\000%s"
-             (nnimap-quote-specials user)
-             (nnimap-quote-specials password)))))
    ((nnimap-capability "AUTH=CRAM-MD5")
     (erase-buffer)
     (let ((sequence (nnimap-send-command "AUTHENTICATE CRAM-MD5"))
@@ -432,7 +423,16 @@ textual parts.")
                 (rfc2104-hash 'md5 64 16 password
                               (base64-decode-string challenge))))
        "\r\n"))
-      (nnimap-wait-for-response sequence)))))
+      (nnimap-wait-for-response sequence)))
+   ((not (nnimap-capability "LOGINDISABLED"))
+    (nnimap-command "LOGIN %S %S" user password))
+   ((nnimap-capability "AUTH=PLAIN")
+    (nnimap-command
+     "AUTHENTICATE PLAIN %s"
+     (base64-encode-string
+      (format "\000%s\000%s"
+             (nnimap-quote-specials user)
+             (nnimap-quote-specials password)))))))
 
 (defun nnimap-quote-specials (string)
   (with-temp-buffer