aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2016-05-31 20:00:21 +0200
committerMichael Albinus2016-05-31 20:00:21 +0200
commit9878cf4d30589eed27ea609de3ebd9cb9c72d41f (patch)
treea8044f82ed81b1b72fff6727b958c6018caa0525
parent01030eed9395f5004e7d0721394697d1ca90cc2f (diff)
downloademacs-9878cf4d30589eed27ea609de3ebd9cb9c72d41f.tar.gz
emacs-9878cf4d30589eed27ea609de3ebd9cb9c72d41f.zip
Improve robustness for out-of-band copy in Tramp
* lisp/net/tramp-adb.el (tramp-adb-execute-adb-command) * lisp/net/tramp-cmds.el (tramp-append-tramp-buffers) * lisp/net/tramp-gvfs.el (tramp-gvfs-do-copy-or-rename-file): Cosmetic changes. * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band): Use local `default-directory'. Simplify command to send. Don't check return code, this was already done in `tramp-process-actions'. (tramp-get-inline-coding): Don't set `default-directory'. * lisp/net/tramp.el (tramp-action-out-of-band): Throw `out-of-band-failed'. (tramp-process-actions): Handle `out-of-band-failed'. (tramp-call-process, tramp-call-process-region): Use local `default-directory'.
-rw-r--r--lisp/net/tramp-adb.el2
-rw-r--r--lisp/net/tramp-cmds.el2
-rw-r--r--lisp/net/tramp-gvfs.el2
-rw-r--r--lisp/net/tramp-sh.el51
-rw-r--r--lisp/net/tramp.el12
5 files changed, 27 insertions, 42 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 1281dbbd72d..f77e44e79ce 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -1045,7 +1045,7 @@ E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\"
1045 "Returns nil on success error-output on failure." 1045 "Returns nil on success error-output on failure."
1046 (when (and (> (length (tramp-file-name-host vec)) 0) 1046 (when (and (> (length (tramp-file-name-host vec)) 0)
1047 ;; The -s switch is only available for ADB device commands. 1047 ;; The -s switch is only available for ADB device commands.
1048 (not (member (car args) (list "connect" "disconnect")))) 1048 (not (member (car args) '("connect" "disconnect"))))
1049 (setq args (append (list "-s" (tramp-adb-get-device vec)) args))) 1049 (setq args (append (list "-s" (tramp-adb-get-device vec)) args)))
1050 (with-temp-buffer 1050 (with-temp-buffer
1051 (prog1 1051 (prog1
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index 856011fc0ee..45f30042ad8 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -345,7 +345,7 @@ names. Passwords will never be included there.")
345Please note that you have set `tramp-verbose' to a value of at 345Please note that you have set `tramp-verbose' to a value of at
346least 6. Therefore, the contents of files might be included in 346least 6. Therefore, the contents of files might be included in
347the debug buffer(s).") 347the debug buffer(s).")
348 (add-text-properties start (point) (list 'face 'italic)))) 348 (add-text-properties start (point) '(face italic))))
349 349
350 (set-buffer-modified-p nil) 350 (set-buffer-modified-p nil)
351 (setq buffer-read-only t) 351 (setq buffer-read-only t)
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index ac390e5d5a6..0e874d6c586 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -680,7 +680,7 @@ file names."
680 'tramp-gvfs-send-command v gvfs-operation 680 'tramp-gvfs-send-command v gvfs-operation
681 (append 681 (append
682 (and (eq op 'copy) (or keep-date preserve-uid-gid) 682 (and (eq op 'copy) (or keep-date preserve-uid-gid)
683 (list "--preserve")) 683 '("--preserve"))
684 (list 684 (list
685 (tramp-gvfs-url-file-name filename) 685 (tramp-gvfs-url-file-name filename)
686 (tramp-gvfs-url-file-name newname)))) 686 (tramp-gvfs-url-file-name newname))))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index e9f78b7d1ce..19f687c3433 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2517,19 +2517,18 @@ The method used must be an out-of-band method."
2517 2517
2518 ;; Use an asynchronous process. By this, password can 2518 ;; Use an asynchronous process. By this, password can
2519 ;; be handled. We don't set a timeout, because the 2519 ;; be handled. We don't set a timeout, because the
2520 ;; copying of large files can last longer than 60 2520 ;; copying of large files can last longer than 60 secs.
2521 ;; secs. 2521 (let* ((command
2522 (let ((p (apply 'start-process-shell-command 2522 (mapconcat
2523 (tramp-get-connection-name v) 2523 'identity (append (list copy-program) copy-args)
2524 (tramp-get-connection-buffer v) 2524 " "))
2525 copy-program 2525 (p (let ((default-directory
2526 (append 2526 (tramp-compat-temporary-file-directory)))
2527 copy-args 2527 (start-process-shell-command
2528 (list "&&" "echo" "tramp_exit_status" "0" 2528 (tramp-get-connection-name v)
2529 "||" "echo" "tramp_exit_status" "1"))))) 2529 (tramp-get-connection-buffer v)
2530 (tramp-message 2530 command))))
2531 orig-vec 6 "%s" 2531 (tramp-message orig-vec 6 "%s" command)
2532 (mapconcat 'identity (process-command p) " "))
2533 (tramp-set-connection-property p "vector" orig-vec) 2532 (tramp-set-connection-property p "vector" orig-vec)
2534 (set-process-query-on-exit-flag p nil) 2533 (set-process-query-on-exit-flag p nil)
2535 2534
@@ -2537,23 +2536,7 @@ The method used must be an out-of-band method."
2537 ;; sending the password. 2536 ;; sending the password.
2538 (let ((tramp-local-end-of-line tramp-rsh-end-of-line)) 2537 (let ((tramp-local-end-of-line tramp-rsh-end-of-line))
2539 (tramp-process-actions 2538 (tramp-process-actions
2540 p v nil tramp-actions-copy-out-of-band)) 2539 p v nil tramp-actions-copy-out-of-band))))
2541
2542 ;; Check the return code.
2543 (goto-char (point-max))
2544 (unless
2545 (re-search-backward "tramp_exit_status [0-9]+" nil t)
2546 (tramp-error
2547 orig-vec 'file-error
2548 "Couldn't find exit status of `%s'"
2549 (mapconcat 'identity (process-command p) " ")))
2550 (skip-chars-forward "^ ")
2551 (unless (zerop (read (current-buffer)))
2552 (forward-line -1)
2553 (tramp-error
2554 orig-vec 'file-error
2555 "Error copying: `%s'"
2556 (buffer-substring (point-min) (point-at-eol))))))
2557 2540
2558 ;; Reset the transfer process properties. 2541 ;; Reset the transfer process properties.
2559 (tramp-set-connection-property v "process-name" nil) 2542 (tramp-set-connection-property v "process-name" nil)
@@ -5597,18 +5580,14 @@ function cell is returned to be applied on a buffer."
5597 `(lambda (beg end) 5580 `(lambda (beg end)
5598 (,coding beg end) 5581 (,coding beg end)
5599 (let ((coding-system-for-write 'binary) 5582 (let ((coding-system-for-write 'binary)
5600 (coding-system-for-read 'binary) 5583 (coding-system-for-read 'binary))
5601 (default-directory
5602 (tramp-compat-temporary-file-directory)))
5603 (apply 5584 (apply
5604 'tramp-call-process-region ,vec (point-min) (point-max) 5585 'tramp-call-process-region ,vec (point-min) (point-max)
5605 (car (split-string ,compress)) t t nil 5586 (car (split-string ,compress)) t t nil
5606 (cdr (split-string ,compress))))) 5587 (cdr (split-string ,compress)))))
5607 `(lambda (beg end) 5588 `(lambda (beg end)
5608 (let ((coding-system-for-write 'binary) 5589 (let ((coding-system-for-write 'binary)
5609 (coding-system-for-read 'binary) 5590 (coding-system-for-read 'binary))
5610 (default-directory
5611 (tramp-compat-temporary-file-directory)))
5612 (apply 5591 (apply
5613 'tramp-call-process-region ,vec beg end 5592 'tramp-call-process-region ,vec beg end
5614 (car (split-string ,compress)) t t nil 5593 (car (split-string ,compress)) t t nil
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index e3755533b9d..b02760bff80 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3445,7 +3445,7 @@ The terminal type can be configured with `tramp-terminal-type'."
3445 (tramp-message vec 3 "Process has finished.") 3445 (tramp-message vec 3 "Process has finished.")
3446 (throw 'tramp-action 'ok)) 3446 (throw 'tramp-action 'ok))
3447 (tramp-message vec 3 "Process has died.") 3447 (tramp-message vec 3 "Process has died.")
3448 (throw 'tramp-action 'process-died)))) 3448 (throw 'tramp-action 'out-of-band-failed))))
3449 (t nil))) 3449 (t nil)))
3450 3450
3451;;; Functions for processing the actions: 3451;;; Functions for processing the actions:
@@ -3506,6 +3506,10 @@ connection buffer."
3506 (tramp-get-connection-buffer vec) vec 'file-error 3506 (tramp-get-connection-buffer vec) vec 'file-error
3507 (cond 3507 (cond
3508 ((eq exit 'permission-denied) "Permission denied") 3508 ((eq exit 'permission-denied) "Permission denied")
3509 ((eq exit 'out-of-band-failed)
3510 (format-message
3511 "Copy failed, see buffer `%s' for details"
3512 (tramp-get-connection-buffer vec)))
3509 ((eq exit 'process-died) 3513 ((eq exit 'process-died)
3510 (substitute-command-keys 3514 (substitute-command-keys
3511 (concat 3515 (concat
@@ -4003,7 +4007,8 @@ ALIST is of the form ((FROM . TO) ...)."
4003It always returns a return code. The Lisp error raised when 4007It always returns a return code. The Lisp error raised when
4004PROGRAM is nil is trapped also, returning 1. Furthermore, traces 4008PROGRAM is nil is trapped also, returning 1. Furthermore, traces
4005are written with verbosity of 6." 4009are written with verbosity of 6."
4006 (let ((v (or vec 4010 (let ((default-directory (tramp-compat-temporary-file-directory))
4011 (v (or vec
4007 (vector tramp-current-method tramp-current-user 4012 (vector tramp-current-method tramp-current-user
4008 tramp-current-host nil nil))) 4013 tramp-current-host nil nil)))
4009 (destination (if (eq destination t) (current-buffer) destination)) 4014 (destination (if (eq destination t) (current-buffer) destination))
@@ -4033,7 +4038,8 @@ are written with verbosity of 6."
4033It always returns a return code. The Lisp error raised when 4038It always returns a return code. The Lisp error raised when
4034PROGRAM is nil is trapped also, returning 1. Furthermore, traces 4039PROGRAM is nil is trapped also, returning 1. Furthermore, traces
4035are written with verbosity of 6." 4040are written with verbosity of 6."
4036 (let ((v (or vec 4041 (let ((default-directory (tramp-compat-temporary-file-directory))
4042 (v (or vec
4037 (vector tramp-current-method tramp-current-user 4043 (vector tramp-current-method tramp-current-user
4038 tramp-current-host nil nil))) 4044 tramp-current-host nil nil)))
4039 (buffer (if (eq buffer t) (current-buffer) buffer)) 4045 (buffer (if (eq buffer t) (current-buffer) buffer))