bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24274: 24.5; Use auth-source library for remote passwords in Rmail


From: Ivan Shmakov
Subject: bug#24274: 24.5; Use auth-source library for remote passwords in Rmail
Date: Sat, 20 Aug 2016 19:45:50 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

>>>>> Viktor Slavkovikj <zhtvk@gmx.com> writes:

 > Hi, I thought that it would be convenient to obtain remote passwords
 > in Rmail from an authinfo file.  Therefore, I modified rmail.el to
 > make use of the auth-source library.  I include a patch for this
 > small feature in attachment.  Do you think that there could be any
 > drawbacks to using this approach?

        Personally, I can’t readily think of any.  (Not that I’m
        particularly familiar with either.)

        One issue I see with your patch is that it expands TABs into
        spaces outside of the actual code changes.  If deliberate, I’d
        rather see such whitespace changes in a separate patch.

 > ! (defun rmail-get-remote-password (imap user host)
 > !   "Get the password for retrieving mail from a POP or IMAP server.
 > ! If none has been set, check authinfo for one. If authinfo search
 > ! yields no result, prompt the user for the password."

        The auth-source library allows access to other backends beside
        plain ~/.authinfo, which is why I think it makes sense to
        mention the library by name here.  See the docstring for the
        erc-autojoin-channels-alist variable for an example.

 >     (when (not rmail-encoded-remote-password)
 >       (if (not rmail-remote-password)
 > !         (setq rmail-remote-password
 > !               (let ((found (nth 0 (auth-source-search :max 1
 > !                                                       :user user           
 >                                            
 > !                                                       :host host
 > !                                                       :require 
 > '(:secret)))))
 > !                    (if found
 > !                        (funcall (plist-get found :secret))
 > !                      (read-passwd (if imap
 > !                                       "IMAP password: "
 > !                                     "POP password: "))))))

        The auth-source-search function will prompt for password
        automatically if given ‘:create t’ among its parameters, making
        explicit read-passwd unnecessary.  (But check also the
        auth-source-creation-prompts variable.)

 >       (rmail-set-remote-password rmail-remote-password)
 >       (setq rmail-remote-password nil))
 >     (rmail-encode-string rmail-encoded-remote-password (emacs-pid)))

-- 
FSF associate member #7257  http://am-1.org/~ivan/      … 3013 B6A0 230E 334A





reply via email to

[Prev in Thread] Current Thread [Next in Thread]