changeset 88028:2a4ab582b2a6

* net/tramp.el (tramp-compute-multi-hops): In case of su(do)? methods, the host name must be a local host.
author Michael Albinus <michael.albinus@gmx.de>
date Sun, 27 Jan 2008 16:20:05 +0000
parents 17a3cbebbd67
children 3611478abf21
files lisp/net/tramp.el
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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))