Add an in-memory netrc cache (for now) to make ~/.authinfo.gpg files usable.
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 21 Feb 2011 01:34:09 +0000 (17:34 -0800)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 21 Feb 2011 01:34:09 +0000 (17:34 -0800)
lisp/ChangeLog
lisp/auth-source.el

index 616ed34..16e1fa3 100644 (file)
@@ -1,5 +1,8 @@
 2011-02-21  Lars Ingebrigtsen  <larsi@gnus.org>
 
+       * auth-source.el (auth-source-netrc-parse): Add an in-memory netrc
+       cache (for now) to make ~/.authinfo.gpg files usable.
+
        * nnfolder.el (copyright-update): Define for the compiler.
 
        * auth-source.el (auth-source-search): Fix unbound variable.
index eaed8e8..3fe31b5 100644 (file)
@@ -690,6 +690,8 @@ while \(:host t) would find all host entries."
 
 ;;; Backend specific parsing: netrc/authinfo backend
 
+(defvar auth-source-netrc-cache nil)
+
 ;;; (auth-source-netrc-parse "~/.authinfo.gpg")
 (defun* auth-source-netrc-parse (&rest
                                  spec
@@ -708,7 +710,19 @@ Note that the MAX parameter is used so we can exit the parse early."
               (max (or max 5000))       ; sanity check: default to stop at 5K
               (modified 0)
               alist elem result pair)
-          (insert-file-contents file)
+         (if (and auth-source-netrc-cache
+                  (equal (car auth-source-netrc-cache)
+                         (nth 5 (file-attributes file))))
+             (insert (base64-decode-string
+                      (rot13-string (cdr auth-source-netrc-cache))))
+           (insert-file-contents file)
+           (when (string-match "\\.gpg\\'" file)
+             ;; Store the contents of the file heavily encrypted in memory.
+             (setq auth-source-netrc-cache
+                   (cons (nth 5 (file-attributes file))
+                         (rot13-string
+                          (base64-encode-string
+                           (buffer-string)))))))
           (goto-char (point-min))
           ;; Go through the file, line by line.
           (while (and (not (eobp))