summaryrefslogtreecommitdiff
path: root/lisp/auth-source-pass.el
diff options
context:
space:
mode:
authorJelle Licht <jlicht@fsfe.org>2018-01-08 17:34:38 +0100
committerNicolas Petton <nicolas@petton.fr>2018-06-05 15:51:26 +0200
commit1d2551f8e70ab80a6f57ee11ab70f54aa916adcd (patch)
tree12bd87f8901445dd326e9e8219ad9fd6e259da14 /lisp/auth-source-pass.el
parentb43ed61ef985e01975b90d7e0ec3cac70d0afefa (diff)
downloademacs-1d2551f8e70ab80a6f57ee11ab70f54aa916adcd.tar.gz
emacs-1d2551f8e70ab80a6f57ee11ab70f54aa916adcd.tar.bz2
emacs-1d2551f8e70ab80a6f57ee11ab70f54aa916adcd.zip
Fix auth-source-pass.el to properly handle special inputs
* lisp/auth-source-pass.el (auth-source-pass-search): Warn when passing multiple hosts in SPEC. Early return and warn when passing a wildcard as host in SPEC. Early return when host is nil. * test/lisp/auth-source-pass-tests.el (auth-source-pass-any-host, auth-source-pass-undefined-host): Add corresponding tests.
Diffstat (limited to 'lisp/auth-source-pass.el')
-rw-r--r--lisp/auth-source-pass.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 96aefc8dd7e..461cba02dd4 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -45,10 +45,18 @@
See `auth-source-search' for details on SPEC."
(cl-assert (or (null type) (eq type (oref backend type)))
t "Invalid password-store search: %s %s")
- (when (listp host)
+ (when (consp host)
+ (warn "auth-source-pass ignores all but first host in spec.")
;; Take the first non-nil item of the list of hosts
(setq host (seq-find #'identity host)))
- (list (auth-source-pass--build-result host port user)))
+ (cond ((eq host t)
+ (warn "auth-source-pass does not handle host wildcards.")
+ nil)
+ ((null host)
+ ;; Do not build a result, as none will match when HOST is nil
+ nil)
+ (t
+ (list (auth-source-pass--build-result host port user)))))
(defun auth-source-pass--build-result (host port user)
"Build auth-source-pass entry matching HOST, PORT and USER."