Gnus auth with username being prepended to domain

0

I'm trying to solve the problem of Gnus asking you to type a username which it then prepends to the IMAP domain, i.e. preventing Gnus from making username typed at prompt foo@bar.com into foo@bar.com@mail.bar.com.

All the guides I've read online specify something like this for setting up login credentials:

Place a line like the following in ~/.authinfo

machine imap.gmail.com login your-name@gmail.com password your-password port 993

Following that, I added a string that looks like this:

machine mail.foo.com login me@foo.com port 993

This gets me good behavior (prompt for password only), but still prepends the whole username to the machine address. Worse, when I try to change something and repeat the login, I get an error Wrong type argument: wholenump, nil.

My gnus.el file has the following for IMAP:

; IMAP
(setq gnus-select-method
      '(nnimap "mymail"
               (nnimap-address "mail.bar.com")
               (nnimap-server-port 993)
               (nnimap-stream ssl)))

bright-star

Posted 2014-03-25T02:11:37.387

Reputation: 1 489

1In my numerous attempts at setting up Wanderlust, I came across something similar with a separate authorization file -- I ended up using something like this directly in my configuration file without needing a separate authorization file -- perhaps the regular gnu email is similar: (setq smtpmail-auth-credentials '(("mail.msn.com" 587 "user-name" "password"))) – lawlist – 2014-03-25T05:17:59.727

Answers

0

The prompt is hard-coded in the source (nnimap.el):

(defun nnimap-credentials (address ports user)
  (let* ((auth-source-creation-prompts
          '((user  . "IMAP user at %h: ")
            (secret . "IMAP password for %u@%h: ")))
         (found (nth 0 (auth-source-search :max 1
                                           :host address
                                           :port ports
                                           :user user
                                           :require '(:user :secret)
                                           :create t))))
    (if found
        (list (plist-get found :user)
          (let ((secret (plist-get found :secret)))
        (if (functionp secret)
            (funcall secret)
          secret))
          (plist-get found :save-function))
      nil)))

So it seems like the only way to change this is to redefine the function and modify the prompt to be just "IMAP password for %u: ".

legoscia

Posted 2014-03-25T02:11:37.387

Reputation: 2 197

Sorry, I can't read elisp too well, but is this snippet actually appending the whole server to the input username? – bright-star – 2014-03-25T21:46:24.350

1Yes, it is. %u stands for the username, and %h stands for the server hostname. – legoscia – 2014-03-26T12:43:53.210

It seems like the best way to take care of this is to advise the function. How would I go about doing that? (The emacswiki is not so clear about this for more complicated functions.) – bright-star – 2014-04-07T21:23:00.763