diff options
| author | Michael Albinus | 2024-01-11 12:30:05 +0100 |
|---|---|---|
| committer | Michael Albinus | 2024-01-11 12:30:05 +0100 |
| commit | ef08f94cbec1a9fb98bc1bbfcc88cd399b7ff8d0 (patch) | |
| tree | c99a9bd2976f4f01589ed74043e6c2581e33bfab /lisp/auth-source.el | |
| parent | c7aa5c6d2b838e2fd84db4cbdafdbd546dd87832 (diff) | |
| download | emacs-ef08f94cbec1a9fb98bc1bbfcc88cd399b7ff8d0.tar.gz emacs-ef08f94cbec1a9fb98bc1bbfcc88cd399b7ff8d0.zip | |
Support numeric port numbers in auth-source-macos-keychain
* lisp/auth-source.el (auth-source-macos-keychain-search):
Support numeric port numbers (bug#68376).
(auth-source-macos-keychain-search-items): Make regexp more robust.
* test/lisp/auth-source-tests.el (test-macos-keychain-search):
Extend test.
Diffstat (limited to 'lisp/auth-source.el')
| -rw-r--r-- | lisp/auth-source.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el index 369cf4dca2e..cf93cb05fba 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el | |||
| @@ -1946,18 +1946,20 @@ entries for git.gnus.org: | |||
| 1946 | (returned-keys (delete-dups (append | 1946 | (returned-keys (delete-dups (append |
| 1947 | '(:host :login :port :secret) | 1947 | '(:host :login :port :secret) |
| 1948 | search-keys))) | 1948 | search-keys))) |
| 1949 | ;; Extract host and port from spec | 1949 | ;; Extract host, port and user from spec |
| 1950 | (hosts (plist-get spec :host)) | 1950 | (hosts (plist-get spec :host)) |
| 1951 | (hosts (if (and hosts (listp hosts)) hosts `(,hosts))) | 1951 | (hosts (if (consp hosts) hosts `(,hosts))) |
| 1952 | (ports (plist-get spec :port)) | 1952 | (ports (plist-get spec :port)) |
| 1953 | (ports (if (and ports (listp ports)) ports `(,ports))) | 1953 | (ports (if (consp ports) ports `(,ports))) |
| 1954 | (users (plist-get spec :user)) | 1954 | (users (plist-get spec :user)) |
| 1955 | (users (if (and users (listp users)) users `(,users))) | 1955 | (users (if (consp users) users `(,users))) |
| 1956 | ;; Loop through all combinations of host/port and pass each of these to | 1956 | ;; Loop through all combinations of host/port and pass each of these to |
| 1957 | ;; auth-source-macos-keychain-search-items | 1957 | ;; auth-source-macos-keychain-search-items. Convert numeric port to |
| 1958 | ;; string (bug#68376). | ||
| 1958 | (items (catch 'match | 1959 | (items (catch 'match |
| 1959 | (dolist (host hosts) | 1960 | (dolist (host hosts) |
| 1960 | (dolist (port ports) | 1961 | (dolist (port ports) |
| 1962 | (when (numberp port) (setq port (number-to-string port))) | ||
| 1961 | (dolist (user users) | 1963 | (dolist (user users) |
| 1962 | (let ((items (apply | 1964 | (let ((items (apply |
| 1963 | #'auth-source-macos-keychain-search-items | 1965 | #'auth-source-macos-keychain-search-items |
| @@ -2019,7 +2021,7 @@ entries for git.gnus.org: | |||
| 2019 | (when port | 2021 | (when port |
| 2020 | (if keychain-generic | 2022 | (if keychain-generic |
| 2021 | (setq args (append args (list "-s" port))) | 2023 | (setq args (append args (list "-s" port))) |
| 2022 | (setq args (append args (if (string-match "[0-9]+" port) | 2024 | (setq args (append args (if (string-match-p "\\`[[:digit:]]+\\'" port) |
| 2023 | (list "-P" port) | 2025 | (list "-P" port) |
| 2024 | (list "-r" (substring | 2026 | (list "-r" (substring |
| 2025 | (format "%-4s" port) | 2027 | (format "%-4s" port) |