Tramp: Don't require PuTTY 0.82 anymore

* 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.
This commit is contained in:
Michael Albinus 2025-02-15 17:12:52 +01:00
parent b8b7c6fbfd
commit 5fcf07ac09
5 changed files with 71 additions and 69 deletions

View 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.
@ -1191,8 +1190,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}.

View 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.

View 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)))
@ -2497,7 +2485,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" "")))
@ -4909,41 +4897,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")))
"")
;; 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.
(t (ignore-errors
;; ControlMaster and ControlPath options are introduced in OpenSSH 3.9.
(concat
"-o ControlMaster="
(if (eq tramp-use-connection-share 'suppress)
;; 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.
@ -4957,10 +4964,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."
@ -5176,9 +5183,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"

View file

@ -2534,10 +2534,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
@ -2548,11 +2545,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

View file

@ -152,7 +152,8 @@
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))))))
(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.
(ignore-errors
;; Exclude sockets and FUSE mount points.
(unless
(or (string-prefix-p
"srw" (file-attribute-modes (file-attributes file)))