unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7304: [Patch] AUTHENTICATE PLAIN for imap.el
@ 2010-10-29 19:50 Tom Regner
  2010-10-29 22:05 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Regner @ 2010-10-29 19:50 UTC (permalink / raw)
  To: submit

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

Severity: wishlist
Package: emacs,gnus,imap

The main mailserver at my work only provides AUTH=PLAIN as
authentication capability. Gnus (imap.el) does not provide that.

I added the missing functionality to imap.el, taking imap-login-auth as
example (the methods are very similar).

Please find attached the simple patch.

I allready send this patch to bugs@gnus.org, but there was no reaction -
asking for directions in #emacs at irc.freenode.org, I was made aware of
this possibility (via EmacsWiki).

If there is a problem with this patch, I'd be happy to adjust it, so
that it might be applied to a future release.

I developed it with/against GNU Emacs 23.2.1 and testet it against a
Zimbra Mailserver (I don't know which IMAP-Server is used in this suite,
or if it's even another imeplementation) and Cyrus-IMAPD.

kind regards, 
Tom Regner


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: authenticate plain for imap.el / Gnus --]
[-- Type: text/x-patch, Size: 2544 bytes --]

*** imap.el.bak	2010-10-28 11:17:05.000000000 +0200
--- imap.el	2010-10-28 15:13:12.000000000 +0200
***************
*** 311,316 ****
--- 311,317 ----
  			      cram-md5
  			      ;;sasl
  			      login
+ 			      plain
  			      anonymous)
    "Priority of authenticators to consider when authenticating to server.")
  
***************
*** 320,325 ****
--- 321,327 ----
      (sasl	imap-sasl-auth-p      imap-sasl-auth)
      (cram-md5   imap-cram-md5-p       imap-cram-md5-auth)
      (login      imap-login-p          imap-login-auth)
+     (plain      imap-plain-p          imap-plain-auth)
      (anonymous  imap-anonymous-p      imap-anonymous-auth)
      (digest-md5 imap-digest-md5-p     imap-digest-md5-auth))
    "Definition of authenticators.
***************
*** 948,953 ****
--- 950,958 ----
    (and (not (imap-capability 'LOGINDISABLED buffer))
         (not (imap-capability 'X-LOGIN-CMD-DISABLED buffer))))
  
+ (defun imap-plain-p (buffer)
+   t)
+ 
  (defun imap-quote-specials (string)
    (with-temp-buffer
      (insert string)
***************
*** 970,975 ****
--- 975,993 ----
  						(imap-quote-specials passwd)
  						"\""))))))
  
+ (defun imap-plain-auth (buffer)
+   "Login to server using the PLAIN command."
+   (message "imap: Plaintext authentication PLAIN...")
+   (imap-interactive-login buffer
+ 			  (lambda (user passwd)
+ 			    (imap-ok-p (imap-send-command-wait
+ 					 (concat "AUTHENTICATE PLAIN "
+ 						  (base64-encode-string
+ 						    (concat "\000" (imap-quote-specials user)
+ 							    "\000"
+ 							    (imap-quote-specials passwd)
+ 							    ))))))))
+ 
  (defun imap-anonymous-p (buffer)
    t)
  
***************
*** 1236,1242 ****
  	      auth)
  	  (while (setq auth (pop auths))
  	    ;; OK to use authenticator?
! 	    (setq imap-last-authenticator
  		  (assq auth imap-authenticator-alist))
  	    (when (funcall (nth 1 imap-last-authenticator) (current-buffer))
  	      (message "imap: Authenticating to `%s' using `%s'..."
--- 1254,1260 ----
  	      auth)
  	  (while (setq auth (pop auths))
  	    ;; OK to use authenticator?
! 	    (setq imap-last-authenticator		  
  		  (assq auth imap-authenticator-alist))
  	    (when (funcall (nth 1 imap-last-authenticator) (current-buffer))
  	      (message "imap: Authenticating to `%s' using `%s'..."
***************
*** 3013,3018 ****
--- 3031,3038 ----
  	  imap-cram-md5-auth
  	  imap-login-p
  	  imap-login-auth
+ 	  imap-plain-p
+ 	  imap-plain-auth
  	  imap-anonymous-p
  	  imap-anonymous-auth
  	  imap-open-1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-29 22:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-29 19:50 bug#7304: [Patch] AUTHENTICATE PLAIN for imap.el Tom Regner
2010-10-29 22:05 ` Lars Magne Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).