[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 57e763a 07/13: Split out the attribute retrieval fo
From: |
Damien Cassou |
Subject: |
[Emacs-diffs] master 57e763a 07/13: Split out the attribute retrieval form auth-source-pass-get |
Date: |
Mon, 24 Jun 2019 03:22:46 -0400 (EDT) |
branch: master
commit 57e763a0a057621daac2761084556df38f7f2373
Author: Keith Amidon <address@hidden>
Commit: Damien Cassou <address@hidden>
Split out the attribute retrieval form auth-source-pass-get
Eliminate the need to repeatedly retrieve and parse the data for the
entry. This is generally a good thing since it eliminates repetitions
of the same crypto and parsing operations. It is especially valuable
when protecting an entry with a yubikey with touch required for crypto
operations as it eliminates the need to touch the yubikey sensor for
each attribute retrieved.
* lisp/auth-source-pass.el (auth-source-pass-get): Extract some code to
`auth-source-pass--get-attr'.
(auth-source-pass--get-attr): New function to get a field value from a
parsed entry.
(auth-source-pass--build-result): Make use of
`auth-source-pass--get-attr` to avoid repeated parsing.
---
lisp/auth-source-pass.el | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 4aa0853..a0b0841 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -79,11 +79,12 @@ See `auth-source-search' for details on SPEC."
"Build auth-source-pass entry matching HOST, PORT and USER."
(let ((entry (auth-source-pass--find-match host user port)))
(when entry
- (let ((retval (list
- :host host
- :port (or (auth-source-pass-get "port" entry) port)
- :user (or (auth-source-pass-get "user" entry) user)
- :secret (lambda () (auth-source-pass-get 'secret
entry)))))
+ (let* ((entry-data (auth-source-pass-parse-entry entry))
+ (retval (list
+ :host host
+ :port (or (auth-source-pass--get-attr "port" entry-data)
port)
+ :user (or (auth-source-pass--get-attr "user" entry-data)
user)
+ :secret (lambda () (auth-source-pass--get-attr 'secret
entry-data)))))
(auth-source-pass--do-debug "return %s as final result (plus hidden
password)"
(seq-subseq retval 0 -2)) ;; remove
password
retval))))
@@ -128,9 +129,18 @@ secret
key1: value1
key2: value2"
(let ((data (auth-source-pass-parse-entry entry)))
- (or (cdr (assoc key data))
- (and (string= key "user")
- (cdr (assoc "username" data))))))
+ (auth-source-pass--get-attr key data)))
+
+(defun auth-source-pass--get-attr (key entry-data)
+ "Return value associated with KEY in an ENTRY-DATA.
+
+ENTRY-DATA is the data from a parsed password-store entry.
+The key used to retrieve the password is the symbol `secret'.
+
+See `auth-source-pass-get'."
+ (or (cdr (assoc key entry-data))
+ (and (string= key "user")
+ (cdr (assoc "username" entry-data)))))
(defun auth-source-pass--read-entry (entry)
"Return a string with the file content of ENTRY."
- [Emacs-diffs] master updated (b9ac4f8 -> 157fced), Damien Cassou, 2019/06/24
- [Emacs-diffs] master 527efaf 01/13: Fix auth-source-pass to return nil if no entry found, Damien Cassou, 2019/06/24
- [Emacs-diffs] master a63cbb5 04/13: Add auth-source-pass-filename option, Damien Cassou, 2019/06/24
- [Emacs-diffs] master 9574565 03/13: * lisp/auth-source-pass.el (auth-source-pass-get): Add autoload, Damien Cassou, 2019/06/24
- [Emacs-diffs] master ba11be0 02/13: * lisp/auth-source-pass.el: Version 4.0.2, Damien Cassou, 2019/06/24
- [Emacs-diffs] master 94c9eb8 06/13: Fix auth-source-pass to search for hostname:port/username, Damien Cassou, 2019/06/24
- [Emacs-diffs] master e6fc02f 11/13: * lisp/auth-source-pass.el: Version 5.0.0, Damien Cassou, 2019/06/24
- [Emacs-diffs] master 57e763a 07/13: Split out the attribute retrieval form auth-source-pass-get,
Damien Cassou <=
- [Emacs-diffs] master 736f78b 09/13: * lisp/auth-source-pass.el: Add Keith Amidon to authors, Damien Cassou, 2019/06/24
- [Emacs-diffs] master 34f01eb 12/13: * etc/NEWS: Describe changes to auth-source-pass, Damien Cassou, 2019/06/24
- [Emacs-diffs] master 157fced 13/13: * doc/misc/auth.texi (The Unix password store): Complete rewrite, Damien Cassou, 2019/06/24
- [Emacs-diffs] master 0a580c1 08/13: Minimize entry parsing in auth-source-pass, Damien Cassou, 2019/06/24
- [Emacs-diffs] master 2a0a057 05/13: Add auth-source-pass-port-separator option, Damien Cassou, 2019/06/24
- [Emacs-diffs] master 7022e3f 10/13: Refactoring of auth-source-pass, Damien Cassou, 2019/06/24