]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle port and domain in Tramp's password cache
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 12 Jun 2017 15:52:42 +0000 (17:52 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 12 Jun 2017 15:52:42 +0000 (17:52 +0200)
* 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
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp.el

index 4ca393256f60cab0fbac761e21a317a27841e2f6..38b63715b51f33e77d746c672dcf4b6c0e21c480 100644 (file)
@@ -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}
index 7aac7c66e3717d9fb6a6b39c6979923c581a8d30..859809c00a84e1c0f042f1aeb721b678ab371a39 100644 (file)
@@ -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))
 
index b2d70fe11ca318d79739a0788afb20fdc25b2a23..f66dc7a7e2208fa5dab733f0aeed66bb6d2e4e93 100644 (file)
@@ -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
index 9ac2fc6670ed5538cd76565ef1a2f89fcf911aa2..1aadd14fb4102751d8ab33f053784498b9591c3b 100644 (file)
@@ -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)
index 8758fb61e4aa79cb3ddc72a0dde0c861155df7e9..710aa38b589b690568cd9789342d3b4afee23f98 100644 (file)
@@ -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 ""))))