aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2018-12-20 11:07:15 +0100
committerMichael Albinus2018-12-20 11:07:15 +0100
commit88d3713beb8310eb1ab45dde8aa767f14489affe (patch)
tree1226549f5e63d7d95b2ebf677519c64e5cc12d02 /lisp
parent7ca9bb7849c47f061f1e887fe1c2de9960654648 (diff)
downloademacs-88d3713beb8310eb1ab45dde8aa767f14489affe.tar.gz
emacs-88d3713beb8310eb1ab45dde8aa767f14489affe.zip
Fix Bug#33781
* lisp/net/tramp-sh.el (tramp-set-remote-path): Use a temporary file for setting $PATH, if it exceeds PATH_MAX on the remote system. (tramp-send-command-and-read): Ignore errors if NOERROR. (Bug#33781) * test/lisp/net/tramp-tests.el (tramp-test34-remote-path): New test.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/tramp-sh.el25
1 files changed, 12 insertions, 13 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 14ae2cb51b4..2959422a5da 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3885,22 +3885,21 @@ This function expects to be in the right *tramp* buffer."
3885I.e., for each directory in `tramp-remote-path', it is tested 3885I.e., for each directory in `tramp-remote-path', it is tested
3886whether it exists and if so, it is added to the environment 3886whether it exists and if so, it is added to the environment
3887variable PATH." 3887variable PATH."
3888 (let ((path (mapconcat 'identity (tramp-get-remote-path vec) ":")) 3888 (let ((command
3889 (format "PATH=%s; export PATH"
3890 (mapconcat 'identity (tramp-get-remote-path vec) ":")))
3889 (path-max 3891 (path-max
3890 (with-tramp-connection-property vec "path-max" 3892 (with-tramp-connection-property vec "path-max"
3891 (tramp-send-command-and-read vec "getconf PATH_MAX /"))) 3893 (tramp-send-command-and-read vec "getconf PATH_MAX /")))
3892 index) 3894 tmpfile)
3893 (tramp-message vec 5 "Setting $PATH environment variable") 3895 (tramp-message vec 5 "Setting $PATH environment variable")
3894 (unless (< (length path) path-max) 3896 (if (< (length command) path-max)
3895 (setq index path-max) 3897 (tramp-send-command vec command)
3896 (while (not (string-equal (substring path (1- index) index) ":")) 3898 ;; Use a temporary file.
3897 (setq index (1- index))) 3899 (setq tmpfile (tramp-make-tramp-temp-file vec))
3898 ;; FIXME: Is this sufficient? Or shall we raise an error? 3900 (write-region command nil tmpfile)
3899 (tramp-message 3901 (tramp-send-command vec (format ". %s" tmpfile))
3900 vec 2 "$PATH environment variable is too long. Ignoring \"%s\"" 3902 (delete-file tmpfile))))
3901 (substring path index))
3902 (setq path (substring path 0 (1- index))))
3903 (tramp-send-command vec (format "PATH=%s; export PATH" path))))
3904 3903
3905;; ------------------------------------------------------------ 3904;; ------------------------------------------------------------
3906;; -- Communication with external shell -- 3905;; -- Communication with external shell --
@@ -5066,7 +5065,7 @@ If MARKER is a regexp, read the output after that string.
5066In case there is no valid Lisp expression and NOERROR is nil, it 5065In case there is no valid Lisp expression and NOERROR is nil, it
5067raises an error." 5066raises an error."
5068 (when (if noerror 5067 (when (if noerror
5069 (tramp-send-command-and-check vec command) 5068 (ignore-errors (tramp-send-command-and-check vec command))
5070 (tramp-barf-unless-okay 5069 (tramp-barf-unless-okay
5071 vec command "`%s' returns with error" command)) 5070 vec command "`%s' returns with error" command))
5072 (with-current-buffer (tramp-get-connection-buffer vec) 5071 (with-current-buffer (tramp-get-connection-buffer vec)