diff options
| author | Michael Albinus | 2017-09-19 18:12:35 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-09-19 18:12:35 +0200 |
| commit | 40fdbb01d0017e9e164a24aeb760056778975e65 (patch) | |
| tree | 8e28eb9ebb23aac8d7414052800b565cc38e93a0 | |
| parent | 1a01423b3c75bf08c255b3bd39f44d91e509a318 (diff) | |
| download | emacs-40fdbb01d0017e9e164a24aeb760056778975e65.tar.gz emacs-40fdbb01d0017e9e164a24aeb760056778975e65.zip | |
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.
| -rw-r--r-- | lisp/net/tramp-sh.el | 26 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 6 |
2 files changed, 12 insertions, 20 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 5f145d4fae1..a744a53ca42 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -613,7 +613,7 @@ use Cwd \"realpath\"; | |||
| 613 | 613 | ||
| 614 | sub myrealpath { | 614 | sub myrealpath { |
| 615 | my ($file) = @_; | 615 | my ($file) = @_; |
| 616 | return realpath($file) if -e $file; | 616 | return realpath($file) if (-e $file || -l $file); |
| 617 | } | 617 | } |
| 618 | 618 | ||
| 619 | sub recursive { | 619 | sub recursive { |
| @@ -1139,12 +1139,7 @@ component is used as the target of the symlink." | |||
| 1139 | (tramp-shell-quote-argument localname))) | 1139 | (tramp-shell-quote-argument localname))) |
| 1140 | (with-current-buffer (tramp-get-connection-buffer v) | 1140 | (with-current-buffer (tramp-get-connection-buffer v) |
| 1141 | (goto-char (point-min)) | 1141 | (goto-char (point-min)) |
| 1142 | (setq result (buffer-substring (point-min) (point-at-eol)))) | 1142 | (setq result (buffer-substring (point-min) (point-at-eol))))) |
| 1143 | (when (and (file-symlink-p filename) | ||
| 1144 | (string-equal result localname)) | ||
| 1145 | (tramp-error | ||
| 1146 | v 'file-error | ||
| 1147 | "Apparent cycle of symbolic links for %s" filename))) | ||
| 1148 | 1143 | ||
| 1149 | ;; Use Perl implementation. | 1144 | ;; Use Perl implementation. |
| 1150 | ((and (tramp-get-remote-perl v) | 1145 | ((and (tramp-get-remote-perl v) |
| @@ -1198,16 +1193,6 @@ component is used as the target of the symlink." | |||
| 1198 | (setq numchase (1+ numchase)) | 1193 | (setq numchase (1+ numchase)) |
| 1199 | (when (file-name-absolute-p symlink-target) | 1194 | (when (file-name-absolute-p symlink-target) |
| 1200 | (setq result nil)) | 1195 | (setq result nil)) |
| 1201 | ;; If the symlink was absolute, we'll get a | ||
| 1202 | ;; string like "/user@host:/some/target"; | ||
| 1203 | ;; extract the "/some/target" part from it. | ||
| 1204 | (when (tramp-tramp-file-p symlink-target) | ||
| 1205 | (unless (tramp-equal-remote filename symlink-target) | ||
| 1206 | (tramp-error | ||
| 1207 | v 'file-error | ||
| 1208 | "Symlink target `%s' on wrong host" | ||
| 1209 | symlink-target)) | ||
| 1210 | (setq symlink-target localname)) | ||
| 1211 | (setq steps | 1196 | (setq steps |
| 1212 | (append | 1197 | (append |
| 1213 | (split-string symlink-target "/" 'omit) steps))) | 1198 | (split-string symlink-target "/" 'omit) steps))) |
| @@ -1226,6 +1211,13 @@ component is used as the target of the symlink." | |||
| 1226 | "/")) | 1211 | "/")) |
| 1227 | (when (string= "" result) | 1212 | (when (string= "" result) |
| 1228 | (setq result "/"))))) | 1213 | (setq result "/"))))) |
| 1214 | |||
| 1215 | ;; Detect cycle. | ||
| 1216 | (when (and (file-symlink-p filename) | ||
| 1217 | (string-equal result localname)) | ||
| 1218 | (tramp-error | ||
| 1219 | v 'file-error | ||
| 1220 | "Apparent cycle of symbolic links for %s" filename)) | ||
| 1229 | ;; If the resulting localname looks remote, we must quote it | 1221 | ;; If the resulting localname looks remote, we must quote it |
| 1230 | ;; for security reasons. | 1222 | ;; for security reasons. |
| 1231 | (when (or quoted (file-remote-p result)) | 1223 | (when (or quoted (file-remote-p result)) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index abcd5282d3a..3573eeb7d49 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3169,7 +3169,7 @@ User is always nil." | |||
| 3169 | 3169 | ||
| 3170 | (defun tramp-handle-file-truename (filename) | 3170 | (defun tramp-handle-file-truename (filename) |
| 3171 | "Like `file-truename' for Tramp files." | 3171 | "Like `file-truename' for Tramp files." |
| 3172 | (let ((result filename) | 3172 | (let ((result (expand-file-name filename)) |
| 3173 | (numchase 0) | 3173 | (numchase 0) |
| 3174 | ;; Don't make the following value larger than | 3174 | ;; Don't make the following value larger than |
| 3175 | ;; necessary. People expect an error message in a | 3175 | ;; necessary. People expect an error message in a |
| @@ -3180,7 +3180,7 @@ User is always nil." | |||
| 3180 | symlink-target) | 3180 | symlink-target) |
| 3181 | (format | 3181 | (format |
| 3182 | "%s%s" | 3182 | "%s%s" |
| 3183 | (with-parsed-tramp-file-name (expand-file-name result) v1 | 3183 | (with-parsed-tramp-file-name result v1 |
| 3184 | (with-tramp-file-property v1 v1-localname "file-truename" | 3184 | (with-tramp-file-property v1 v1-localname "file-truename" |
| 3185 | (while (and (setq symlink-target (file-symlink-p result)) | 3185 | (while (and (setq symlink-target (file-symlink-p result)) |
| 3186 | (< numchase numchase-limit)) | 3186 | (< numchase numchase-limit)) |
| @@ -3850,7 +3850,7 @@ Erase echoed commands if exists." | |||
| 3850 | (min (+ (point-min) tramp-echo-mark-marker-length) | 3850 | (min (+ (point-min) tramp-echo-mark-marker-length) |
| 3851 | (point-max)))))) | 3851 | (point-max)))))) |
| 3852 | ;; No echo to be handled, now we can look for the regexp. | 3852 | ;; No echo to be handled, now we can look for the regexp. |
| 3853 | ;; Sometimes, lines are much to long, and we run into a "Stack | 3853 | ;; Sometimes, lines are much too long, and we run into a "Stack |
| 3854 | ;; overflow in regexp matcher". For example, //DIRED// lines of | 3854 | ;; overflow in regexp matcher". For example, //DIRED// lines of |
| 3855 | ;; directory listings with some thousand files. Therefore, we | 3855 | ;; directory listings with some thousand files. Therefore, we |
| 3856 | ;; look from the end. | 3856 | ;; look from the end. |