aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/netrc.el26
1 files changed, 13 insertions, 13 deletions
diff --git a/lisp/net/netrc.el b/lisp/net/netrc.el
index ff0b52c2b96..989470becad 100644
--- a/lisp/net/netrc.el
+++ b/lisp/net/netrc.el
@@ -34,18 +34,6 @@
34;;; .netrc and .authinfo rc parsing 34;;; .netrc and .authinfo rc parsing
35;;; 35;;;
36 36
37(defalias 'netrc-point-at-eol
38 (if (fboundp 'point-at-eol)
39 'point-at-eol
40 'line-end-position))
41(eval-when-compile
42 ;; This is unnecessary in the compiled version as it is a macro.
43 (if (fboundp 'bound-and-true-p)
44 (defalias 'netrc-bound-and-true-p 'bound-and-true-p)
45 (defmacro netrc-bound-and-true-p (var)
46 "Return the value of symbol VAR if it is bound, else nil."
47 `(and (boundp (quote ,var)) ,var))))
48
49(defgroup netrc nil 37(defgroup netrc nil
50 "Netrc configuration." 38 "Netrc configuration."
51 :group 'comm) 39 :group 'comm)
@@ -58,12 +46,15 @@
58(defvar netrc-services-file "/etc/services" 46(defvar netrc-services-file "/etc/services"
59 "The name of the services file.") 47 "The name of the services file.")
60 48
49(defvar netrc-cache nil)
50
61(defun netrc-parse (&optional file) 51(defun netrc-parse (&optional file)
62 (interactive "fFile to Parse: ") 52 (interactive "fFile to Parse: ")
63 "Parse FILE and return a list of all entries in the file." 53 "Parse FILE and return a list of all entries in the file."
64 (unless file 54 (unless file
65 (setq file netrc-file)) 55 (setq file netrc-file))
66 (if (listp file) 56 (if (listp file)
57 ;; We got already parsed contents; just return it.
67 file 58 file
68 (when (file-exists-p file) 59 (when (file-exists-p file)
69 (with-temp-buffer 60 (with-temp-buffer
@@ -71,7 +62,16 @@
71 "password" "account" "macdef" "force" 62 "password" "account" "macdef" "force"
72 "port")) 63 "port"))
73 alist elem result pair) 64 alist elem result pair)
74 (insert-file-contents file) 65 (if (and netrc-cache
66 (equal (car netrc-cache) (nth 5 (file-attributes file))))
67 ;; Store the contents of the file heavily encrypted in memory.
68 (insert (base64-decode-string (rot13-string (cdr netrc-cache))))
69 (insert-file-contents file)
70 (when (string-match "\\.gpg\\'" file)
71 (setq netrc-cache (cons (nth 5 (file-attributes file))
72 (rot13-string
73 (base64-encode-string
74 (buffer-string)))))))
75 (goto-char (point-min)) 75 (goto-char (point-min))
76 ;; Go through the file, line by line. 76 ;; Go through the file, line by line.
77 (while (not (eobp)) 77 (while (not (eobp))