aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgalaunay2019-01-13 21:30:53 +0000
committerDamien Cassou2019-06-24 09:15:40 +0200
commita63cbb56dfc6074189407e9e182e807ce058e618 (patch)
treefbfa119a4917068c1867c9b908c12016a98da00f
parent9574565202a1a9a58a38b067b0230933733c0b4b (diff)
downloademacs-a63cbb56dfc6074189407e9e182e807ce058e618.tar.gz
emacs-a63cbb56dfc6074189407e9e182e807ce058e618.zip
Add auth-source-pass-filename option
* lisp/auth-source-pass.el (auth-source-pass) (auth-source-pass-filename): Add option to specify a customized password-store path. (auth-source-pass--read-entry) (auth-source-pass-entries): Use the new option instead of hard-coded `~/.password-store'.
-rw-r--r--lisp/auth-source-pass.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 4fcb1015e76..1fda6982328 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -38,6 +38,17 @@
38(require 'auth-source) 38(require 'auth-source)
39(require 'url-parse) 39(require 'url-parse)
40 40
41(defgroup auth-source-pass nil
42 "password-store integration within auth-source."
43 :prefix "auth-source-pass-"
44 :group 'auth-source
45 :version "27.1")
46
47(defcustom auth-source-pass-filename "~/.password-store"
48 "Filename of the password-store folder."
49 :type 'directory
50 :version "27.1")
51
41(cl-defun auth-source-pass-search (&rest spec 52(cl-defun auth-source-pass-search (&rest spec
42 &key backend type host user port 53 &key backend type host user port
43 &allow-other-keys) 54 &allow-other-keys)
@@ -121,7 +132,7 @@ key2: value2"
121 (with-temp-buffer 132 (with-temp-buffer
122 (insert-file-contents (expand-file-name 133 (insert-file-contents (expand-file-name
123 (format "%s.gpg" entry) 134 (format "%s.gpg" entry)
124 "~/.password-store")) 135 auth-source-pass-filename))
125 (buffer-substring-no-properties (point-min) (point-max)))) 136 (buffer-substring-no-properties (point-min) (point-max))))
126 137
127(defun auth-source-pass-parse-entry (entry) 138(defun auth-source-pass-parse-entry (entry)
@@ -188,7 +199,7 @@ often."
188;; in Emacs 199;; in Emacs
189(defun auth-source-pass-entries () 200(defun auth-source-pass-entries ()
190 "Return a list of all password store entries." 201 "Return a list of all password store entries."
191 (let ((store-dir (expand-file-name "~/.password-store/"))) 202 (let ((store-dir (expand-file-name auth-source-pass-filename)))
192 (mapcar 203 (mapcar
193 (lambda (file) (file-name-sans-extension (file-relative-name file store-dir))) 204 (lambda (file) (file-name-sans-extension (file-relative-name file store-dir)))
194 (directory-files-recursively store-dir "\\.gpg$")))) 205 (directory-files-recursively store-dir "\\.gpg$"))))