From c773edcf56b39b2e74c9625f4547b8323a161375 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Wed, 17 Dec 2014 22:08:30 +0100 Subject: [PATCH] * net/tramp-gw.el (tramp-gw-open-connection): Suppress traces in wrong debug buffer. (tramp-gw-open-connection): Set process coding system 'binary. (tramp-gw-open-network-stream): Handle HTTP error 403. * net/tramp-sh.el (tramp-compute-multi-hops): Suppress traces in wrong debug buffer. (tramp-maybe-open-connection): Set connection property "gateway". * net/tramp.el (tramp-error-with-buffer): Call `message' properly. (tramp-accept-process-output): Use nil as argument for `accept-process-output', when there is a gateway prepended. --- lisp/ChangeLog | 15 +++++++++++++++ lisp/net/tramp-gw.el | 9 +++++++-- lisp/net/tramp-sh.el | 12 ++++++++---- lisp/net/tramp.el | 16 ++++++++++------ 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9e242ca99fa..a7fe33204d1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,18 @@ +2014-12-17 Michael Albinus + + * net/tramp.el (tramp-error-with-buffer): Call `message' properly. + (tramp-accept-process-output): Use nil as argument for + `accept-process-output', when there is a gateway prepended. + + * net/tramp-gw.el (tramp-gw-open-connection): Suppress traces in + wrong debug buffer. + (tramp-gw-open-connection): Set process coding system 'binary. + (tramp-gw-open-network-stream): Handle HTTP error 403. + + * net/tramp-sh.el (tramp-compute-multi-hops): Suppress traces in + wrong debug buffer. + (tramp-maybe-open-connection): Set connection property "gateway". + 2014-12-15 Stefan Monnier * subr.el (sit-for): Tweak docstring (bug#19381). diff --git a/lisp/net/tramp-gw.el b/lisp/net/tramp-gw.el index 0decd8847cc..e21aaf78914 100644 --- a/lisp/net/tramp-gw.el +++ b/lisp/net/tramp-gw.el @@ -195,11 +195,12 @@ instead of the host name declared in TARGET-VEC." (setq tramp-gw-gw-proc (funcall socks-function - (tramp-get-connection-name gw-vec) - (tramp-get-connection-buffer gw-vec) + (let ((tramp-verbose 0)) (tramp-get-connection-name gw-vec)) + (let ((tramp-verbose 0)) (tramp-get-connection-buffer gw-vec)) (tramp-file-name-real-host target-vec) (tramp-file-name-port target-vec))) (set-process-sentinel tramp-gw-gw-proc 'tramp-gw-gw-proc-sentinel) + (set-process-coding-system tramp-gw-gw-proc 'binary 'binary) (tramp-compat-set-process-query-on-exit-flag tramp-gw-gw-proc nil) (tramp-message vec 4 "Opened %s process `%s'" @@ -260,6 +261,10 @@ authentication is requested from proxy server, provide it." (200 (setq found t)) ;; We need basic authentication. (401 (setq authentication (tramp-gw-basic-authentication nil first))) + ;; Access forbidden. + (403 (tramp-error-with-buffer + (current-buffer) tramp-gw-vector 'file-error + "Connection to %s:%d forbidden." host service)) ;; Target host not found. (404 (tramp-error-with-buffer (current-buffer) tramp-gw-vector 'file-error diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index f94c5b5d47a..bb1a813b388 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -4470,7 +4470,8 @@ Gateway hops are already opened." ;; Therefore, we must remember the gateway vector. But we ;; cannot do it as connection property, because it shouldn't ;; be persistent. And we have no started process yet either. - (tramp-set-file-property (car target-alist) "" "gateway" hop))) + (let ((tramp-verbose 0)) + (tramp-set-file-property (car target-alist) "" "gateway" hop)))) ;; Foreign and out-of-band methods are not supported for multi-hops. (when (cdr target-alist) @@ -4646,7 +4647,8 @@ connection if a previous connection has died for some reason." l-method 'tramp-connection-timeout)) (gw-args (tramp-get-method-parameter l-method 'tramp-gw-args)) - (gw (tramp-get-file-property hop "" "gateway" nil)) + (gw (let ((tramp-verbose 0)) + (tramp-get-file-property hop "" "gateway" nil))) (g-method (and gw (tramp-file-name-method gw))) (g-user (and gw (tramp-file-name-user gw))) (g-host (and gw (tramp-file-name-real-host gw))) @@ -4674,8 +4676,10 @@ connection if a previous connection has died for some reason." (setq login-args (append async-args login-args))) ;; Add gateway arguments if necessary. - (when (and gw gw-args) - (setq login-args (append gw-args login-args))) + (when gw + (tramp-set-connection-property p "gateway" t) + (when gw-args + (setq login-args (append gw-args login-args)))) ;; Check for port number. Until now, there's no ;; need for handling like method, user, host. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index fc9950d4a69..140bf1874bf 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1610,7 +1610,7 @@ an input event arrives. The other arguments are passed to `tramp-error'." (let ((enable-recursive-minibuffers t)) ;; `tramp-error' does not show messages. So we must do it ;; ourselves. - (message fmt-string arguments) + (apply 'message fmt-string arguments) ;; Show buffer. (pop-to-buffer buf) (discard-input) @@ -3609,15 +3609,19 @@ connection buffer." This is needed in order to hide `last-coding-system-used', which is set for process communication also." (with-current-buffer (process-buffer proc) - (tramp-message proc 10 "%s %s" proc (process-status proc)) - (let (buffer-read-only last-coding-system-used) + ;; FIXME: If there is a gateway process, we need communication + ;; between several processes. Too complicate to implement, so we + ;; read output from all proceeses. + (let ((p (if (tramp-get-connection-property proc "gateway" nil) nil proc)) + buffer-read-only last-coding-system-used) ;; Under Windows XP, accept-process-output doesn't return ;; sometimes. So we add an additional timeout. (with-timeout ((or timeout 1)) (if (featurep 'xemacs) - (accept-process-output proc timeout timeout-msecs) - (accept-process-output proc timeout timeout-msecs (and proc t))))) - (tramp-message proc 10 "\n%s" (buffer-string)))) + (accept-process-output p timeout timeout-msecs) + (accept-process-output p timeout timeout-msecs (and proc t)))) + (tramp-message proc 10 "%s %s %s\n%s" + proc (process-status proc) p (buffer-string))))) (defun tramp-check-for-regexp (proc regexp) "Check, whether REGEXP is contained in process buffer of PROC. -- 2.39.2