Subject: 24.5; nnimap: anonymous login to IMAP server not working

From: Jonathan Marten <[email-masked]>
Date: Sun, 16 Oct 2016 06:06:19 +0100

Gnus (gnus-version = "Gnus v5.13") configured for anonymous IMAP login
does not log in to the IMAP server.  Setting in .gnus:

(setq gnus-secondary-select-methods
      '((nnfolder "")
        (nnimap "imapserv"
                (nnimap-authenticator anonymous)
                (nnimap-stream network))))

and starting Gnus produces the echo area messages:

Reading /home/jjm/.newsrc.eld...
Checking new news...
Reading active file via nnfolder...
Opening nnfolder server...done
nnfolder: Reading incoming mail (no new mail)...done
Reading active file via nnfolder...done
Opening connection to imapserv...
Reading active file via nndraft...done
Checking new news...done
No news is good news

with all of the groups on that server showing "*" for the message counts.  
Entering one of those groups produces the message "Couldn't open server".  In 
the server buffer the server is shown as:

     {nnimap:imapnews} (denied)

Observing the IMAP network connection with wireshark shows that the CAPABILITY 
request is sent and returned correctly, but no further IMAP activity takes 
place after that (in particular, no LOGIN is sent).

Stepping through nnimap-login in nnimap.el shows that the parameters passed to 
it are user="anonymous", password=(email address).  The problem seems to be 
that nnimap-authenticator=anonymous is not handled by any of the conditions in 
this function, so no login is sent.  Applying the patch:

--- /usr/share/emacs/24.5/lisp/gnus/nnimap.el   2015-04-02 08:23:06.000000000 
+0100
+++ nnimap.el   2016-10-16 05:53:16.043526259 +0100
@@ -504,6 +504,7 @@
    ((and (not (nnimap-capability "LOGINDISABLED"))
         (eq (nnimap-stream-type nnimap-object) 'tls)
         (or (null nnimap-authenticator)
+            (eq nnimap-authenticator 'anonymous)
             (eq nnimap-authenticator 'login)))
     (nnimap-command "LOGIN %S %S" user password))
    ((and (nnimap-capability "AUTH=CRAM-MD5")
@@ -523,6 +524,7 @@
       (nnimap-wait-for-response sequence)))
    ((and (not (nnimap-capability "LOGINDISABLED"))
         (or (null nnimap-authenticator)
+            (eq nnimap-authenticator 'anonymous)
             (eq nnimap-authenticator 'login)))
     (nnimap-command "LOGIN %S %S" user password))
    ((and (nnimap-capability "AUTH=PLAIN")

handles the anonymous login case (in the same way as plain login) and 
correctly logs in to the IMAP server.

In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
 of 2016-10-11 on keelhaul
Windowing system distributor `The X.Org Foundation', version 11.0.11804000
Configured using:
 `configure --prefix=/usr --build=x86_64-pc-linux-gnu
 --host=x86_64-pc-linux-gnu --mandir=/usr/share/man
 --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
 --localstatedir=/var/lib --disable-dependency-tracking
 --disable-silent-rules --docdir=/usr/share/doc/emacs-24.5-r3
 --htmldir=/usr/share/doc/emacs-24.5-r3/html --libdir=/usr/lib64
 --program-suffix=-emacs-24 --infodir=/usr/share/info/emacs-24
 --localstatedir=/var
 --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
 --with-gameuser=:gamestat --without-compress-install
 --with-file-notification=inotify --enable-acl --without-dbus
 --without-gpm --without-hesiod --without-kerberos --without-kerberos5
 --with-xml2 --without-selinux --with-gnutls --without-wide-int
 --with-zlib --with-sound=alsa --with-x --without-ns --without-gconf
 --without-gsettings --with-toolkit-scroll-bars --with-gif --with-jpeg
 --with-png --with-rsvg --with-tiff --with-xpm --with-imagemagick
 --with-xft --without-libotf --without-m17n-flt --with-x-toolkit=gtk2
 GENTOO_PACKAGE=app-editors/emacs-24.5-r3 'CFLAGS=-O2 -march=native
 -pipe' CPPFLAGS= 'LDFLAGS=-Wl,-O1 -Wl,--as-needed''

Important settings:
  value of $EMACSLOADPATH: /usr/local/lib/xemacs/local:
  value of $LC_COLLATE: C
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_TIME: C
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  transient-mark-mode: t

Recent messages:
Saving file /home/jjm/.newsrc...
Wrote /home/jjm/.newsrc
Saving /home/jjm/.newsrc...done
Saving /home/jjm/.newsrc.eld...
Saving file /home/jjm/.newsrc.eld...
Wrote /home/jjm/.newsrc.eld
Saving /home/jjm/.newsrc.eld...done
Type C-x 1 to delete the help window, C-M-v to scroll help.
Type C-x 4 C-o RET to restore the other window.  

Load-path shadows:
/usr/local/lib/xemacs/local/site-start hides /etc/emacs/site-start

Features:
(shadow sort emacsbug sendmail qp mm-archive utf-7 goto-addr noutline
outline view sgml-mode smiley gnus-cite mail-extr gnus-async gnus-bcklg
cl-macs gv edebug gnus-ml disp-table gnus-topic nndraft nnmh nnimap
parse-time utf7 nnfolder gnus-agent gnus-srvr gnus-score score-mode
nnvirtual gnus-msg gnus-art mm-uu mml2015 epg-config mm-view mml-smime
smime dig gnus-cache gnus-sum netrc gnutls network-stream starttls tls
nntp gnus-group gnus-undo nnmail mail-source nnoo gnus-start gnus-spec
gnus-int gnus-range gnus-win gnus gnus-ems nnheader apropos cc-langs
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs thingatpt mule-util cus-theme eieio-custom wid-browse
tree-widget cus-edit cus-start cus-load wid-edit log-edit easy-mmode
message format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils
gmm-utils mailheader pcvs-util add-log vc vc-dispatcher eieio-opt
speedbar sb-image ezimage dframe find-func warnings help-mode easymenu
misearch multi-isearch pp vc-sccs server sunkbd redo+ paren browse-url
paren-xe blink-paren frame-select auto-set-indent sourcepair riscos url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util url-parse auth-source eieio byte-opt bytecomp
byte-compile cl-extra cl-loaddefs cl-lib cconv eieio-core gnus-util
mm-util mail-prsvr password-cache url-vars mailcap compile comint
ansi-color ring datetrack edj advice help-fns gnu-compat time-date
tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
inotify dynamic-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)

Memory information:
((conses 16 281130 29553)
 (symbols 48 34580 0)
 (miscs 40 920 689)
 (strings 32 58901 4711)
 (string-bytes 1 1883171)
 (vectors 16 27253)
 (vector-slots 8 593487 19651)
 (floats 8 259 795)
 (intervals 56 4912 0)
 (buffers 960 51)
 (heap 1024 40905 12916))

--