From: Michael Albinus Date: Sun, 27 Jan 2008 16:20:57 +0000 (+0000) Subject: * net/tramp.el (tramp-compute-multi-hops): In case of su(do)? X-Git-Tag: emacs-pretest-23.0.90~8368 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2991e49f20dc4a7af55cc94802f3c69c47679c76;p=emacs.git * net/tramp.el (tramp-compute-multi-hops): In case of su(do)? methods, the host name must be a local host. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 679784fbcd0..20478b7511c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-01-27 Michael Albinus + + * net/tramp.el (tramp-compute-multi-hops): In case of su(do)? + methods, the host name must be a local host. + 2008-01-27 Dan Nicolaescu * server.el (server-process-filter): Check for non-nil before diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 9fba537f006..b9e6a279644 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -6052,6 +6052,27 @@ Gateway hops are already opened." "Method `%s' is not supported for multi-hops." (tramp-file-name-method item))))) + ;; In case the host name is not used for the remote shell + ;; command, the user could be misguided by applying a random + ;; hostname. + (let* ((v (car target-alist)) + (method (tramp-file-name-method v)) + (host (tramp-file-name-host v))) + (unless + (or + ;; There are multi-hops. + (cdr target-alist) + ;; The host name is used for the remote shell command. + (member + '("%h") (tramp-get-method-parameter method 'tramp-login-args)) + ;; The host is local. We cannot use `tramp-local-host-p' + ;; here, because it opens a connection as well. + (string-match + (concat "^" (regexp-opt (list "localhost" (system-name)) t) "$") + host)) + (tramp-error + v 'file-error "Wrong hostname `%s' for method `%s'" host method))) + ;; Result. target-alist))