summaryrefslogtreecommitdiff
path: root/lisp/net
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2017-06-12 17:52:42 +0200
committerMichael Albinus <michael.albinus@gmx.de>2017-06-12 17:52:42 +0200
commit7dfc8353ce8e91fd4391abe7cb669dcb643f7b39 (patch)
treedd3e17c16be37c5908e3af629a9081e139e5507c /lisp/net
parente6f47a9d6c5dcb1b7be3830381085412da9b10e6 (diff)
downloademacs-7dfc8353ce8e91fd4391abe7cb669dcb643f7b39.tar.gz
emacs-7dfc8353ce8e91fd4391abe7cb669dcb643f7b39.tar.bz2
emacs-7dfc8353ce8e91fd4391abe7cb669dcb643f7b39.zip
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.
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/tramp-gvfs.el3
-rw-r--r--lisp/net/tramp-sh.el12
-rw-r--r--lisp/net/tramp-smb.el20
-rw-r--r--lisp/net/tramp.el30
4 files changed, 48 insertions, 17 deletions
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 7aac7c66e37..859809c00a8 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -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))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index b2d70fe11ca..f66dc7a7e22 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -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
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 9ac2fc6670e..1aadd14fb41 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -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)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 8758fb61e4a..710aa38b589 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -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 ""))))