From 1728de5a77660dcde6b779b200e39fa96c214e28 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 22 Jun 2024 19:49:45 +0200 Subject: Backport: Tramp: Fix bug#71709, and other minor changes * lisp/net/tramp-message.el (tramp-backtrace): Print also in batch mode. * lisp/net/tramp.el (tramp-skeleton-file-exists-p): Check for property only. (tramp-skeleton-make-process): Don't set `default-directory'. (tramp-handle-make-process): Set it. (Bug#71709) (cherry picked from commit 8456cb9b698dfbfc90af82b3ebcd739fc22be4e4) --- lisp/net/tramp-cmds.el | 2 +- lisp/net/tramp-compat.el | 5 +++-- lisp/net/tramp-message.el | 4 +++- lisp/net/tramp.el | 9 +++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index 6cd856c10e5..ecb9071eb57 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -585,7 +585,7 @@ An alternative method could be chosen with `tramp-file-name-with-method'." (tramp-make-tramp-file-name (make-tramp-file-name :method tramp-file-name-with-method :localname localname))) - ;; Remote file with multi-hop capable method.. + ;; Remote file with multi-hop capable method. ((tramp-multi-hop-p v) (tramp-make-tramp-file-name (make-tramp-file-name diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index a324c4fa826..1d6f47dc364 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -252,8 +252,9 @@ Also see `ignore'." (tramp-error vec tramp-permission-denied file) (tramp-error vec tramp-permission-denied "Permission denied: %s" file))) -;; Function `auth-info-password' is new in Emacs 29.1. However, it -;; doesn't obey cascaded functions, which is fixed in Emacs 30.1 only. +;; Function `auth-info-password' is new in Emacs 29.1. Finally, +;; Bug#49289 is fixed in Emacs 30.1 for the `secrets' and `plstore' +;; auth-sources backends. (defalias 'tramp-compat-auth-info-password (if (>= emacs-major-version 30) 'auth-info-password diff --git a/lisp/net/tramp-message.el b/lisp/net/tramp-message.el index 685b14d14db..8d6458ce07a 100644 --- a/lisp/net/tramp-message.el +++ b/lisp/net/tramp-message.el @@ -357,7 +357,9 @@ This function is meant for debugging purposes." (let ((tramp-verbose (if force 10 tramp-verbose))) (when (>= tramp-verbose 10) (tramp-message - vec-or-proc 10 "\n%s" (with-output-to-string (backtrace)))))) + ;; In batch-mode, we want to see it on stderr. + vec-or-proc (if (and force noninteractive) 1 10) + "\n%s" (with-output-to-string (backtrace)))))) (defsubst tramp-error (vec-or-proc signal fmt-string &rest arguments) "Emit an error. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index d9db17ea598..f97ed66c58b 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3477,7 +3477,7 @@ BODY is the backend specific code." (with-tramp-file-property v localname "file-exists-p" ;; Examine `file-attributes' cache to see if request can ;; be satisfied without remote operation. - (if (tramp-use-file-attributes v) + (if (tramp-file-property-p v localname "file-attributes") (not (null (tramp-get-file-property v localname "file-attributes"))) ,@body)))))) @@ -3594,8 +3594,7 @@ that a stederr file is supported. BODY is the backend specific code." (not (tramp-equal-remote default-directory stderr))) (signal 'file-error (list "Wrong stderr" stderr))) - (let ((default-directory tramp-compat-temporary-file-directory) - (name (tramp-get-unique-process-name name)) + (let ((name (tramp-get-unique-process-name name)) (buffer (if buffer (get-buffer-create buffer) @@ -5058,7 +5057,8 @@ should be set connection-local.") ;; Check for `tramp-sh-file-name-handler' and ;; `adb-file-name-handler-p', because something is different ;; between tramp-sh.el, and tramp-adb.el or tramp-sshfs.el. - (let* ((sh-file-name-handler-p (tramp-sh-file-name-handler-p v)) + (let* ((default-directory tramp-compat-temporary-file-directory) + (sh-file-name-handler-p (tramp-sh-file-name-handler-p v)) (adb-file-name-handler-p (tramp-adb-file-name-p v)) (env (mapcar (lambda (elt) @@ -5896,6 +5896,7 @@ Mostly useful to protect BODY from being interrupted by timers." ;; Be kind for old versions of Emacs. (if (member 'remote-file-error debug-ignored-errors) (throw 'non-essential 'non-essential) + ;(tramp-backtrace ,proc 'force) (tramp-error ,proc 'remote-file-error "Forbidden reentrant call of Tramp")) (with-tramp-suspended-timers -- cgit v1.2.1 From d9bd1718f9a3561f7aa233f105f78aaa7f8dc93a Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 22 Jun 2024 19:52:06 +0200 Subject: Backport: Minor changes in tramp-tests.el * test/lisp/net/tramp-tests.el (tramp--test-shell-file-name): Use connection-local value. (tramp--test-shell-command-switch): New defun. (tramp-test28-process-file) (tramp-test34-explicit-shell-file-name): Use it. (tramp--test-supports-processes-p): Simplify. (tramp--test-check-files): Use `tramp-compat-seq-keep'. (tramp-test45-asynchronous-requests): Don't let-bind `shell-file-name'. (tramp-test45-asynchronous-requests): Adjust timer. (tramp-test45-asynchronous-requests): Add another test message. (cherry picked from commit c95caade15d295fa6cc31d337028faa15142b388) --- test/lisp/net/tramp-tests.el | 56 ++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 516ba53c0f3..08a3dd179e2 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -5066,10 +5066,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (defun tramp--test-shell-file-name () "Return default remote shell." - (if (file-exists-p - (concat - (file-remote-p ert-remote-temporary-file-directory) "/system/bin/sh")) - "/system/bin/sh" "/bin/sh")) + (let ((default-directory ert-remote-temporary-file-directory)) + (tramp-compat-connection-local-value shell-file-name))) + +(defun tramp--test-shell-command-switch () + "Return default remote shell command switch." + (let ((default-directory ert-remote-temporary-file-directory)) + (tramp-compat-connection-local-value shell-command-switch))) (ert-deftest tramp-test28-process-file () "Check `process-file'." @@ -5086,14 +5089,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (unwind-protect (progn ;; We cannot use "/bin/true" and "/bin/false"; those paths - ;; do not exist on hydra. + ;; do not exist on hydra and on MS Windows. (should (zerop (process-file "true"))) (should-not (zerop (process-file "false"))) (should-not (zerop (process-file "binary-does-not-exist"))) ;; Return exit code. (should (= 42 (process-file - (tramp--test-shell-file-name) - nil nil nil "-c" "exit 42"))) + (tramp--test-shell-file-name) nil nil nil + (tramp--test-shell-command-switch) "exit 42"))) ;; Return exit code in case the process is interrupted, ;; and there's no indication for a signal describing string. (unless (tramp--test-sshfs-p) @@ -5101,8 +5104,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (should (= (+ 128 2) (process-file - (tramp--test-shell-file-name) - nil nil nil "-c" "kill -2 $$"))))) + (tramp--test-shell-file-name) nil nil nil + (tramp--test-shell-command-switch) "kill -2 $$"))))) ;; Return string in case the process is interrupted and ;; there's an indication for a signal describing string. (unless (tramp--test-sshfs-p) @@ -5111,8 +5114,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (string-match-p (rx (| "Interrupt" "Signal 2")) (process-file - (tramp--test-shell-file-name) - nil nil nil "-c" "kill -2 $$"))))) + (tramp--test-shell-file-name) nil nil nil + (tramp--test-shell-command-switch) "kill -2 $$"))))) ;; Check DESTINATION. (dolist (destination `(nil t ,buffer)) @@ -6292,7 +6295,8 @@ INPUT, if non-nil, is a string sent to the process." (connection-local-set-profile-variables 'remote-sh `((explicit-shell-file-name . ,(tramp--test-shell-file-name)) - (explicit-sh-args . ("-c" "echo foo")))) + (explicit-sh-args + . (,(tramp--test-shell-command-switch) "echo foo")))) (connection-local-set-profiles `(:application tramp :protocol ,(file-remote-p default-directory 'method) @@ -7251,14 +7255,14 @@ This requires restrictions of file name syntax." (defun tramp--test-supports-processes-p () "Return whether the method under test supports external processes." - ;; We use it to enable/disable tests in a given test run, for - ;; example for remote processes on MS Windows. - (if (tramp-connection-property-p - tramp-test-vec "tramp--test-supports-processes-p") - (tramp-get-connection-property - tramp-test-vec "tramp--test-supports-processes-p") - (and (or (tramp--test-adb-p) (tramp--test-sh-p) (tramp--test-sshfs-p)) - (not (tramp--test-crypt-p))))) + (unless (tramp--test-crypt-p) + ;; We use it to enable/disable tests in a given test run, for + ;; example for remote processes on MS Windows. + (if (tramp-connection-property-p + tramp-test-vec "tramp--test-supports-processes-p") + (tramp-get-connection-property + tramp-test-vec "tramp--test-supports-processes-p") + (or (tramp--test-adb-p) (tramp--test-sh-p) (tramp--test-sshfs-p))))) (defun tramp--test-supports-set-file-modes-p () "Return whether the method under test supports setting file modes." @@ -7283,8 +7287,8 @@ This requires restrictions of file name syntax." (tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (tramp--test-make-temp-name 'local quoted)) (files - (delq - nil (mapcar (lambda (x) (unless (string-empty-p x) x)) files))) + (tramp-compat-seq-keep + (lambda (x) (unless (string-empty-p x) x)) files)) (process-environment process-environment) (sorted-files (sort (copy-sequence files) #'string-lessp)) buffer) @@ -7724,7 +7728,6 @@ process sentinels. They shall not disturb each other." (define-key special-event-map [sigusr1] #'tramp--test-timeout-handler) (let* (;; For the watchdog. (default-directory (expand-file-name temporary-file-directory)) - (shell-file-name (tramp--test-shell-file-name)) ;; It doesn't work on w32 systems. (watchdog (start-process-shell-command @@ -7794,7 +7797,7 @@ process sentinels. They shall not disturb each other." "Stop timer %s %s" file (current-time-string)) ;; Adjust timer if it takes too much time. (when (> (- (float-time) time) timer-repeat) - (setq timer-repeat (* 1.1 timer-repeat)) + (setq timer-repeat (* 1.1 (- (float-time) time))) (setf (timer--repeat-delay timer) timer-repeat) (tramp--test-message "Increase timer %s" timer-repeat)))))))) @@ -7840,7 +7843,8 @@ process sentinels. They shall not disturb each other." (lambda (proc _state) (tramp--test-with-proper-process-name-and-buffer proc (tramp--test-message - "Process sentinel %s %s" proc (current-time-string))))))) + "Process sentinel %s %s" proc (current-time-string))))) + (tramp--test-message "Process started %s" proc))) ;; Send a string to the processes. Use a random order of ;; the buffers. Mix with regular operation. @@ -8300,6 +8304,8 @@ If INTERACTIVE is non-nil, the tests are run interactively." ;; * Implement `tramp-test31-interrupt-process' and ;; `tramp-test31-signal-process' for "adb", "sshfs" and for direct ;; async processes. Check, why they don't run stable. +;; * Check, why `tramp-test45-asynchronous-requests' often fails. The +;; famous reentrant error? ;; * Check, why direct async processes do not work for ;; `tramp-test45-asynchronous-requests'. -- cgit v1.2.1