]> git.eshelyaron.com Git - emacs.git/commitdiff
Tramp: Don't require PuTTY 0.82 anymore
authorMichael Albinus <michael.albinus@gmx.de>
Sat, 15 Feb 2025 16:12:52 +0000 (17:12 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 15 Feb 2025 19:34:08 +0000 (20:34 +0100)
* doc/misc/tramp.texi: Revert last change.

* lisp/net/tramp-cache.el (with-tramp-saved-connection-properties):
Adapt `tramp-verbose' when completing host names.

* lisp/net/tramp-sh.el (tramp-methods) <plink, plinkx, pscp, psftp>:
Adapt `tramp-login-args' and `tramp-copy-args' arguments.
(tramp-plink-option-exists-p): New defun.
(tramp-ssh-or-plink-options): Rename from
`tramp-ssh-controlmaster-options'.  Adapt further plink options.
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-maybe-open-connection): Adapt calls.

* lisp/net/tramp.el (tramp-file-name-handler): Don't touch
`tramp-verbose'.

* test/lisp/net/tramp-tests.el (top): Set `vc-handled-backends' to nil.
(tramp--test-enabled): Rearrange code.

(cherry picked from commit 5fcf07ac096a588a561fae07d8177acd8e45498b)

doc/misc/tramp.texi
lisp/net/tramp-cache.el
lisp/net/tramp-sh.el
lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index 467bc7d35a2e892341abaf2f023bfe51f0fd3c01..941029a8ffc71ac65b9ab0e69940212c47e95325 100644 (file)
@@ -955,10 +955,9 @@ This is another method from the Kerberos suite.  It behaves like
 @cindex @option{plink} method
 @item @option{plink}
 
-@option{plink} method is for MS Windows users with the
-PuTTY@footnote{It requires at least PuTTY 0.82.} implementation of
-SSH@.  It uses @samp{plink -ssh} to log in to the remote host.  It
-supports changing the remote login shell @command{/bin/sh}.
+@option{plink} method is for MS Windows users with the PuTTY
+implementation of SSH@.  It uses @samp{plink -ssh} to log in to the
+remote host.  It supports changing the remote login shell @command{/bin/sh}.
 
 Check the @samp{Share SSH connections if possible} control for that
 session.
@@ -1181,8 +1180,7 @@ This method supports the @samp{-p} argument.
 These methods are similar to @option{scp} or @option{sftp}, but they
 use the @command{plink} command to connect to the remote host, and
 they use @command{pscp} or @command{psftp} for transferring the files.
-These programs are part of PuTTY@footnote{It requires at least PuTTY
-0.82.}, an SSH implementation for MS Windows.
+These programs are part of PuTTY, an SSH implementation for MS Windows.
 
 They support changing the remote login shell @command{/bin/sh}.
 
index 64f14c46db699f739dead8b0c3a60b6a54365d93..ba4c786451a82cc734a483d92f5629fc631c8250 100644 (file)
@@ -502,7 +502,9 @@ PROPERTIES is a list of file properties (strings)."
           (mapcar
            (lambda (property)
              (cons property (gethash property hash tramp-cache-undefined)))
-           ,properties)))
+           ,properties))
+         ;; Avoid superfluous debug buffers during host name completion.
+         (tramp-verbose (if minibuffer-completing-file-name 0 tramp-verbose)))
      (tramp-message key 7 "Saved %s" values)
      (unwind-protect (progn ,@body)
        ;; Reset PROPERTIES.  Recompute hash, it could have been flushed.
index 24e27a102de35346460a0b1dfb98416e60d09047..e4df1499467a2937901745b32b66b9c96c65016b 100644 (file)
@@ -322,8 +322,6 @@ The string is used in `tramp-methods'.")
               `("plink"
                 (tramp-login-program        "plink")
                 (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%c")
-                                            ;; Since PuTTY 0.82.
-                                            ("-legacy-stdio-prompts")
                                             ("-t") ("%h") ("\"")
                                             (,(format
                                                "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
@@ -337,8 +335,6 @@ The string is used in `tramp-methods'.")
               `("plinkx"
                 (tramp-login-program        "plink")
                 (tramp-login-args           (("-load") ("%h") ("%c") ("-t") ("\"")
-                                            ;; Since PuTTY 0.82.
-                                            ("-legacy-stdio-prompts")
                                             (,(format
                                                "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
                                                tramp-terminal-type
@@ -351,8 +347,6 @@ The string is used in `tramp-methods'.")
               `("pscp"
                 (tramp-login-program        "plink")
                 (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%c")
-                                            ;; Since PuTTY 0.82.
-                                            ("-legacy-stdio-prompts")
                                             ("-t") ("%h") ("\"")
                                             (,(format
                                                "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
@@ -363,9 +357,7 @@ The string is used in `tramp-methods'.")
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
                 (tramp-copy-program         "pscp")
-                (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-scp")
-                                            ;; Since PuTTY 0.82.
-                                            ("-legacy-stdio-prompts")
+                (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-scp") ("%c")
                                             ("-p" "%k") ("-q") ("-r")))
                 (tramp-copy-keep-date       t)
                 (tramp-copy-recursive       t)))
