From 78fc2530af6b5b36351542b5662ba5d9d5813d04 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 26 Aug 2013 15:17:22 +0200 Subject: [PATCH] * minibuffer.el: Revert change from 2013-08-20. * net/tramp.el (tramp-find-method, tramp-find-user): Mark result with text property `tramp-default', if appropriate. (tramp-check-proper-host): New defun. (tramp-dissect-file-name): Do not check hostname. Revert change of 2013-03-18. (tramp-backtrace): Make VEC-OR-PROC optional. * net/tramp-adb.el (tramp-adb-maybe-open-connection): * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): * net/tramp-sh.el (tramp-maybe-open-connection): * net/tramp-smb.el (tramp-smb-maybe-open-connection): Apply `tramp-check-proper-host'. --- lisp/ChangeLog | 17 +++++++++++ lisp/minibuffer.el | 3 +- lisp/net/tramp-adb.el | 2 ++ lisp/net/tramp-compat.el | 1 + lisp/net/tramp-gvfs.el | 1 + lisp/net/tramp-sh.el | 2 ++ lisp/net/tramp-smb.el | 2 ++ lisp/net/tramp.el | 61 ++++++++++++++++++++++++++-------------- 8 files changed, 66 insertions(+), 23 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 53fd1274937..31538258bb6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,20 @@ +2013-08-26 Michael Albinus + + * minibuffer.el: Revert change from 2013-08-20. + + * net/tramp.el (tramp-find-method, tramp-find-user): Mark result + with text property `tramp-default', if appropriate. + (tramp-check-proper-host): New defun. + (tramp-dissect-file-name): Do not check hostname. Revert change + of 2013-03-18. + (tramp-backtrace): Make VEC-OR-PROC optional. + + * net/tramp-adb.el (tramp-adb-maybe-open-connection): + * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection): + * net/tramp-sh.el (tramp-maybe-open-connection): + * net/tramp-smb.el (tramp-smb-maybe-open-connection): Apply + `tramp-check-proper-host'. + 2013-08-26 Tassilo Horn * epa-hook.el (epa-file-encrypt-to): Quote `safe-local-variable' diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 72cb6f7e894..e07d28a54d0 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2246,8 +2246,7 @@ same as `substitute-in-file-name'." ;; - Cygwin (substitute-in-file-name "C:\bin") => "/usr/bin" ;; (substitute-in-file-name "C:\") => "/" ;; (substitute-in-file-name "C:\bi") => "/bi" - (let* ((non-essential t) - (ustr (substitute-in-file-name qstr)) + (let* ((ustr (substitute-in-file-name qstr)) (uprefix (substring ustr 0 upos)) qprefix) ;; Main assumption: nothing after qpos should affect the text before upos, diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 8ddbe254380..ff6d0d10671 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -1092,6 +1092,8 @@ FMT and ARGS are passed to `error'." "Maybe open a connection VEC. Does not do anything if a connection is already open, but re-opens the connection if a previous connection has died for some reason." + (tramp-check-proper-host vec) + (let* ((buf (tramp-get-connection-buffer vec)) (p (get-buffer-process buf)) (host (tramp-file-name-host vec)) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 71703fe6ab1..f0905245dea 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -521,6 +521,7 @@ EOL-TYPE can be one of `dos', `unix', or `mac'." ;; `user-error' has been added to Emacs 24.3. (defun tramp-compat-user-error (format &rest args) "Signal a pilot error." +; (tramp-backtrace) (apply (if (fboundp 'user-error) 'user-error 'error) format args)) (add-hook 'tramp-unload-hook diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index f70074ba6e9..e26ffb26e84 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1469,6 +1469,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"." "Maybe open a connection VEC. Does not do anything if a connection is already open, but re-opens the connection if a previous connection has died for some reason." + (tramp-check-proper-host vec) ;; We set the file name, in case there are incoming D-Bus signals or ;; D-Bus errors. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index b76ac2fa11f..ac131765189 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -4326,6 +4326,8 @@ Gateway hops are already opened." "Maybe open a connection VEC. Does not do anything if a connection is already open, but re-opens the connection if a previous connection has died for some reason." + (tramp-check-proper-host vec) + (catch 'uname-changed (let ((p (tramp-get-connection-process vec)) (process-name (tramp-get-connection-property vec "process-name" nil)) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 39e87f994c2..569bfb9c874 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -1564,6 +1564,8 @@ Does not do anything if a connection is already open, but re-opens the connection if a previous connection has died for some reason. If ARGUMENT is non-nil, use it as argument for `tramp-smb-winexe-program', and suppress any checks." + (tramp-check-proper-host vec) + (let* ((share (tramp-smb-get-share vec)) (buf (tramp-get-connection-buffer vec)) (p (get-buffer-process buf))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index cd7d17b130c..5f473a496e2 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1239,23 +1239,31 @@ their replacement." ;; This works with the current set of `tramp-obsolete-methods'. ;; Must be improved, if their are more sophisticated replacements. (setq result (substring result 0 -1))) - result)) + ;; We must mark, whether a default value has been used. + (if (or method (null result)) + result + (propertize result 'tramp-default t)))) (defun tramp-find-user (method user host) "Return the right user string to use. This is USER, if non-nil. Otherwise, do a lookup in `tramp-default-user-alist'." - (or user - (let ((choices tramp-default-user-alist) - luser item) - (while choices - (setq item (pop choices)) - (when (and (string-match (or (nth 0 item) "") (or method "")) - (string-match (or (nth 1 item) "") (or host ""))) - (setq luser (nth 2 item)) - (setq choices nil))) - luser) - tramp-default-user)) + (let ((result + (or user + (let ((choices tramp-default-user-alist) + luser item) + (while choices + (setq item (pop choices)) + (when (and (string-match (or (nth 0 item) "") (or method "")) + (string-match (or (nth 1 item) "") (or host ""))) + (setq luser (nth 2 item)) + (setq choices nil))) + luser) + tramp-default-user))) + ;; We must mark, whether a default value has been used. + (if (or user (null result)) + result + (propertize result 'tramp-default t)))) (defun tramp-find-host (method user host) "Return the right host string to use. @@ -1272,6 +1280,18 @@ This is HOST, if non-nil. Otherwise, it is `tramp-default-host'." lhost) tramp-default-host)) +(defun tramp-check-proper-host (vec) + "Check host name of VEC." + (let ((method (tramp-file-name-method vec)) + (user (tramp-file-name-user vec)) + (host (tramp-file-name-host vec))) + (when (and (equal tramp-syntax 'ftp) host + (or (null method) (get-text-property 0 'tramp-default method)) + (or (null user) (get-text-property 0 'tramp-default user)) + (member host (mapcar 'car tramp-methods))) + (tramp-compat-user-error + "Host name must not match method `%s'" host)))) + (defun tramp-dissect-file-name (name &optional nodefault) "Return a `tramp-file-name' structure. The structure consists of remote method, remote user, remote host @@ -1290,12 +1310,7 @@ values." (when (string-match tramp-prefix-ipv6-regexp host) (setq host (replace-match "" nil t host))) (when (string-match tramp-postfix-ipv6-regexp host) - (setq host (replace-match "" nil t host))) - (when (and (equal tramp-syntax 'ftp) (null method) (null user) - (member host (mapcar 'car tramp-methods)) - (not (tramp-completion-mode-p))) - (tramp-compat-user-error - "Host name must not match method `%s'" host))) + (setq host (replace-match "" nil t host)))) (if nodefault (vector method user host localname hop) (vector @@ -1537,10 +1552,14 @@ applicable)." (concat (format "(%d) # " level) fmt-string) arguments))))))) -(defsubst tramp-backtrace (vec-or-proc) +(defsubst tramp-backtrace (&optional vec-or-proc) "Dump a backtrace into the debug buffer. -This function is meant for debugging purposes." - (tramp-message vec-or-proc 10 "\n%s" (with-output-to-string (backtrace)))) +If VEC-OR-PROC is nil, the buffer *debug tramp* is used. This +function is meant for debugging purposes." + (if vec-or-proc + (tramp-message vec-or-proc 10 "\n%s" (with-output-to-string (backtrace))) + (if (<= 10 tramp-verbose) + (with-output-to-temp-buffer "*debug tramp*" (backtrace))))) (defsubst tramp-error (vec-or-proc signal fmt-string &rest arguments) "Emit an error. -- 2.39.2