diff options
| author | Michael Albinus | 2019-03-23 09:55:04 +0100 |
|---|---|---|
| committer | Michael Albinus | 2019-03-23 09:55:04 +0100 |
| commit | a3194e7b7654134a51bc066dbf91cf59c3ce393d (patch) | |
| tree | d8dba7e07759168304f85f031b63429c9ce06c39 | |
| parent | 86c3cd99bff27e35e25dec0ee3f0dc4536b171ea (diff) | |
| download | emacs-a3194e7b7654134a51bc066dbf91cf59c3ce393d.tar.gz emacs-a3194e7b7654134a51bc066dbf91cf59c3ce393d.zip | |
Fix Bug#34943
* lisp/files-x.el (cl-lib): Require when compiling.
(hack-connection-local-variables): Regard connection-local
variables as safe. (Bug#34943)
* lisp/shell.el (shell): Use `with-connection-local-variables' for
the whole code block. (Bug#34943)
* lisp/net/tramp-adb.el (tramp-connection-local-safe-shell-file-names):
Do not set values.
* lisp/net/tramp-integration.el
(tramp-connection-local-safe-shell-file-names): Remove.
(shell-file-name, shell-command-switch): Do not add safe-local-variable
property.
* lisp/net/tramp.el (tramp-handle-shell-command): Use proper
buffer name.
* test/lisp/net/tramp-tests.el (tramp-test34-explicit-shell-file-name):
Tag it :unstable.
| -rw-r--r-- | lisp/files-x.el | 8 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-integration.el | 11 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 8 | ||||
| -rw-r--r-- | lisp/shell.el | 46 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 5 |
6 files changed, 40 insertions, 39 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el index eedf630b71f..5353e54158e 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | ;;; Code: | 31 | ;;; Code: |
| 32 | 32 | ||
| 33 | (eval-when-compile (require 'subr-x)) ; for string-trim-right | 33 | (eval-when-compile (require 'subr-x)) ; for string-trim-right |
| 34 | (eval-when-compile (require 'cl-lib)) ; for cl-letf | ||
| 34 | 35 | ||
| 35 | 36 | ||
| 36 | ;;; Commands to add/delete file-local/directory-local variables. | 37 | ;;; Commands to add/delete file-local/directory-local variables. |
| @@ -686,8 +687,11 @@ This does nothing if `enable-connection-local-variables' is nil." | |||
| 686 | (dolist (variable (connection-local-get-profile-variables profile)) | 687 | (dolist (variable (connection-local-get-profile-variables profile)) |
| 687 | (unless (assq (car variable) connection-local-variables-alist) | 688 | (unless (assq (car variable) connection-local-variables-alist) |
| 688 | (push variable connection-local-variables-alist)))) | 689 | (push variable connection-local-variables-alist)))) |
| 689 | ;; Push them to `file-local-variables-alist'. | 690 | ;; Push them to `file-local-variables-alist'. Connection-local |
| 690 | (hack-local-variables-filter connection-local-variables-alist nil))) | 691 | ;; variables do not appear from external files. So we can regard |
| 692 | ;; them as safe. | ||
| 693 | (cl-letf (((symbol-function 'safe-local-variable-p) (lambda (_sym _val) t))) | ||
| 694 | (hack-local-variables-filter connection-local-variables-alist nil)))) | ||
| 691 | 695 | ||
| 692 | ;;;###autoload | 696 | ;;;###autoload |
| 693 | (defun hack-connection-local-variables-apply (criteria) | 697 | (defun hack-connection-local-variables-apply (criteria) |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 8eeaa8be415..68960426b68 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -1299,7 +1299,6 @@ connection if a previous connection has died for some reason." | |||
| 1299 | '((shell-file-name . "/system/bin/sh") | 1299 | '((shell-file-name . "/system/bin/sh") |
| 1300 | (shell-command-switch . "-c")) | 1300 | (shell-command-switch . "-c")) |
| 1301 | "Default connection-local variables for remote adb connections.") | 1301 | "Default connection-local variables for remote adb connections.") |
| 1302 | (add-to-list 'tramp-connection-local-safe-shell-file-names "/system/bin/sh") | ||
| 1303 | 1302 | ||
| 1304 | ;; `connection-local-set-profile-variables' and | 1303 | ;; `connection-local-set-profile-variables' and |
| 1305 | ;; `connection-local-set-profiles' exists since Emacs 26.1. | 1304 | ;; `connection-local-set-profiles' exists since Emacs 26.1. |
diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el index 946d7f8cbab..da168adce77 100644 --- a/lisp/net/tramp-integration.el +++ b/lisp/net/tramp-integration.el | |||
| @@ -173,21 +173,10 @@ NAME must be equal to `tramp-current-connection'." | |||
| 173 | 173 | ||
| 174 | ;;; Default connection-local variables for Tramp: | 174 | ;;; Default connection-local variables for Tramp: |
| 175 | 175 | ||
| 176 | ;;;###tramp-autoload | ||
| 177 | (defvar tramp-connection-local-safe-shell-file-names nil | ||
| 178 | "List of safe `shell-file-name' values for remote hosts.") | ||
| 179 | (add-to-list 'tramp-connection-local-safe-shell-file-names "/bin/sh") | ||
| 180 | |||
| 181 | (defconst tramp-connection-local-default-profile | 176 | (defconst tramp-connection-local-default-profile |
| 182 | '((shell-file-name . "/bin/sh") | 177 | '((shell-file-name . "/bin/sh") |
| 183 | (shell-command-switch . "-c")) | 178 | (shell-command-switch . "-c")) |
| 184 | "Default connection-local variables for remote connections.") | 179 | "Default connection-local variables for remote connections.") |
| 185 | (put 'shell-file-name 'safe-local-variable | ||
| 186 | (lambda (item) | ||
| 187 | (and (stringp item) | ||
| 188 | (member item tramp-connection-local-safe-shell-file-names)))) | ||
| 189 | (put 'shell-command-switch 'safe-local-variable | ||
| 190 | (lambda (item) (and (stringp item) (string-equal item "-c")))) | ||
| 191 | 180 | ||
| 192 | ;; `connection-local-set-profile-variables' and | 181 | ;; `connection-local-set-profile-variables' and |
| 193 | ;; `connection-local-set-profiles' exists since Emacs 26.1. | 182 | ;; `connection-local-set-profiles' exists since Emacs 26.1. |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 48c363a873a..1d7242ba8f9 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3641,7 +3641,7 @@ support symbolic links." | |||
| 3641 | (prog1 | 3641 | (prog1 |
| 3642 | ;; Run the process. | 3642 | ;; Run the process. |
| 3643 | (setq p (start-file-process-shell-command | 3643 | (setq p (start-file-process-shell-command |
| 3644 | "*Async Shell*" buffer command)) | 3644 | (buffer-name output-buffer) buffer command)) |
| 3645 | ;; Display output. | 3645 | ;; Display output. |
| 3646 | (with-current-buffer output-buffer | 3646 | (with-current-buffer output-buffer |
| 3647 | (display-buffer output-buffer '(nil (allow-no-window . t))) | 3647 | (display-buffer output-buffer '(nil (allow-no-window . t))) |
| @@ -4892,6 +4892,12 @@ Only works for Bourne-like shells." | |||
| 4892 | ;; and friends, for most of the handlers this is the major | 4892 | ;; and friends, for most of the handlers this is the major |
| 4893 | ;; difference between the different backends. Other handlers but | 4893 | ;; difference between the different backends. Other handlers but |
| 4894 | ;; *-process-file would profit from this as well. | 4894 | ;; *-process-file would profit from this as well. |
| 4895 | ;; | ||
| 4896 | ;; * Get rid of `shell-command'. In its primary implementation, it | ||
| 4897 | ;; uses `process-file-shell-command' and | ||
| 4898 | ;; `start-file-process-shell-command', which is sufficient due to | ||
| 4899 | ;; connection-local `shell-file-name'. | ||
| 4900 | |||
| 4895 | 4901 | ||
| 4896 | ;;; tramp.el ends here | 4902 | ;;; tramp.el ends here |
| 4897 | 4903 | ||
diff --git a/lisp/shell.el b/lisp/shell.el index 264981bd435..53570272111 100644 --- a/lisp/shell.el +++ b/lisp/shell.el | |||
| @@ -721,9 +721,9 @@ Otherwise, one argument `-i' is passed to the shell. | |||
| 721 | (current-buffer))) | 721 | (current-buffer))) |
| 722 | 722 | ||
| 723 | (with-current-buffer buffer | 723 | (with-current-buffer buffer |
| 724 | (when (file-remote-p default-directory) | 724 | (with-connection-local-variables |
| 725 | ;; On remote hosts, the local `shell-file-name' might be useless. | 725 | ;; On remote hosts, the local `shell-file-name' might be useless. |
| 726 | (with-connection-local-variables | 726 | (when (file-remote-p default-directory) |
| 727 | (if (and (called-interactively-p 'any) | 727 | (if (and (called-interactively-p 'any) |
| 728 | (null explicit-shell-file-name) | 728 | (null explicit-shell-file-name) |
| 729 | (null (getenv "ESHELL"))) | 729 | (null (getenv "ESHELL"))) |
| @@ -732,26 +732,26 @@ Otherwise, one argument `-i' is passed to the shell. | |||
| 732 | (expand-file-name | 732 | (expand-file-name |
| 733 | (read-file-name | 733 | (read-file-name |
| 734 | "Remote shell path: " default-directory shell-file-name | 734 | "Remote shell path: " default-directory shell-file-name |
| 735 | t shell-file-name)))))))) | 735 | t shell-file-name)))))) |
| 736 | 736 | ||
| 737 | ;; The buffer's window must be correctly set when we call comint | 737 | ;; The buffer's window must be correctly set when we call comint |
| 738 | ;; (so that comint sets the COLUMNS env var properly). | 738 | ;; (so that comint sets the COLUMNS env var properly). |
| 739 | (pop-to-buffer buffer) | 739 | (pop-to-buffer buffer) |
| 740 | ;; Rain or shine, BUFFER must be current by now. | 740 | ;; Rain or shine, BUFFER must be current by now. |
| 741 | (unless (comint-check-proc buffer) | 741 | (unless (comint-check-proc buffer) |
| 742 | (let* ((prog (or explicit-shell-file-name | 742 | (let* ((prog (or explicit-shell-file-name |
| 743 | (getenv "ESHELL") shell-file-name)) | 743 | (getenv "ESHELL") shell-file-name)) |
| 744 | (name (file-name-nondirectory prog)) | 744 | (name (file-name-nondirectory prog)) |
| 745 | (startfile (concat "~/.emacs_" name)) | 745 | (startfile (concat "~/.emacs_" name)) |
| 746 | (xargs-name (intern-soft (concat "explicit-" name "-args")))) | 746 | (xargs-name (intern-soft (concat "explicit-" name "-args")))) |
| 747 | (unless (file-exists-p startfile) | 747 | (unless (file-exists-p startfile) |
| 748 | (setq startfile (concat user-emacs-directory "init_" name ".sh"))) | 748 | (setq startfile (concat user-emacs-directory "init_" name ".sh"))) |
| 749 | (apply #'make-comint-in-buffer "shell" buffer prog | 749 | (apply #'make-comint-in-buffer "shell" buffer prog |
| 750 | (if (file-exists-p startfile) startfile) | 750 | (if (file-exists-p startfile) startfile) |
| 751 | (if (and xargs-name (boundp xargs-name)) | 751 | (if (and xargs-name (boundp xargs-name)) |
| 752 | (symbol-value xargs-name) | 752 | (symbol-value xargs-name) |
| 753 | '("-i"))) | 753 | '("-i"))) |
| 754 | (shell-mode))) | 754 | (shell-mode))))) |
| 755 | buffer) | 755 | buffer) |
| 756 | 756 | ||
| 757 | ;;; Directory tracking | 757 | ;;; Directory tracking |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 34b676ee324..7290eb23925 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -4350,7 +4350,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4350 | ;; The functions were introduced in Emacs 26.1. | 4350 | ;; The functions were introduced in Emacs 26.1. |
| 4351 | (ert-deftest tramp-test34-explicit-shell-file-name () | 4351 | (ert-deftest tramp-test34-explicit-shell-file-name () |
| 4352 | "Check that connection-local `explicit-shell-file-name' is set." | 4352 | "Check that connection-local `explicit-shell-file-name' is set." |
| 4353 | :tags '(:expensive-test) | 4353 | ;; The handling of connection-local variables has changed. Test |
| 4354 | ;; must be reworked. | ||
| 4355 | :tags '(:expensive-test :unstable) | ||
| 4354 | (skip-unless (tramp--test-enabled)) | 4356 | (skip-unless (tramp--test-enabled)) |
| 4355 | (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) | 4357 | (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) |
| 4356 | ;; Since Emacs 26.1. | 4358 | ;; Since Emacs 26.1. |
| @@ -5715,6 +5717,7 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 5715 | ;; * Fix `tramp-test29-start-file-process', | 5717 | ;; * Fix `tramp-test29-start-file-process', |
| 5716 | ;; `tramp-test30-make-process' and `tramp-test32-shell-command' for | 5718 | ;; `tramp-test30-make-process' and `tramp-test32-shell-command' for |
| 5717 | ;; `adb' (see comment in `tramp-adb-send-command'). | 5719 | ;; `adb' (see comment in `tramp-adb-send-command'). |
| 5720 | ;; * Rework `tramp-test34-explicit-shell-file-name'. | ||
| 5718 | ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. | 5721 | ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. |
| 5719 | 5722 | ||
| 5720 | (provide 'tramp-tests) | 5723 | (provide 'tramp-tests) |