"J.D. Smith" <[email protected]> writes:

Hi,

> I use `rsync' as my `tramp-default-method' since it gives me the best
> performance.  But sometimes I need to edit a remote file as root, so I
> simply append `/-:server|sudo::'.  This immediately yields the error:
>
>   Method ‘rsync’ is not supported for multi-hops
>
> I looked at configuring `tramp-default-method-alist', but it does not
> apparently match against the full (multi-hop) tramp file syntax, only
> individual hosts/users.  What I'd like is something like a
> `tramp-default-method-multihop`: a default method to use for any prior
> "default method" markers, as soon as a multi-hop file is detected.  So:
>
>   /-:server:  -> `tramp-default-method-alist'  -> `tramp-default-method'
>   /-:server|  -> `tramp-default-method-multihop'
>
> But maybe there's already a way with current configuration options?  Or
> perhaps the current configuration like `tramp-default-method-alist'
> could be extended, to provide a multi-hop flag for the alist
> configuration?

Tramp doesn't offer such a user option. But thinking about, I come back
to an old idea slumbering on my TODO: Make external methods (like scp,
rsync) multi-hop capable.

It shouldn't be too hard. As you know, Tramp distinguishes between
inline and external methods, like ssh and scp. The major difference is
copying large files, which is performed by the scp command. For
everything else, both use the same code.

In theory, it should be possible to add another check for external Tramp
methods: If they are used inside a multi-hop connection, don't use the
external command. Then, they should behave identically. See for example
the definition of the "ssh" and the "rsync" methods in
tramp-methods. They are

--8<---------------cut here---------------start------------->8---
 ("ssh"
  (tramp-login-program "ssh")
  (tramp-login-args
   (("-l" "%u")
    ("-p" "%p")
    ("%c")
    ("-e" "none")
    ("-o" "SetEnv=\"TERM=dumb\"")
    ("%h")))
  (tramp-async-args
   (("-q")))
  (tramp-direct-async
   ("-t" "-t"))
  (tramp-remote-shell "/bin/sh")
  (tramp-remote-shell-login
   ("-l"))
  (tramp-remote-shell-args
   ("-c")))
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
 ("rsync"
  (tramp-login-program "ssh")
  (tramp-login-args
   (("-l" "%u")
    ("-p" "%p")
    ("%c")
    ("-e" "none")
    ("-o" "SetEnv=\"TERM=dumb\"")
    ("%h")))
  (tramp-async-args
   (("-q")))
  (tramp-direct-async
   ("-t" "-t"))
  (tramp-remote-shell "/bin/sh")
  (tramp-remote-shell-login
   ("-l"))
  (tramp-remote-shell-args
   ("-c"))
  (tramp-copy-program "rsync")
  (tramp-copy-args
   (("-t" "%k")
    ("-p")
    ("-r")
    ("-s")
    ("-c")))
  (tramp-copy-env
   (("RSYNC_RSH")
    ("ssh")
    ("%c")))
  (tramp-copy-keep-date t)
  (tramp-copy-keep-tmpfile t)
  (tramp-copy-recursive t))
--8<---------------cut here---------------end--------------->8---

The "rsync" method has just some additional entries `tramp-copy-*',
which can be ignored in the multi-hop case.

I'll give it a try. No idea, whether there are subtle traps I'll run
into, but I hope I can fix them. Stay tuned!

Best regards, Michael.

Reply via email to