diff options
| author | Michael Albinus | 2024-11-14 17:29:07 +0100 |
|---|---|---|
| committer | Michael Albinus | 2024-11-14 17:29:07 +0100 |
| commit | 6d42c70fd3e2e63c8f993a10c83dee7425f185d5 (patch) | |
| tree | b96c24a289023d7959d1ba87e21f5cab36748c47 | |
| parent | 70273dc9f7e01e5330abedb44b1c3e46430fbc69 (diff) | |
| download | emacs-6d42c70fd3e2e63c8f993a10c83dee7425f185d5.tar.gz emacs-6d42c70fd3e2e63c8f993a10c83dee7425f185d5.zip | |
Fix errors in Tramp's password cache expiration
* doc/misc/tramp.texi (Password handling): Mention expiration of
cached passwords when a session timeout happens.
* lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection): Rename
file property "process-attributes" to connection property
" process-attributes".
* lisp/net/tramp.el (tramp-read-passwd):
* lisp/net/tramp-sh.el (tramp-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-send-command):
Rename connection property "password-vector" to "pw-vector".
* lisp/net/tramp-sh.el (tramp-maybe-open-connection):
Use connection property "hop-vector".
* lisp/net/tramp.el (tramp-get-process-attributes)
(tramp-handle-list-system-processes): Rename file property
"process-attributes" to connection property " process-attributes".
(tramp-compute-multi-hops): Check for
`tramp-sh-file-name-handler-p', it works only for this.
(tramp-action-password, tramp-process-actions): Use connection
property "hop-vector".
(tramp-read-passwd, tramp-clear-passwd): Rewrite. (Bug#74105)
| -rw-r--r-- | doc/misc/tramp.texi | 6 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 5 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 7 | ||||
| -rw-r--r-- | lisp/net/tramp-sudoedit.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 216 |
5 files changed, 123 insertions, 113 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 05bd62b7714..d429ef33780 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi | |||
| @@ -2258,6 +2258,12 @@ this interactively. | |||
| 2258 | @vindex auth-source-do-cache | 2258 | @vindex auth-source-do-cache |
| 2259 | Set @code{auth-source-do-cache} to @code{nil} to disable password caching. | 2259 | Set @code{auth-source-do-cache} to @code{nil} to disable password caching. |
| 2260 | 2260 | ||
| 2261 | For connections which use a session-timeout, like @option{sudo}, | ||
| 2262 | @option{doas} and @option{run0}, the password cache is expired by | ||
| 2263 | @value{tramp} when the session expires (@pxref{Predefined connection | ||
| 2264 | information}). However, this makes only sense if the password cannot | ||
| 2265 | be retrieved from a persistent authentication file or store. | ||
| 2266 | |||
| 2261 | 2267 | ||
| 2262 | @node Connection caching | 2268 | @node Connection caching |
| 2263 | @section Reusing connection related information | 2269 | @section Reusing connection related information |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 4210d1247a8..7fbb2332e89 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -1106,7 +1106,8 @@ connection if a previous connection has died for some reason." | |||
| 1106 | ;; Maybe we know already that "su" is not supported. We cannot | 1106 | ;; Maybe we know already that "su" is not supported. We cannot |
| 1107 | ;; use a connection property, because we have not checked yet | 1107 | ;; use a connection property, because we have not checked yet |
| 1108 | ;; whether it is still the same device. | 1108 | ;; whether it is still the same device. |
| 1109 | (when (and user (not (tramp-get-file-property vec "/" "su-command-p" t))) | 1109 | (when |
| 1110 | (and user (not (tramp-get-connection-property vec " su-command-p" t))) | ||
| 1110 | (tramp-error vec 'file-error "Cannot switch to user `%s'" user)) | 1111 | (tramp-error vec 'file-error "Cannot switch to user `%s'" user)) |
| 1111 | 1112 | ||
| 1112 | (unless (process-live-p p) | 1113 | (unless (process-live-p p) |
| @@ -1191,7 +1192,7 @@ connection if a previous connection has died for some reason." | |||
| 1191 | (unless (tramp-adb-send-command-and-check vec nil) | 1192 | (unless (tramp-adb-send-command-and-check vec nil) |
| 1192 | (delete-process p) | 1193 | (delete-process p) |
| 1193 | ;; Do not flush, we need the nil value. | 1194 | ;; Do not flush, we need the nil value. |
| 1194 | (tramp-set-file-property vec "/" "su-command-p" nil) | 1195 | (tramp-set-connection-property vec " su-command-p" nil) |
| 1195 | (tramp-error | 1196 | (tramp-error |
| 1196 | vec 'file-error "Cannot switch to user `%s'" user))) | 1197 | vec 'file-error "Cannot switch to user `%s'" user))) |
| 1197 | 1198 | ||
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 8f66b9f030e..0182c8f8eb8 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -5246,9 +5246,10 @@ connection if a previous connection has died for some reason." | |||
| 5246 | (setq r-shell t))) | 5246 | (setq r-shell t))) |
| 5247 | (setq current-host l-host) | 5247 | (setq current-host l-host) |
| 5248 | 5248 | ||
| 5249 | ;; Set password prompt vector. | 5249 | ;; Set hop and password prompt vector. |
| 5250 | (tramp-set-connection-property p "hop-vector" hop) | ||
| 5250 | (tramp-set-connection-property | 5251 | (tramp-set-connection-property |
| 5251 | p "password-vector" | 5252 | p "pw-vector" |
| 5252 | (if (tramp-get-method-parameter | 5253 | (if (tramp-get-method-parameter |
| 5253 | hop 'tramp-password-previous-hop) | 5254 | hop 'tramp-password-previous-hop) |
| 5254 | (let ((pv (copy-tramp-file-name previous-hop))) | 5255 | (let ((pv (copy-tramp-file-name previous-hop))) |
| @@ -5304,6 +5305,8 @@ connection if a previous connection has died for some reason." | |||
| 5304 | tramp-actions-before-shell connection-timeout)) | 5305 | tramp-actions-before-shell connection-timeout)) |
| 5305 | 5306 | ||
| 5306 | ;; Next hop. | 5307 | ;; Next hop. |
| 5308 | (tramp-flush-connection-property p "hop-vector") | ||
| 5309 | (tramp-flush-connection-property p "pw-vector") | ||
| 5307 | (setq options "" | 5310 | (setq options "" |
| 5308 | target-alist (cdr target-alist) | 5311 | target-alist (cdr target-alist) |
| 5309 | previous-hop hop))) | 5312 | previous-hop hop))) |
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index af5cb8e4bdc..bd10a0eb922 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el | |||
| @@ -785,7 +785,7 @@ in case of error, t otherwise." | |||
| 785 | ;; Avoid process status message in output buffer. | 785 | ;; Avoid process status message in output buffer. |
| 786 | (set-process-sentinel p #'ignore) | 786 | (set-process-sentinel p #'ignore) |
| 787 | (tramp-post-process-creation p vec) | 787 | (tramp-post-process-creation p vec) |
| 788 | (tramp-set-connection-property p "password-vector" tramp-sudoedit-null-hop) | 788 | (tramp-set-connection-property p "pw-vector" tramp-sudoedit-null-hop) |
| 789 | (tramp-process-actions p vec nil tramp-sudoedit-sudo-actions) | 789 | (tramp-process-actions p vec nil tramp-sudoedit-sudo-actions) |
| 790 | (tramp-message vec 6 "%s\n%s" (process-exit-status p) (buffer-string)) | 790 | (tramp-message vec 6 "%s\n%s" (process-exit-status p) (buffer-string)) |
| 791 | (prog1 | 791 | (prog1 |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index dbec3d5807e..6d384d97db6 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -4707,7 +4707,7 @@ Parsing the remote \"ps\" output is controlled by | |||
| 4707 | It is not guaranteed, that all process attributes as described in | 4707 | It is not guaranteed, that all process attributes as described in |
| 4708 | `process-attributes' are returned. The additional attribute | 4708 | `process-attributes' are returned. The additional attribute |
| 4709 | `pid' shall be returned always." | 4709 | `pid' shall be returned always." |
| 4710 | (with-tramp-file-property vec "/" "process-attributes" | 4710 | (with-tramp-connection-property vec " process-attributes" |
| 4711 | (ignore-errors | 4711 | (ignore-errors |
| 4712 | (with-temp-buffer | 4712 | (with-temp-buffer |
| 4713 | (hack-connection-local-variables-apply | 4713 | (hack-connection-local-variables-apply |
| @@ -4754,7 +4754,7 @@ It is not guaranteed, that all process attributes as described in | |||
| 4754 | (defun tramp-handle-list-system-processes () | 4754 | (defun tramp-handle-list-system-processes () |
| 4755 | "Like `list-system-processes' for Tramp files." | 4755 | "Like `list-system-processes' for Tramp files." |
| 4756 | (let ((v (tramp-dissect-file-name default-directory))) | 4756 | (let ((v (tramp-dissect-file-name default-directory))) |
| 4757 | (tramp-flush-file-property v "/" "process-attributes") | 4757 | (tramp-flush-connection-property v " process-attributes") |
| 4758 | (mapcar (lambda (x) (cdr (assq 'pid x))) (tramp-get-process-attributes v)))) | 4758 | (mapcar (lambda (x) (cdr (assq 'pid x))) (tramp-get-process-attributes v)))) |
| 4759 | 4759 | ||
| 4760 | (defun tramp-get-lock-file (file) | 4760 | (defun tramp-get-lock-file (file) |
| @@ -4962,74 +4962,74 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.") | |||
| 4962 | (item vec) | 4962 | (item vec) |
| 4963 | choices proxy) | 4963 | choices proxy) |
| 4964 | 4964 | ||
| 4965 | ;; Ad-hoc proxy definitions. | 4965 | ;; `tramp-compute-multi-hops' could be called also for other file |
| 4966 | (tramp-add-hops vec) | 4966 | ;; name handlers, for example in `tramp-clear-passwd'. |
| 4967 | 4967 | (when (tramp-sh-file-name-handler-p vec) | |
| 4968 | ;; Look for proxy hosts to be passed. | 4968 | |
| 4969 | (setq choices tramp-default-proxies-alist) | 4969 | ;; Ad-hoc proxy definitions. |
| 4970 | (while choices | 4970 | (tramp-add-hops vec) |
| 4971 | (setq item (pop choices) | 4971 | |
| 4972 | proxy (eval (nth 2 item) t)) | 4972 | ;; Look for proxy hosts to be passed. |
| 4973 | (when (and | 4973 | (setq choices tramp-default-proxies-alist) |
| 4974 | ;; Host. | 4974 | (while choices |
| 4975 | (string-match-p | 4975 | (setq item (pop choices) |
| 4976 | (or (eval (nth 0 item) t) "") | 4976 | proxy (eval (nth 2 item) t)) |
| 4977 | (or (tramp-file-name-host-port (car target-alist)) "")) | 4977 | (when (and |
| 4978 | ;; User. | 4978 | ;; Host. |
| 4979 | (string-match-p | 4979 | (string-match-p |
| 4980 | (or (eval (nth 1 item) t) "") | 4980 | (or (eval (nth 0 item) t) "") |
| 4981 | (or (tramp-file-name-user-domain (car target-alist)) ""))) | 4981 | (or (tramp-file-name-host-port (car target-alist)) "")) |
| 4982 | (if (null proxy) | 4982 | ;; User. |
| 4983 | ;; No more hops needed. | 4983 | (string-match-p |
| 4984 | (setq choices nil) | 4984 | (or (eval (nth 1 item) t) "") |
| 4985 | ;; Replace placeholders. The proxy could contain "%" which | 4985 | (or (tramp-file-name-user-domain (car target-alist)) ""))) |
| 4986 | ;; is not intended as format character, for example in | 4986 | (if (null proxy) |
| 4987 | ;; USER%DOMAIN or POD%NAMESPACE. | 4987 | ;; No more hops needed. |
| 4988 | (setq proxy | 4988 | (setq choices nil) |
| 4989 | (replace-regexp-in-string | 4989 | ;; Replace placeholders. |
| 4990 | (rx "%" (group (= 2 alnum))) "%%\\1" proxy) | 4990 | (setq proxy |
| 4991 | proxy | 4991 | (format-spec |
| 4992 | (format-spec | 4992 | proxy |
| 4993 | proxy | 4993 | (format-spec-make |
| 4994 | (format-spec-make | 4994 | ?u (or (tramp-file-name-user (car target-alist)) "") |
| 4995 | ?u (or (tramp-file-name-user (car target-alist)) "") | 4995 | ?h (or (tramp-file-name-host (car target-alist)) "")))) |
| 4996 | ?h (or (tramp-file-name-host (car target-alist)) "")))) | 4996 | (with-parsed-tramp-file-name proxy l |
| 4997 | (with-parsed-tramp-file-name proxy l | 4997 | ;; Add the hop. |
| 4998 | ;; Add the hop. | 4998 | (push l target-alist) |
| 4999 | (push l target-alist) | 4999 | ;; Start next search. |
| 5000 | ;; Start next search. | 5000 | (setq choices tramp-default-proxies-alist))))) |
| 5001 | (setq choices tramp-default-proxies-alist))))) | 5001 | |
| 5002 | 5002 | ;; Foreign and out-of-band methods are not supported for | |
| 5003 | ;; Foreign and out-of-band methods are not supported for multi-hops. | 5003 | ;; multi-hops. |
| 5004 | (when (cdr target-alist) | 5004 | (when (cdr target-alist) |
| 5005 | (setq choices target-alist) | 5005 | (setq choices target-alist) |
| 5006 | (while (setq item (pop choices)) | 5006 | (while (setq item (pop choices)) |
| 5007 | (unless (tramp-multi-hop-p item) | 5007 | (unless (tramp-multi-hop-p item) |
| 5008 | (setq tramp-default-proxies-alist saved-tdpa) | ||
| 5009 | (tramp-user-error | ||
| 5010 | vec "Method `%s' is not supported for multi-hops" | ||
| 5011 | (tramp-file-name-method item))))) | ||
| 5012 | |||
| 5013 | ;; Some methods ("su", "sg", "sudo", "doas", "run0", "ksu") do not | ||
| 5014 | ;; use the host name in their command template. In this case, the | ||
| 5015 | ;; remote file name must use either a local host name (first hop), | ||
| 5016 | ;; or a host name matching the previous hop. | ||
| 5017 | (let ((previous-host (or tramp-local-host-regexp ""))) | ||
| 5018 | (setq choices target-alist) | ||
| 5019 | (while (setq item (pop choices)) | ||
| 5020 | (let ((host (tramp-file-name-host item))) | ||
| 5021 | (unless | ||
| 5022 | (or | ||
| 5023 | ;; The host name is used for the remote shell command. | ||
| 5024 | (member | ||
| 5025 | "%h" (flatten-tree | ||
| 5026 | (tramp-get-method-parameter item 'tramp-login-args))) | ||
| 5027 | ;; The host name must match previous hop. | ||
| 5028 | (string-match-p previous-host host)) | ||
| 5029 | (setq tramp-default-proxies-alist saved-tdpa) | 5008 | (setq tramp-default-proxies-alist saved-tdpa) |
| 5030 | (tramp-user-error | 5009 | (tramp-user-error |
| 5031 | vec "Host name `%s' does not match `%s'" host previous-host)) | 5010 | vec "Method `%s' is not supported for multi-hops" |
| 5032 | (setq previous-host (rx bol (literal host) eol))))) | 5011 | (tramp-file-name-method item))))) |
| 5012 | |||
| 5013 | ;; Some methods ("su", "sg", "sudo", "doas", "run0", "ksu") do | ||
| 5014 | ;; not use the host name in their command template. In this | ||
| 5015 | ;; case, the remote file name must use either a local host name | ||
| 5016 | ;; (first hop), or a host name matching the previous hop. | ||
| 5017 | (let ((previous-host (or tramp-local-host-regexp ""))) | ||
| 5018 | (setq choices target-alist) | ||
| 5019 | (while (setq item (pop choices)) | ||
| 5020 | (let ((host (tramp-file-name-host item))) | ||
| 5021 | (unless | ||
| 5022 | (or | ||
| 5023 | ;; The host name is used for the remote shell command. | ||
| 5024 | (member | ||
| 5025 | "%h" (flatten-tree | ||
| 5026 | (tramp-get-method-parameter item 'tramp-login-args))) | ||
| 5027 | ;; The host name must match previous hop. | ||
| 5028 | (string-match-p previous-host host)) | ||
| 5029 | (setq tramp-default-proxies-alist saved-tdpa) | ||
| 5030 | (tramp-user-error | ||
| 5031 | vec "Host name `%s' does not match `%s'" host previous-host)) | ||
| 5032 | (setq previous-host (rx bol (literal host) eol)))))) | ||
| 5033 | 5033 | ||
| 5034 | ;; Result. | 5034 | ;; Result. |
| 5035 | target-alist)) | 5035 | target-alist)) |
| @@ -5694,7 +5694,11 @@ of." | |||
| 5694 | ;; Sometimes, the process returns a new password request | 5694 | ;; Sometimes, the process returns a new password request |
| 5695 | ;; immediately after rejecting the previous (wrong) one. | 5695 | ;; immediately after rejecting the previous (wrong) one. |
| 5696 | (unless (or tramp-password-prompt-not-unique | 5696 | (unless (or tramp-password-prompt-not-unique |
| 5697 | (tramp-get-connection-property vec " first-password-request")) | 5697 | (tramp-get-connection-property |
| 5698 | (tramp-get-connection-property | ||
| 5699 | proc "hop-vector" | ||
| 5700 | (process-get proc 'tramp-vector)) | ||
| 5701 | " first-password-request")) | ||
| 5698 | (tramp-clear-passwd vec)) | 5702 | (tramp-clear-passwd vec)) |
| 5699 | (goto-char (point-min)) | 5703 | (goto-char (point-min)) |
| 5700 | (tramp-check-for-regexp proc tramp-process-action-regexp) | 5704 | (tramp-check-for-regexp proc tramp-process-action-regexp) |
| @@ -5897,10 +5901,10 @@ because the shell prompt has been detected), it shall throw a | |||
| 5897 | result. The symbol `ok' means that all ACTIONs have been | 5901 | result. The symbol `ok' means that all ACTIONs have been |
| 5898 | performed successfully. Any other value means an error." | 5902 | performed successfully. Any other value means an error." |
| 5899 | ;; Enable `auth-source', unless "emacs -Q" has been called. We must | 5903 | ;; Enable `auth-source', unless "emacs -Q" has been called. We must |
| 5900 | ;; use the "password-vector" property in case we have several hops. | 5904 | ;; use the "hop-vector" property in case we have several hops. |
| 5901 | (tramp-set-connection-property | 5905 | (tramp-set-connection-property |
| 5902 | (tramp-get-connection-property | 5906 | (tramp-get-connection-property |
| 5903 | proc "password-vector" (process-get proc 'tramp-vector)) | 5907 | proc "hop-vector" (process-get proc 'tramp-vector)) |
| 5904 | " first-password-request" tramp-cache-read-persistent-data) | 5908 | " first-password-request" tramp-cache-read-persistent-data) |
| 5905 | (save-restriction | 5909 | (save-restriction |
| 5906 | (with-tramp-progress-reporter | 5910 | (with-tramp-progress-reporter |
| @@ -6843,15 +6847,16 @@ Consults the auth-source package." | |||
| 6843 | ;; adapt `default-directory'. (Bug#39389, Bug#39489) | 6847 | ;; adapt `default-directory'. (Bug#39389, Bug#39489) |
| 6844 | (default-directory tramp-compat-temporary-file-directory) | 6848 | (default-directory tramp-compat-temporary-file-directory) |
| 6845 | (case-fold-search t) | 6849 | (case-fold-search t) |
| 6846 | ;; In tramp-sh.el, we must use "password-vector" due to | 6850 | ;; In tramp-sh.el, we must use "hop-vector" and "pw-vector" |
| 6847 | ;; multi-hop. | 6851 | ;; due to multi-hop. |
| 6848 | (vec (tramp-get-connection-property | 6852 | (vec (process-get proc 'tramp-vector)) |
| 6849 | proc "password-vector" (process-get proc 'tramp-vector))) | 6853 | (hop-vec (tramp-get-connection-property proc "hop-vector" vec)) |
| 6850 | (key (tramp-make-tramp-file-name vec 'noloc)) | 6854 | (pw-vec (tramp-get-connection-property proc "pw-vector" hop-vec)) |
| 6851 | (method (tramp-file-name-method vec)) | 6855 | (key (tramp-make-tramp-file-name pw-vec 'noloc)) |
| 6852 | (user-domain (or (tramp-file-name-user-domain vec) | 6856 | (method (tramp-file-name-method pw-vec)) |
| 6853 | (tramp-get-connection-property key "login-as"))) | 6857 | (user-domain (or (tramp-file-name-user-domain pw-vec) |
| 6854 | (host-port (tramp-file-name-host-port vec)) | 6858 | (tramp-get-connection-property pw-vec "login-as"))) |
| 6859 | (host-port (tramp-file-name-host-port pw-vec)) | ||
| 6855 | (pw-prompt | 6860 | (pw-prompt |
| 6856 | (string-trim-left | 6861 | (string-trim-left |
| 6857 | (or prompt | 6862 | (or prompt |
| @@ -6860,29 +6865,23 @@ Consults the auth-source package." | |||
| 6860 | (if (string-match-p "passphrase" (match-string 1)) | 6865 | (if (string-match-p "passphrase" (match-string 1)) |
| 6861 | (match-string 0) | 6866 | (match-string 0) |
| 6862 | (format "%s for %s " (capitalize (match-string 1)) key)))))) | 6867 | (format "%s for %s " (capitalize (match-string 1)) key)))))) |
| 6868 | ;; If there is no user name, `:create' triggers to ask for. | ||
| 6869 | ;; We suppress it. | ||
| 6870 | (pw-spec (list :max 1 :user user-domain :host host-port :port method | ||
| 6871 | :require (cons :secret (and user-domain '(:user))) | ||
| 6872 | :create (and user-domain t))) | ||
| 6863 | (auth-source-creation-prompts `((secret . ,pw-prompt))) | 6873 | (auth-source-creation-prompts `((secret . ,pw-prompt))) |
| 6864 | ;; Use connection-local value. | 6874 | ;; Use connection-local value. |
| 6865 | (auth-sources (buffer-local-value 'auth-sources (process-buffer proc))) | 6875 | (auth-sources (buffer-local-value 'auth-sources (process-buffer proc))) |
| 6866 | auth-info auth-passwd tramp-dont-suspend-timers) | 6876 | auth-info auth-passwd tramp-dont-suspend-timers) |
| 6867 | 6877 | ||
| 6868 | (unwind-protect | 6878 | (unwind-protect |
| 6869 | ;; We cannot use `with-parsed-tramp-file-name', because it | ||
| 6870 | ;; expands the file name. | ||
| 6871 | (or | 6879 | (or |
| 6872 | (setq tramp-password-save-function nil) | 6880 | (setq tramp-password-save-function nil) |
| 6873 | ;; See if auth-sources contains something useful. | 6881 | ;; See if `auth-sources' contains something useful. |
| 6874 | (ignore-errors | 6882 | (ignore-errors |
| 6875 | (and auth-sources | 6883 | (and (tramp-get-connection-property hop-vec " first-password-request") |
| 6876 | (tramp-get-connection-property vec " first-password-request") | 6884 | (setq auth-info (car (apply #'auth-source-search pw-spec)) |
| 6877 | ;; Try with Tramp's current method. If there is no | ||
| 6878 | ;; user name, `:create' triggers to ask for. We | ||
| 6879 | ;; suppress it. | ||
| 6880 | (setq auth-info | ||
| 6881 | (car | ||
| 6882 | (auth-source-search | ||
| 6883 | :max 1 :user user-domain :host host-port :port method | ||
| 6884 | :require (cons :secret (and user-domain '(:user))) | ||
| 6885 | :create (and user-domain t))) | ||
| 6886 | tramp-password-save-function | 6885 | tramp-password-save-function |
| 6887 | (plist-get auth-info :save-function) | 6886 | (plist-get auth-info :save-function) |
| 6888 | auth-passwd | 6887 | auth-passwd |
| @@ -6890,12 +6889,19 @@ Consults the auth-source package." | |||
| 6890 | 6889 | ||
| 6891 | ;; Try the password cache. | 6890 | ;; Try the password cache. |
| 6892 | (with-tramp-suspended-timers | 6891 | (with-tramp-suspended-timers |
| 6893 | (setq auth-passwd (password-read pw-prompt key) | 6892 | (setq auth-passwd |
| 6893 | (password-read | ||
| 6894 | pw-prompt (auth-source-format-cache-entry pw-spec)) | ||
| 6894 | tramp-password-save-function | 6895 | tramp-password-save-function |
| 6895 | (lambda () (password-cache-add key auth-passwd))) | 6896 | (when auth-source-do-cache |
| 6897 | (lambda () | ||
| 6898 | (password-cache-add | ||
| 6899 | (auth-source-format-cache-entry pw-spec) auth-passwd)))) | ||
| 6896 | auth-passwd)) | 6900 | auth-passwd)) |
| 6897 | 6901 | ||
| 6898 | (tramp-set-connection-property vec " first-password-request" nil)))) | 6902 | ;; Remember the values. |
| 6903 | (tramp-set-connection-property hop-vec " pw-spec" pw-spec) | ||
| 6904 | (tramp-set-connection-property hop-vec " first-password-request" nil)))) | ||
| 6899 | 6905 | ||
| 6900 | (defun tramp-read-passwd-without-cache (proc &optional prompt) | 6906 | (defun tramp-read-passwd-without-cache (proc &optional prompt) |
| 6901 | "Read a password from user (compat function)." | 6907 | "Read a password from user (compat function)." |
| @@ -6912,17 +6918,11 @@ Consults the auth-source package." | |||
| 6912 | (defun tramp-clear-passwd (vec) | 6918 | (defun tramp-clear-passwd (vec) |
| 6913 | "Clear password cache for connection related to VEC." | 6919 | "Clear password cache for connection related to VEC." |
| 6914 | (declare (tramp-suppress-trace t)) | 6920 | (declare (tramp-suppress-trace t)) |
| 6915 | (let ((method (tramp-file-name-method vec)) | 6921 | (when-let* ((hop (cadr (reverse (tramp-compute-multi-hops vec))))) |
| 6916 | (user-domain (tramp-file-name-user-domain vec)) | 6922 | ;; Clear also the passwords of the hops. |
| 6917 | (host-port (tramp-file-name-host-port vec)) | 6923 | (tramp-clear-passwd hop)) |
| 6918 | (hop (tramp-file-name-hop vec))) | 6924 | (when-let* ((pw-spec (tramp-get-connection-property vec " pw-spec"))) |
| 6919 | (when hop | 6925 | (auth-source-forget pw-spec))) |
| 6920 | ;; Clear also the passwords of the hops. | ||
| 6921 | (tramp-clear-passwd (tramp-dissect-hop-name hop))) | ||
| 6922 | (auth-source-forget | ||
| 6923 | `(:max 1 ,(and user-domain :user) ,user-domain | ||
| 6924 | :host ,host-port :port ,method)) | ||
| 6925 | (password-cache-remove (tramp-make-tramp-file-name vec 'noloc)))) | ||
| 6926 | 6926 | ||
| 6927 | (defun tramp-time-diff (t1 t2) | 6927 | (defun tramp-time-diff (t1 t2) |
| 6928 | "Return the difference between the two times, in seconds. | 6928 | "Return the difference between the two times, in seconds. |