@@ -373,8 +365,6 @@ The string is used in `tramp-methods'.")
               `("psftp"
                 (tramp-login-program        "plink")
                 (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%c")
-                                            ;; Since PuTTY 0.82.
-                                            ("-legacy-stdio-prompts")
                                             ("-t") ("%h") ("\"")
                                             (,(format
                                                "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
@@ -385,9 +375,7 @@ The string is used in `tramp-methods'.")
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
                 (tramp-copy-program         "pscp")
-                (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-sftp")
-                                            ;; Since PuTTY 0.82.
-                                            ("-legacy-stdio-prompts")
+                (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-sftp") ("%c")
                                             ("-p" "%k")))
                 (tramp-copy-keep-date       t)))
 
@@ -2506,7 +2494,7 @@ The method used must be an out-of-band method."
       ;; Compose copy command.
       (setq options
            (format-spec
-            (tramp-ssh-controlmaster-options v)
+            (tramp-ssh-or-plink-options v)
             (format-spec-make
              ?t (tramp-get-connection-property
                  (tramp-get-connection-process v) "temp-file" "")))
@@ -4916,41 +4904,60 @@ Goes through the list `tramp-inline-compress-commands'."
     (zerop
      (tramp-call-process vec "ssh" nil nil nil "-G" "-o" option "0.0.0.1"))))
 
-(defun tramp-ssh-controlmaster-options (vec)
-  "Return the Control* arguments of the local ssh."
+(defun tramp-plink-option-exists-p (vec option)
+  "Check, whether local plink OPTION is applicable."
+  ;; We don't want to cache it persistently.
+  (with-tramp-connection-property nil option
+    ;; "plink" with valid options returns "plink: no valid host name
+    ;; provided".  We xcheck for this error message."
+    (with-temp-buffer
+      (tramp-call-process vec "plink" nil t nil option)
+      (not
+       (string-match-p
+       (rx (| (: "plink: unknown option \"" (literal option) "\"" )
+              (: "plink: option \"" (literal option)
+                 "\" not available in this tool" )))
+       (buffer-string))))))
+
+(defun tramp-ssh-or-plink-options (vec)
+  "Return additional arguments of the local ssh or plink."
   (cond
    ;; No options to be computed.
-   ((or (null tramp-use-connection-share)
-       (null (assoc "%c" (tramp-get-method-parameter vec 'tramp-login-args))))
-    "")
+   ((null (assoc "%c" (tramp-get-method-parameter vec 'tramp-login-args))) "")
 
-   ;; Use plink option.
+   ;; Use plink options.
    ((string-match-p
      (rx "plink" (? ".exe") eol)
      (tramp-get-method-parameter vec 'tramp-login-program))
-    (if (eq tramp-use-connection-share 'suppress)
-       "-noshare" "-share"))
+    (concat
+     (if (eq tramp-use-connection-share 'suppress)
+        "-noshare" "-share")
+     ;; Since PuTTY 0.82.
+     (when (tramp-plink-option-exists-p vec "-legacy-stdio-prompts")
+       " -legacy-stdio-prompts")))
 
    ;; There is already a value to be used.
    ((and (eq tramp-use-connection-share t)
          (stringp tramp-ssh-controlmaster-options))
     tramp-ssh-controlmaster-options)
 
-   ;; We can't auto-compute the options.
-   ((ignore-errors
-      (not (tramp-ssh-option-exists-p vec "ControlMaster=auto")))
-    "")
-
-   ;; Determine the options.
-   (t (ignore-errors
-        ;; ControlMaster and ControlPath options are introduced in OpenSSH 3.9.
-        (concat
-         "-o ControlMaster="
-         (if (eq tramp-use-connection-share 'suppress)
+   ;; Use ssh options.
+   (tramp-use-connection-share
+    ;; We can't auto-compute the options.
+    (if (ignore-errors
+         (not (tramp-ssh-option-exists-p vec "ControlMaster=auto")))
+       ""
+
+      ;; Determine the options.
+      (ignore-errors
+       ;; ControlMaster and ControlPath options are introduced in OpenSSH 3.9.
+       (concat
+        "-o ControlMaster="
+        (if (eq tramp-use-connection-share 'suppress)
              "no" "auto")
 
-         " -o ControlPath="
-         (if (eq tramp-use-connection-share 'suppress)
+        " -o ControlPath="
+        (if (eq tramp-use-connection-share 'suppress)
              "none"
            ;; Hashed tokens are introduced in OpenSSH 6.7.  On macOS
            ;; we cannot use an absolute file name, it is too long.
@@ -4964,10 +4971,10 @@ Goes through the list `tramp-inline-compress-commands'."
              (or small-temporary-file-directory
                  tramp-compat-temporary-file-directory))))
 
-         ;; ControlPersist option is introduced in OpenSSH 5.6.
+        ;; ControlPersist option is introduced in OpenSSH 5.6.
         (when (and (not (eq tramp-use-connection-share 'suppress))
                     (tramp-ssh-option-exists-p vec "ControlPersist=no"))
-          " -o ControlPersist=no"))))))
+          " -o ControlPersist=no")))))))
 
 (defun tramp-scp-strict-file-name-checking (vec)
   "Return the strict file name checking argument of the local scp."
@@ -5183,9 +5190,9 @@ connection if a previous connection has died for some reason."
              (let* ((current-host tramp-system-name)
                     (target-alist (tramp-compute-multi-hops vec))
                     (previous-hop tramp-null-hop)
-                    ;; We will apply `tramp-ssh-controlmaster-options'
+                    ;; We will apply `tramp-ssh-or-plink-options'
                     ;; only for the first hop.
-                    (options (tramp-ssh-controlmaster-options vec))
+                    (options (tramp-ssh-or-plink-options vec))
                     (process-connection-type tramp-process-connection-type)
                     (process-adaptive-read-buffering nil)
                     ;; There are unfortunate settings for "cmdproxy"
index dd525fbd01bc10111f4ed5c0c4ac213bc639b19b..9cefeafea6e74fb7e7c822820450d96ddeefab27 100644 (file)
@@ -2538,10 +2538,7 @@ Fall back to normal file name handler if no Tramp file name handler exists."
                          ;; We flush connection properties
                          ;; " process-name" and " process-buffer",
                          ;; because the operations shall be applied
-                         ;; in the main connection process.  In order
-                         ;; to avoid superfluous debug buffers during
-                         ;; host name completion, we adapt
-                         ;; `tramp-verbose'.
+                         ;; in the main connection process.
                          ;; If `non-essential' is non-nil, Tramp shall
                          ;; not open a new connection.
                          ;; If Tramp detects that it shouldn't continue
@@ -2552,11 +2549,8 @@ Fall back to normal file name handler if no Tramp file name handler exists."
                          ;; In both cases, we try the default handler then.
                          (with-tramp-saved-connection-properties
                              v '(" process-name" " process-buffer")
-                           (let ((tramp-verbose
-                                  (if minibuffer-completing-file-name
-                                      0 tramp-verbose)))
-                             (tramp-flush-connection-property v " process-name")
-                             (tramp-flush-connection-property v " process-buffer"))
+                           (tramp-flush-connection-property v " process-name")
+                           (tramp-flush-connection-property v " process-buffer")
                            (setq result
                                  (catch 'non-essential
                                    (catch 'suppress
index 0bb81c188e7a8c373178de17ab5a4509794be761..44ccd55285075ab109442fa208d68ae9dc18475b 100644 (file)
       tramp-copy-size-limit nil
       tramp-error-show-message-timeout nil
       tramp-persistency-file-name nil
-      tramp-verbose 0)
+      tramp-verbose 0
+      vc-handled-backends nil)
 
 (defconst tramp-test-name-prefix "tramp-test"
   "Prefix to use for temporary test files.")
@@ -251,20 +252,20 @@ being the result.")
           (file-writable-p ert-remote-temporary-file-directory))))))
 
   (when (cdr tramp--test-enabled-checked)
-    ;; Remove old test files.
-    (dolist (dir `(,temporary-file-directory
-                  ,tramp-compat-temporary-file-directory
-                  ,ert-remote-temporary-file-directory))
-      (dolist (file (directory-files
-                    dir 'full
-                    (rx-to-string
-                     `(: bos (? ".#")
-                         (| ,tramp-test-name-prefix
-                            ,(if (getenv "TRAMP_TEST_CLEANUP_TEMP_FILES")
-                                 tramp-temp-name-prefix 'unmatchable))))))
-
-       ;; Exclude sockets and FUSE mount points.
-       (ignore-errors
+    (ignore-errors
+      ;; Remove old test files.
+      (dolist (dir `(,temporary-file-directory
+                    ,tramp-compat-temporary-file-directory
+                    ,ert-remote-temporary-file-directory))
+       (dolist (file (directory-files
+                      dir 'full
+                      (rx-to-string
+                       `(: bos (? ".#")
+                           (| ,tramp-test-name-prefix
+                              ,(if (getenv "TRAMP_TEST_CLEANUP_TEMP_FILES")
+                                   tramp-temp-name-prefix 'unmatchable))))))
+
+         ;; Exclude sockets and FUSE mount points.
          (unless
              (or (string-prefix-p
                   "srw" (file-attribute-modes (file-attributes file)))