質問

My main problem right now is that in gnus.el i got several mail sources set in a manner like:

(setq mail-sources
  '((pop :server "server.org"
     :port 995
     :user "user@server.org"
     :password "pAssWorD")

I don't want to store passwords in a plain text file like that. What i want is:

  1. Store passwords for Gnus mail sources in a separate file with strict permissions and encrypted using gpg.
  2. When using Emacs enter passphrase once and have these passwords automatically used when fetching mail.

What is the most idiomatic/efficient way to do that?

I'm also interested in any general ideas about password management in Emacs, be it just storing them somewhere in an encrypted files or having them managed for particular Emacs packages.

Emacs version: 24.0.97

役に立ちましたか?

解決

I couldn't make .authinfo file work with POP3, so i followed the Keeping your secrets secret blogpost (thanks to phils for the link). I created three files in my load-path. secrets.el:

(load-library "secrets.el.gpg")
(provide 'secrets)

secrets.el.gpg:

(setq password-alist
      '((:mbox1 . "pAsSwOrD")
        (:mbox2 . "correct horse battery staple")
        (:mbox3 . "qwfpgj")))

mail.el:

(defun load-mail-passwords ()
  "Load passwords for mail sources from secrets.el.gpg"
  (require 'secrets)
  (setq mail-sources
    `((pop :server "pop.server.org"
           :port 995
           :user "user@server.org"
           :password ,(rest (assoc :mbox1 password-alist)))
      ))
  (setq smtpmail-auth-credentials `(("smtp.server.org" "465" "user@server.org"
                                     ,(rest (assoc :mbox1 password-alist))))))
(add-hook 'gnus-load-hook 'load-mail-passwords)

And i also put (load "~/.emacs.d/mail.el") to my init file, because for some reason my ~/.emacs.d/ folder in load-path wasn't being loaded automatically.

The backtick is like apostrophe (quote), but it allows some expressions to be unquoted using comma. The (rest (assoc :keyword alist)) combination is to get the second part of the dotted pair in association list.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top