1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Add auth-source-pass-port-separator option

* lisp/auth-source-pass.el (auth-source-pass-port-separator): New
option to specify separator between host and port, default to
colon (":").
(auth-source-pass--find-match-unambiguous): Adapt to make use of the
new variable.
* test/lisp/auth-source-pass-tests.el: Add corresponding tests.
This commit is contained in:
Iku Iwasa 2019-04-07 17:59:59 +09:00 committed by Damien Cassou
parent a63cbb56df
commit 2a0a05789d
No known key found for this signature in database
GPG key ID: B68746238E59B548
2 changed files with 25 additions and 3 deletions

View file

@ -49,6 +49,11 @@
:type 'directory
:version "27.1")
(defcustom auth-source-pass-port-separator ":"
"Separator string between host and port in entry filename."
:type 'string
:version "27.1")
(cl-defun auth-source-pass-search (&rest spec
&key backend type host user port
&allow-other-keys)
@ -254,9 +259,15 @@ return nil.
HOSTNAME should not contain any username or port number."
(or
(and user port (auth-source-pass--find-one-by-entry-name (format "%s@%s:%s" user hostname port) user))
(and user (auth-source-pass--find-one-by-entry-name (format "%s@%s" user hostname) user))
(and port (auth-source-pass--find-one-by-entry-name (format "%s:%s" hostname port) nil))
(and user port (auth-source-pass--find-one-by-entry-name
(format "%s@%s%s%s" user hostname auth-source-pass-port-separator port)
user))
(and user (auth-source-pass--find-one-by-entry-name
(format "%s@%s" user hostname)
user))
(and port (auth-source-pass--find-one-by-entry-name
(format "%s%s%s" hostname auth-source-pass-port-separator port)
nil))
(auth-source-pass--find-one-by-entry-name hostname user)
;; if that didn't work, remove subdomain: foo.bar.com -> bar.com
(let ((components (split-string hostname "\\.")))