summaryrefslogtreecommitdiff
path: root/lisp/net/tramp.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net/tramp.el')
-rw-r--r--lisp/net/tramp.el82
1 files changed, 61 insertions, 21 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 3c6733e6dfa..a45e1a22ad5 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -326,24 +326,35 @@ This variable defaults to the value of `tramp-encoding-shell'."
(tramp-login-program "ssh")
(tramp-copy-program "scp")
(tramp-remote-sh "/bin/sh")
- (tramp-login-args ("-e" "none"))
- (tramp-copy-args nil)
+ (tramp-login-args ("-o" "ControlPath=%t.%%r@%%h:%%p"
+ "-o" "ControlMaster=yes"
+ "-e" "none"))
+ (tramp-copy-args ("-o" "ControlPath=%t.%%r@%%h:%%p"
+ "-o" "ControlMaster=auto"))
(tramp-copy-keep-date-arg "-p")
(tramp-password-end-of-line nil))
("scp1" (tramp-connection-function tramp-open-connection-rsh)
(tramp-login-program "ssh")
(tramp-copy-program "scp")
(tramp-remote-sh "/bin/sh")
- (tramp-login-args ("-1" "-e" "none"))
- (tramp-copy-args ("-1"))
+ (tramp-login-args ("-o" "ControlPath=%t.%%r@%%h:%%p"
+ "-o" "ControlMaster=yes"
+ "-1" "-e" "none"))
+ (tramp-copy-args ("-o" "ControlPath=%t.%%r@%%h:%%p"
+ "-o" "ControlMaster=auto"
+ "-1"))
(tramp-copy-keep-date-arg "-p")
(tramp-password-end-of-line nil))
("scp2" (tramp-connection-function tramp-open-connection-rsh)
(tramp-login-program "ssh")
(tramp-copy-program "scp")
(tramp-remote-sh "/bin/sh")
- (tramp-login-args ("-2" "-e" "none"))
- (tramp-copy-args ("-2"))
+ (tramp-login-args ("-o" "ControlPath=%t.%%r@%%h:%%p"
+ "-o" "ControlMaster=yes"
+ "-2" "-e" "none"))
+ (tramp-copy-args ("-o" "ControlPath=%t.%%r@%%h:%%p"
+ "-o" "ControlMaster=auto"
+ "-2"))
(tramp-copy-keep-date-arg "-p")
(tramp-password-end-of-line nil))
("scp1_old"
@@ -566,6 +577,7 @@ pair of the form (KEY VALUE). The following KEYs are defined:
If `tramp-connection-function' is `tramp-open-connection-su', then
\"%u\" in this list is replaced by the user name, and \"%%\" can
be used to obtain a literal percent character.
+ \"%t\" is replaced by the temporary file name for `scp'-like methods.
* `tramp-copy-program'
This specifies the name of the program to use for remotely copying
the file; this might be the absolute filename of rcp or the name of
@@ -673,8 +685,8 @@ various functions for details."
(defcustom tramp-default-method
(if (and (fboundp 'executable-find)
- (executable-find "plink"))
- "plink"
+ (executable-find "pscp"))
+ "pscp"
"scp")
"*Default method to use for transferring files.
See `tramp-methods' for possibilities.
@@ -943,6 +955,17 @@ be ignored safely."
:group 'tramp
:type 'regexp)
+(defcustom tramp-copy-failed-regexp
+ (concat "\\(.+: "
+ (regexp-opt '("Permission denied"
+ "not a regular file"
+ "is a directory"
+ "No such file or directory") t)
+ "\\)\\s-*")
+ "Regular expression matching copy problems in (s)cp operations."
+ :group 'tramp
+ :type 'regexp)
+
(defcustom tramp-process-alive-regexp
""
"Regular expression indicating a process has finished.
@@ -1340,6 +1363,7 @@ corresponding PATTERN matches, the ACTION function is called."
(defcustom tramp-actions-copy-out-of-band
'((tramp-password-prompt-regexp tramp-action-password)
(tramp-wrong-passwd-regexp tramp-action-permission-denied)
+ (tramp-copy-failed-regexp tramp-action-copy-failed)
(tramp-process-alive-regexp tramp-action-out-of-band))
"List of pattern/action pairs.
This list is used for copying/renaming with out-of-band methods.
@@ -3140,6 +3164,14 @@ be a local filename. The method used must be an out-of-band method."
v2-user v2-host
(tramp-shell-quote-argument v2-localname))))
+ ;; Handle ControlMaster/ControlPath
+ (setq copy-args
+ (mapcar
+ (lambda (x)
+ (format-spec
+ x `((?t . ,(format "/tmp/%s" tramp-temp-name-prefix)))))
+ copy-args))
+
;; Handle keep-date argument
(when keep-date
(if t1
@@ -3174,12 +3206,13 @@ be a local filename. The method used must be an out-of-band method."
(message "Transferring %s to %s..." filename newname)
;; Use rcp-like program for file transfer.
- (let ((p (apply 'start-process (buffer-name trampbuf) trampbuf
- copy-program copy-args)))
- (tramp-set-process-query-on-exit-flag p nil)
- (tramp-process-actions p multi-method method user host
- tramp-actions-copy-out-of-band))
- (kill-buffer trampbuf)
+ (unwind-protect
+ (let ((p (apply 'start-process (buffer-name trampbuf) trampbuf
+ copy-program copy-args)))
+ (tramp-set-process-query-on-exit-flag p nil)
+ (tramp-process-actions p multi-method method user host
+ tramp-actions-copy-out-of-band))
+ (kill-buffer trampbuf))
(message "Transferring %s to %s...done" filename newname)
;; Set the mode.
@@ -5353,6 +5386,11 @@ Returns nil if none was found, else the command is returned."
(kill-process p)
(throw 'tramp-action 'permission-denied))
+(defun tramp-action-copy-failed (p multi-method method user host)
+ "Signal copy failed."
+ (kill-process p)
+ (error "%s" (match-string 1)))
+
(defun tramp-action-yesno (p multi-method method user host)
"Ask the user for confirmation using `yes-or-no-p'.
Send \"yes\" to remote process on confirmation, abort otherwise.
@@ -5409,9 +5447,6 @@ The terminal type can be configured with `tramp-terminal-type'."
(tramp-message 10 "'set mode' error ignored.")
(tramp-message 9 "Process has finished.")
(throw 'tramp-action 'ok))
- (goto-char (point-min))
- (when (re-search-forward "^.cp.?: \\(.+: Permission denied.?\\)$" nil t)
- (error "Remote host: %s" (match-string 1)))
(tramp-message 9 "Process has died.")
(throw 'tramp-action 'process-died)))
(t nil)))
@@ -5476,6 +5511,7 @@ The terminal type can be configured with `tramp-terminal-type'."
(defun tramp-process-actions (p multi-method method user host actions)
"Perform actions until success."
+ (tramp-message 10 "%s" (mapconcat 'identity (process-command p) " "))
(let (exit)
(while (not exit)
(tramp-message 9 "Waiting for prompts from remote shell")
@@ -5646,10 +5682,14 @@ arguments, and xx will be used as the host name to connect to.
multi-method
(tramp-find-method multi-method method user host)
user host 'tramp-login-program))
- (login-args (tramp-get-method-parameter
- multi-method
- (tramp-find-method multi-method method user host)
- user host 'tramp-login-args))
+ (login-args (mapcar
+ (lambda (x)
+ (format-spec
+ x `((?t . ,(format "/tmp/%s" tramp-temp-name-prefix)))))
+ (tramp-get-method-parameter
+ multi-method
+ (tramp-find-method multi-method method user host)
+ user host 'tramp-login-args)))
(real-host host))
;; The following should be changed. We need a more general
;; mechanism to parse extra host args.