[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 7dfc835 1/2: Handle port and domain in Tramp's pass
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master 7dfc835 1/2: Handle port and domain in Tramp's password cache |
Date: |
Mon, 12 Jun 2017 11:55:23 -0400 (EDT) |
branch: master
commit 7dfc8353ce8e91fd4391abe7cb669dcb643f7b39
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
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.
---
doc/misc/tramp.texi | 10 ++++++++--
lisp/net/tramp-gvfs.el | 3 +++
lisp/net/tramp-sh.el | 12 ++++++++----
lisp/net/tramp-smb.el | 20 +++++++++++++++-----
lisp/net/tramp.el | 30 ++++++++++++++++++++++--------
5 files changed, 56 insertions(+), 19 deletions(-)
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 4ca3932..38b6371 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -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
address@hidden methods.
address@hidden 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.
address@hidden
+machine melancholia#4711 port davs login daniel%DOMAIN password geheim
address@hidden example
+
address@hidden auth-source-debug
+Set @code{auth-source-debug} to @code{t} to debug messages.
@anchor{Caching passwords}
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 7aac7c6..859809c 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 b2d70fe..f66dc7a 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 9ac2fc6..1aadd14 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 8758fb6..710aa38 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 ""))))