aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/auth-source.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/auth-source.el')
-rw-r--r--lisp/auth-source.el36
1 files changed, 16 insertions, 20 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index d1747bda3da..d4b44a59529 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -200,8 +200,6 @@ Note that if EPA/EPG is not available, this should NOT be used."
200 (const :tag "Save GPG-encrypted password tokens" gpg) 200 (const :tag "Save GPG-encrypted password tokens" gpg)
201 (const :tag "Don't encrypt tokens" never)))))) 201 (const :tag "Don't encrypt tokens" never))))))
202 202
203(defvar auth-source-magic "auth-source-magic ")
204
205(defcustom auth-source-do-cache t 203(defcustom auth-source-do-cache t
206 "Whether auth-source should cache information with `password-cache'." 204 "Whether auth-source should cache information with `password-cache'."
207 :group 'auth-source 205 :group 'auth-source
@@ -782,16 +780,16 @@ Returns the deleted entries."
782(defun auth-source-forget-all-cached () 780(defun auth-source-forget-all-cached ()
783 "Forget all cached auth-source data." 781 "Forget all cached auth-source data."
784 (interactive) 782 (interactive)
785 (cl-do-symbols (sym password-data) 783 (maphash (lambda (key _password)
786 ;; when the symbol name starts with auth-source-magic 784 (when (eq 'auth-source (car-safe key))
787 (when (string-match (concat "^" auth-source-magic) (symbol-name sym)) 785 ;; remove that key
788 ;; remove that key 786 (password-cache-remove key)))
789 (password-cache-remove (symbol-name sym)))) 787 password-data)
790 (setq auth-source-netrc-cache nil)) 788 (setq auth-source-netrc-cache nil))
791 789
792(defun auth-source-format-cache-entry (spec) 790(defun auth-source-format-cache-entry (spec)
793 "Format SPEC entry to put it in the password cache." 791 "Format SPEC entry to put it in the password cache."
794 (concat auth-source-magic (format "%S" spec))) 792 `(auth-source . ,spec))
795 793
796(defun auth-source-remember (spec found) 794(defun auth-source-remember (spec found)
797 "Remember FOUND search results for SPEC." 795 "Remember FOUND search results for SPEC."
@@ -822,18 +820,16 @@ This is not a full `auth-source-search' spec but works similarly.
822For instance, \(:host \"myhost\" \"yourhost\") would find all the 820For instance, \(:host \"myhost\" \"yourhost\") would find all the
823cached data that was found with a search for those two hosts, 821cached data that was found with a search for those two hosts,
824while \(:host t) would find all host entries." 822while \(:host t) would find all host entries."
825 (let ((count 0) 823 (let ((count 0))
826 sname) 824 (maphash
827 (cl-do-symbols (sym password-data) 825 (lambda (key _password)
828 ;; when the symbol name matches with auth-source-magic 826 (when (and (eq 'auth-source (car-safe key))
829 (when (and (setq sname (symbol-name sym)) 827 ;; and the spec matches what was stored in the cache
830 (string-match (concat "^" auth-source-magic "\\(.+\\)") 828 (auth-source-specmatchp spec (cdr key)))
831 sname) 829 ;; remove that key
832 ;; and the spec matches what was stored in the cache 830 (password-cache-remove key)
833 (auth-source-specmatchp spec (read (match-string 1 sname)))) 831 (cl-incf count)))
834 ;; remove that key 832 password-data)
835 (password-cache-remove sname)
836 (cl-incf count)))
837 count)) 833 count))
838 834
839(defun auth-source-specmatchp (spec stored) 835(defun auth-source-specmatchp (spec stored)