Commit 40fdbb01 authored by Michael Albinus's avatar Michael Albinus

Work on Tramp's file-truename

* lisp/net/tramp-sh.el (tramp-perl-file-truename):
Check also for symlinks.
(tramp-sh-handle-file-truename): Move check for a symlink
cycle to the end.  Do not blame symlinks which look like a
remote file name.

* lisp/net/tramp.el (tramp-handle-file-truename): Expand result.
parent 1a01423b
......@@ -613,7 +613,7 @@ use Cwd \"realpath\";
sub myrealpath {
my ($file) = @_;
return realpath($file) if -e $file;
return realpath($file) if (-e $file || -l $file);
}
sub recursive {
......@@ -1139,12 +1139,7 @@ component is used as the target of the symlink."
(tramp-shell-quote-argument localname)))
(with-current-buffer (tramp-get-connection-buffer v)
(goto-char (point-min))
(setq result (buffer-substring (point-min) (point-at-eol))))
(when (and (file-symlink-p filename)
(string-equal result localname))
(tramp-error
v 'file-error
"Apparent cycle of symbolic links for %s" filename)))
(setq result (buffer-substring (point-min) (point-at-eol)))))
;; Use Perl implementation.
((and (tramp-get-remote-perl v)
......@@ -1198,16 +1193,6 @@ component is used as the target of the symlink."
(setq numchase (1+ numchase))
(when (file-name-absolute-p symlink-target)
(setq result nil))
;; If the symlink was absolute, we'll get a
;; string like "/user@host:/some/target";
;; extract the "/some/target" part from it.
(when (tramp-tramp-file-p symlink-target)
(unless (tramp-equal-remote filename symlink-target)
(tramp-error
v 'file-error
"Symlink target `%s' on wrong host"
symlink-target))
(setq symlink-target localname))
(setq steps
(append
(split-string symlink-target "/" 'omit) steps)))
......@@ -1226,6 +1211,13 @@ component is used as the target of the symlink."
"/"))
(when (string= "" result)
(setq result "/")))))
;; Detect cycle.
(when (and (file-symlink-p filename)
(string-equal result localname))
(tramp-error
v 'file-error
"Apparent cycle of symbolic links for %s" filename))
;; If the resulting localname looks remote, we must quote it
;; for security reasons.
(when (or quoted (file-remote-p result))
......
......@@ -3169,7 +3169,7 @@ User is always nil."
(defun tramp-handle-file-truename (filename)
"Like `file-truename' for Tramp files."
(let ((result filename)
(let ((result (expand-file-name filename))
(numchase 0)
;; Don't make the following value larger than
;; necessary. People expect an error message in a
......@@ -3180,7 +3180,7 @@ User is always nil."
symlink-target)
(format
"%s%s"
(with-parsed-tramp-file-name (expand-file-name result) v1
(with-parsed-tramp-file-name result v1
(with-tramp-file-property v1 v1-localname "file-truename"
(while (and (setq symlink-target (file-symlink-p result))
(< numchase numchase-limit))
......@@ -3850,7 +3850,7 @@ Erase echoed commands if exists."
(min (+ (point-min) tramp-echo-mark-marker-length)
(point-max))))))
;; No echo to be handled, now we can look for the regexp.
;; Sometimes, lines are much to long, and we run into a "Stack
;; Sometimes, lines are much too long, and we run into a "Stack
;; overflow in regexp matcher". For example, //DIRED// lines of
;; directory listings with some thousand files. Therefore, we
;; look from the end.
......
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