Commit 7dfc8353 authored by Michael Albinus's avatar Michael Albinus
Browse files

Handle port and domain in Tramp's password cache

* doc/misc/tramp.texi (Password handling): Explain port and
domain handling in authinfo.

* lisp/net/tramp.el (tramp-process-actions, tramp-clear-passwd):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handler-askpassword):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory)
(tramp-smb-handle-file-acl, tramp-smb-handle-set-file-acl)
(tramp-smb-maybe-open-connection): Handle also domain and port.
parent e6f47a9d
......@@ -1503,9 +1503,15 @@ machine melancholia port scp login daniel password geheim
The port can take any @value{tramp} method (@pxref{Inline methods},
@pxref{External methods}). Omitting port values matches all
@value{tramp} methods.
@value{tramp} methods. Domain and ports, as used in @value{tramp}
file name syntax, must be appended to the machine and login items:
Setting @code{auth-source-debug} to @code{t} to debug messages.
@example
machine melancholia#4711 port davs login daniel%DOMAIN password geheim
@end example
@vindex auth-source-debug
Set @code{auth-source-debug} to @code{t} to debug messages.
@anchor{Caching passwords}
......
......@@ -1299,9 +1299,12 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
(unless (tramp-get-connection-property l "first-password-request" nil)
(tramp-clear-passwd l))
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method l-method
tramp-current-user user
tramp-current-domain l-domain
tramp-current-host l-host
tramp-current-port l-port
password (tramp-read-passwd
(tramp-get-connection-process l) pw-prompt))
......
......@@ -2345,13 +2345,14 @@ The method used must be an out-of-band method."
(expand-file-name ".." tmpfile) 'recursive)
(delete-file tmpfile)))))
;; Set variables for computing the prompt for reading
;; password.
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method (tramp-file-name-method v)
tramp-current-user (or (tramp-file-name-user v)
(tramp-get-connection-property
v "login-as" nil))
tramp-current-host (tramp-file-name-host v))
tramp-current-domain (tramp-file-name-domain v)
tramp-current-host (tramp-file-name-host v)
tramp-current-port (tramp-file-name-port v))
;; Check which ones of source and target are Tramp files.
(setq source (funcall
......@@ -4719,6 +4720,7 @@ connection if a previous connection has died for some reason."
(let* ((hop (car target-alist))
(l-method (tramp-file-name-method hop))
(l-user (tramp-file-name-user hop))
(l-domain (tramp-file-name-domain hop))
(l-host (tramp-file-name-host hop))
(l-port (tramp-file-name-port hop))
(login-program
......@@ -4764,7 +4766,9 @@ connection if a previous connection has died for some reason."
;; reading password.
(setq tramp-current-method l-method
tramp-current-user l-user
tramp-current-host l-host)
tramp-current-domain l-domain
tramp-current-host l-host
tramp-current-port l-port)
;; Add login environment.
(when login-env
......
......@@ -439,9 +439,12 @@ pass to the OPERATION."
(if (not (file-directory-p newname))
(make-directory newname parents))
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method method
tramp-current-user user
tramp-current-host host)
tramp-current-domain domain
tramp-current-host host
tramp-current-port port)
(let* ((share (tramp-smb-get-share v))
(localname (file-name-as-directory
......@@ -729,10 +732,12 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(with-parsed-tramp-file-name filename nil
(with-tramp-file-property v localname "file-acl"
(when (executable-find tramp-smb-acl-program)
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method method
tramp-current-user user
tramp-current-host host)
tramp-current-domain domain
tramp-current-host host
tramp-current-port port)
(let* ((share (tramp-smb-get-share v))
(localname (replace-regexp-in-string
......@@ -1320,9 +1325,12 @@ target of the symlink differ."
(ignore-errors
(with-parsed-tramp-file-name filename nil
(when (and (stringp acl-string) (executable-find tramp-smb-acl-program))
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method method
tramp-current-user user
tramp-current-host host)
tramp-current-domain domain
tramp-current-host host
tramp-current-port port)
(tramp-set-file-property v localname "file-acl" 'undef)
(let* ((share (tramp-smb-get-share v))
......@@ -1876,7 +1884,9 @@ If ARGUMENT is non-nil, use it as argument for
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method tramp-smb-method
tramp-current-user user
tramp-current-host host)
tramp-current-domain domain
tramp-current-host host
tramp-current-port port)
(condition-case err
(let (tramp-message-show-message)
......
......@@ -3550,13 +3550,13 @@ The terminal type can be configured with `tramp-terminal-type'."
PROC and VEC indicate the remote connection to be used. POS, if
set, is the starting point of the region to be deleted in the
connection buffer."
;; Enable `auth-source'. We must use tramp-current-* variables in
;; Enable `auth-source'. We must use `tramp-current-*' variables in
;; case we have several hops.
(tramp-set-connection-property
(tramp-dissect-file-name
(tramp-make-tramp-file-name
tramp-current-method tramp-current-user tramp-current-domain
tramp-current-host tramp-current-port ""))
(make-tramp-file-name
:method tramp-current-method :user tramp-current-user
:domain tramp-current-domain :host tramp-current-host
:port tramp-current-port)
"first-password-request" t)
(save-restriction
(with-tramp-progress-reporter
......@@ -4233,8 +4233,19 @@ Invokes `password-read' if available, `read-passwd' else."
(auth-source-search
:max 1
(and tramp-current-user :user)
tramp-current-user
:host tramp-current-host
(if tramp-current-domain
(format
"%s%s%s"
tramp-current-user tramp-prefix-domain-format
tramp-current-domain)
tramp-current-user)
:host
(if tramp-current-port
(format
"%s%s%s"
tramp-current-host tramp-prefix-port-format
tramp-current-port)
tramp-current-host)
:port tramp-current-method
:require
(cons
......@@ -4260,8 +4271,10 @@ Invokes `password-read' if available, `read-passwd' else."
(let ((method (tramp-file-name-method vec))
(user (tramp-file-name-user vec))
(domain (tramp-file-name-domain vec))
(user-domain (tramp-file-name-user-domain vec))
(host (tramp-file-name-host vec))
(port (tramp-file-name-port vec))
(host-port (tramp-file-name-host-port vec))
(hop (tramp-file-name-hop vec)))
(when hop
;; Clear also the passwords of the hops.
......@@ -4273,7 +4286,8 @@ Invokes `password-read' if available, `read-passwd' else."
(concat tramp-postfix-hop-regexp "$")
(tramp-postfix-host-format) hop)))))
(auth-source-forget
`(:max 1 ,(and user :user) ,user :host ,host :port ,method))
`(:max 1 ,(and user-domain :user) ,user-domain
:host ,host-port :port ,method))
(password-cache-remove
(tramp-make-tramp-file-name method user domain host port ""))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment