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: Viktor Slavkovik
Subject: bug#24274: 24.5; Use auth-source library for remote passwords in Rmail
Date: Sun, 21 Aug 2016 16:26:31 +0200

Ivan Shmakov <ivan@siamics.net> writes:

>>>>>> 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)))

I've made an update (attached) to the previous patch. I removed the code
indentation spaces and changed the docstring to be more
descriptive. Also, I included a function check for the auth-source
password which was missing before.

I don't think that the ':create' parameter of auth-source-search should
be used here, since we don't know if the authentication will be
successful.

Attachment: patch_update
Description: updated patch


reply via email to

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