Commit 78fc2530 authored by Michael Albinus's avatar 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'.
parent bfff6445
2013-08-26 Michael Albinus <michael.albinus@gmx.de>
* 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 <tsdh@gnu.org> 2013-08-26 Tassilo Horn <tsdh@gnu.org>
* epa-hook.el (epa-file-encrypt-to): Quote `safe-local-variable' * epa-hook.el (epa-file-encrypt-to): Quote `safe-local-variable'
......
...@@ -2246,8 +2246,7 @@ same as `substitute-in-file-name'." ...@@ -2246,8 +2246,7 @@ same as `substitute-in-file-name'."
;; - Cygwin (substitute-in-file-name "C:\bin") => "/usr/bin" ;; - Cygwin (substitute-in-file-name "C:\bin") => "/usr/bin"
;; (substitute-in-file-name "C:\") => "/" ;; (substitute-in-file-name "C:\") => "/"
;; (substitute-in-file-name "C:\bi") => "/bi" ;; (substitute-in-file-name "C:\bi") => "/bi"
(let* ((non-essential t) (let* ((ustr (substitute-in-file-name qstr))
(ustr (substitute-in-file-name qstr))
(uprefix (substring ustr 0 upos)) (uprefix (substring ustr 0 upos))
qprefix) qprefix)
;; Main assumption: nothing after qpos should affect the text before upos, ;; Main assumption: nothing after qpos should affect the text before upos,
......
...@@ -1092,6 +1092,8 @@ FMT and ARGS are passed to `error'." ...@@ -1092,6 +1092,8 @@ FMT and ARGS are passed to `error'."
"Maybe open a connection VEC. "Maybe open a connection VEC.
Does not do anything if a connection is already open, but re-opens the Does not do anything if a connection is already open, but re-opens the
connection if a previous connection has died for some reason." connection if a previous connection has died for some reason."
(tramp-check-proper-host vec)
(let* ((buf (tramp-get-connection-buffer vec)) (let* ((buf (tramp-get-connection-buffer vec))
(p (get-buffer-process buf)) (p (get-buffer-process buf))
(host (tramp-file-name-host vec)) (host (tramp-file-name-host vec))
......
...@@ -521,6 +521,7 @@ EOL-TYPE can be one of `dos', `unix', or `mac'." ...@@ -521,6 +521,7 @@ EOL-TYPE can be one of `dos', `unix', or `mac'."
;; `user-error' has been added to Emacs 24.3. ;; `user-error' has been added to Emacs 24.3.
(defun tramp-compat-user-error (format &rest args) (defun tramp-compat-user-error (format &rest args)
"Signal a pilot error." "Signal a pilot error."
; (tramp-backtrace)
(apply (if (fboundp 'user-error) 'user-error 'error) format args)) (apply (if (fboundp 'user-error) 'user-error 'error) format args))
(add-hook 'tramp-unload-hook (add-hook 'tramp-unload-hook
......
...@@ -1469,6 +1469,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"." ...@@ -1469,6 +1469,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
"Maybe open a connection VEC. "Maybe open a connection VEC.
Does not do anything if a connection is already open, but re-opens the Does not do anything if a connection is already open, but re-opens the
connection if a previous connection has died for some reason." 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 ;; We set the file name, in case there are incoming D-Bus signals or
;; D-Bus errors. ;; D-Bus errors.
......
...@@ -4326,6 +4326,8 @@ Gateway hops are already opened." ...@@ -4326,6 +4326,8 @@ Gateway hops are already opened."
"Maybe open a connection VEC. "Maybe open a connection VEC.
Does not do anything if a connection is already open, but re-opens the Does not do anything if a connection is already open, but re-opens the
connection if a previous connection has died for some reason." connection if a previous connection has died for some reason."
(tramp-check-proper-host vec)
(catch 'uname-changed (catch 'uname-changed
(let ((p (tramp-get-connection-process vec)) (let ((p (tramp-get-connection-process vec))
(process-name (tramp-get-connection-property vec "process-name" nil)) (process-name (tramp-get-connection-property vec "process-name" nil))
......
...@@ -1564,6 +1564,8 @@ Does not do anything if a connection is already open, but re-opens the ...@@ -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. connection if a previous connection has died for some reason.
If ARGUMENT is non-nil, use it as argument for If ARGUMENT is non-nil, use it as argument for
`tramp-smb-winexe-program', and suppress any checks." `tramp-smb-winexe-program', and suppress any checks."
(tramp-check-proper-host vec)
(let* ((share (tramp-smb-get-share vec)) (let* ((share (tramp-smb-get-share vec))
(buf (tramp-get-connection-buffer vec)) (buf (tramp-get-connection-buffer vec))
(p (get-buffer-process buf))) (p (get-buffer-process buf)))
......
...@@ -1239,23 +1239,31 @@ their replacement." ...@@ -1239,23 +1239,31 @@ their replacement."
;; This works with the current set of `tramp-obsolete-methods'. ;; This works with the current set of `tramp-obsolete-methods'.
;; Must be improved, if their are more sophisticated replacements. ;; Must be improved, if their are more sophisticated replacements.
(setq result (substring result 0 -1))) (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) (defun tramp-find-user (method user host)
"Return the right user string to use. "Return the right user string to use.
This is USER, if non-nil. Otherwise, do a lookup in This is USER, if non-nil. Otherwise, do a lookup in
`tramp-default-user-alist'." `tramp-default-user-alist'."
(or user (let ((result
(let ((choices tramp-default-user-alist) (or user
luser item) (let ((choices tramp-default-user-alist)
(while choices luser item)
(setq item (pop choices)) (while choices
(when (and (string-match (or (nth 0 item) "") (or method "")) (setq item (pop choices))
(string-match (or (nth 1 item) "") (or host ""))) (when (and (string-match (or (nth 0 item) "") (or method ""))
(setq luser (nth 2 item)) (string-match (or (nth 1 item) "") (or host "")))
(setq choices nil))) (setq luser (nth 2 item))
luser) (setq choices nil)))
tramp-default-user)) 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) (defun tramp-find-host (method user host)
"Return the right host string to use. "Return the right host string to use.
...@@ -1272,6 +1280,18 @@ This is HOST, if non-nil. Otherwise, it is `tramp-default-host'." ...@@ -1272,6 +1280,18 @@ This is HOST, if non-nil. Otherwise, it is `tramp-default-host'."
lhost) lhost)
tramp-default-host)) 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) (defun tramp-dissect-file-name (name &optional nodefault)
"Return a `tramp-file-name' structure. "Return a `tramp-file-name' structure.
The structure consists of remote method, remote user, remote host The structure consists of remote method, remote user, remote host
...@@ -1290,12 +1310,7 @@ values." ...@@ -1290,12 +1310,7 @@ values."
(when (string-match tramp-prefix-ipv6-regexp host) (when (string-match tramp-prefix-ipv6-regexp host)
(setq host (replace-match "" nil t host))) (setq host (replace-match "" nil t host)))
(when (string-match tramp-postfix-ipv6-regexp host) (when (string-match tramp-postfix-ipv6-regexp host)
(setq host (replace-match "" nil t 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)))
(if nodefault (if nodefault
(vector method user host localname hop) (vector method user host localname hop)
(vector (vector
...@@ -1537,10 +1552,14 @@ applicable)." ...@@ -1537,10 +1552,14 @@ applicable)."
(concat (format "(%d) # " level) fmt-string) (concat (format "(%d) # " level) fmt-string)
arguments))))))) arguments)))))))
(defsubst tramp-backtrace (vec-or-proc) (defsubst tramp-backtrace (&optional vec-or-proc)
"Dump a backtrace into the debug buffer. "Dump a backtrace into the debug buffer.
This function is meant for debugging purposes." If VEC-OR-PROC is nil, the buffer *debug tramp* is used. This
(tramp-message vec-or-proc 10 "\n%s" (with-output-to-string (backtrace)))) 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) (defsubst tramp-error (vec-or-proc signal fmt-string &rest arguments)
"Emit an error. "Emit an error.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment