diff options
| author | Michael Albinus | 2017-08-30 12:00:26 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-08-30 12:00:26 +0200 |
| commit | 9376ea3f6c736f62cc064088b2e020a9f89bae63 (patch) | |
| tree | 0170a37cd464d0ec513c4a173bd9fd1e425646e0 /lisp/net | |
| parent | 9ef61c17af49886d150b938f51040ff3a1da1c80 (diff) | |
| download | emacs-9376ea3f6c736f62cc064088b2e020a9f89bae63.tar.gz emacs-9376ea3f6c736f62cc064088b2e020a9f89bae63.zip | |
Improve symlinks for Tramp
* lisp/files.el (files--splice-dirname-file): Quote whole file.
* lisp/net/tramp-sh.el (tramp-sh-handle-make-symbolic-link):
Do not expand TARGET, it could be remote.
(tramp-sh-handle-file-truename): Check for cyclic symlink also
in case of readlink. Quote result if it looks remote.
(tramp-sh-handle-file-local-copy): Use `file-truename'.
* test/lisp/net/tramp-tests.el (tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents): Test also file missing.
(tramp-test21-file-links): Extend test.
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/tramp-sh.el | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 6494b0957bf..85966f122d2 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -1086,7 +1086,7 @@ component is used as the target of the symlink." | |||
| 1086 | ;; If TARGET is a Tramp name, use just the localname component. | 1086 | ;; If TARGET is a Tramp name, use just the localname component. |
| 1087 | (when (and (tramp-tramp-file-p target) | 1087 | (when (and (tramp-tramp-file-p target) |
| 1088 | (tramp-file-name-equal-p | 1088 | (tramp-file-name-equal-p |
| 1089 | v (tramp-dissect-file-name (expand-file-name target)))) | 1089 | v (tramp-dissect-file-name target))) |
| 1090 | (setq target | 1090 | (setq target |
| 1091 | (tramp-file-name-localname | 1091 | (tramp-file-name-localname |
| 1092 | (tramp-dissect-file-name (expand-file-name target))))) | 1092 | (tramp-dissect-file-name (expand-file-name target))))) |
| @@ -1132,7 +1132,12 @@ component is used as the target of the symlink." | |||
| 1132 | (tramp-shell-quote-argument localname))) | 1132 | (tramp-shell-quote-argument localname))) |
| 1133 | (with-current-buffer (tramp-get-connection-buffer v) | 1133 | (with-current-buffer (tramp-get-connection-buffer v) |
| 1134 | (goto-char (point-min)) | 1134 | (goto-char (point-min)) |
| 1135 | (setq result (buffer-substring (point-min) (point-at-eol))))) | 1135 | (setq result (buffer-substring (point-min) (point-at-eol)))) |
| 1136 | (when (and (file-symlink-p filename) | ||
| 1137 | (string-equal result localname)) | ||
| 1138 | (tramp-error | ||
| 1139 | v 'file-error | ||
| 1140 | "Apparent cycle of symbolic links for %s" filename))) | ||
| 1136 | 1141 | ||
| 1137 | ;; Use Perl implementation. | 1142 | ;; Use Perl implementation. |
| 1138 | ((and (tramp-get-remote-perl v) | 1143 | ((and (tramp-get-remote-perl v) |
| @@ -1214,8 +1219,11 @@ component is used as the target of the symlink." | |||
| 1214 | "/")) | 1219 | "/")) |
| 1215 | (when (string= "" result) | 1220 | (when (string= "" result) |
| 1216 | (setq result "/"))))) | 1221 | (setq result "/"))))) |
| 1217 | 1222 | ;; If the resulting localname looks remote, we must quote it | |
| 1218 | (when quoted (setq result (tramp-compat-file-name-quote result))) | 1223 | ;; for security reasons. |
| 1224 | (when (or quoted (file-remote-p result)) | ||
| 1225 | (let (file-name-handler-alist) | ||
| 1226 | (setq result (tramp-compat-file-name-quote result)))) | ||
| 1219 | (tramp-message v 4 "True name of `%s' is `%s'" localname result) | 1227 | (tramp-message v 4 "True name of `%s' is `%s'" localname result) |
| 1220 | result)))) | 1228 | result)))) |
| 1221 | 1229 | ||
| @@ -3072,7 +3080,7 @@ the result will be a local, non-Tramp, file name." | |||
| 3072 | (defun tramp-sh-handle-file-local-copy (filename) | 3080 | (defun tramp-sh-handle-file-local-copy (filename) |
| 3073 | "Like `file-local-copy' for Tramp files." | 3081 | "Like `file-local-copy' for Tramp files." |
| 3074 | (with-parsed-tramp-file-name filename nil | 3082 | (with-parsed-tramp-file-name filename nil |
| 3075 | (unless (file-exists-p filename) | 3083 | (unless (file-exists-p (file-truename filename)) |
| 3076 | (tramp-error | 3084 | (tramp-error |
| 3077 | v tramp-file-missing | 3085 | v tramp-file-missing |
| 3078 | "Cannot make local copy of non-existing file `%s'" filename)) | 3086 | "Cannot make local copy of non-existing file `%s'" filename)) |