X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2699a55464f7b43171c7b0e64d095640904e9e21..493c66882d491bcd6178e580abea92787f3e1555:/lisp/net/netrc.el diff --git a/lisp/net/netrc.el b/lisp/net/netrc.el index ff0b52c2b9..16d9203ba0 100644 --- a/lisp/net/netrc.el +++ b/lisp/net/netrc.el @@ -1,6 +1,5 @@ ;;; netrc.el --- .netrc parsing functionality -;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1996-2012 Free Software Foundation, Inc. ;; Author: Lars Magne Ingebrigtsen ;; Keywords: news @@ -34,36 +33,28 @@ ;;; .netrc and .authinfo rc parsing ;;; -(defalias 'netrc-point-at-eol - (if (fboundp 'point-at-eol) - 'point-at-eol - 'line-end-position)) -(eval-when-compile - ;; This is unnecessary in the compiled version as it is a macro. - (if (fboundp 'bound-and-true-p) - (defalias 'netrc-bound-and-true-p 'bound-and-true-p) - (defmacro netrc-bound-and-true-p (var) - "Return the value of symbol VAR if it is bound, else nil." - `(and (boundp (quote ,var)) ,var)))) - (defgroup netrc nil "Netrc configuration." :group 'comm) (defcustom netrc-file "~/.authinfo" "File where user credentials are stored." + :version "24.1" :type 'file :group 'netrc) (defvar netrc-services-file "/etc/services" "The name of the services file.") +(defvar netrc-cache nil) + (defun netrc-parse (&optional file) (interactive "fFile to Parse: ") "Parse FILE and return a list of all entries in the file." (unless file (setq file netrc-file)) (if (listp file) + ;; We got already parsed contents; just return it. file (when (file-exists-p file) (with-temp-buffer @@ -71,7 +62,16 @@ "password" "account" "macdef" "force" "port")) alist elem result pair) - (insert-file-contents file) + (if (and netrc-cache + (equal (car netrc-cache) (nth 5 (file-attributes file)))) + (insert (base64-decode-string (rot13-string (cdr netrc-cache)))) + (insert-file-contents file) + (when (string-match "\\.gpg\\'" file) + ;; Store the contents of the file heavily encrypted in memory. + (setq 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 (not (eobp)) @@ -238,7 +238,7 @@ MODE can be \"login\" or \"password\", suitable for passing to ;;;###autoload (defun netrc-credentials (machine &rest ports) "Return a user name/password pair. -Port specifications will be prioritised in the order they are +Port specifications will be prioritized in the order they are listed in the PORTS list." (let ((list (netrc-parse)) found)