# HG changeset patch # User Michael Albinus # Date 1201450805 0 # Node ID 2a4ab582b2a6aa338457d58520e1291bc30ab5f7 # Parent 17a3cbebbd67b5ec75032e0fd1236aac611bd7cc * net/tramp.el (tramp-compute-multi-hops): In case of su(do)? methods, the host name must be a local host. diff -r 17a3cbebbd67 -r 2a4ab582b2a6 lisp/net/tramp.el --- a/lisp/net/tramp.el Sun Jan 27 16:17:08 2008 +0000 +++ b/lisp/net/tramp.el Sun Jan 27 16:20:05 2008 +0000 @@ -6052,6 +6052,27 @@ "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))