Subject: bug#30946: 26.0.90; TRAMP cannot access some files when using hops

From: Phil Sainty <[email-masked]>
Date: Mon, 31 Dec 2018 11:01:46 +1300

(resending this to just the bug address, after unarchiving)

On 26/03/18 9:42 PM, Nicolas Petton wrote:
> As discussed on the emacs-devel mailing list, when using tramp with
> multiple hops like the following:
>
>   C-x C-f /ssh:[email-masked]|sudo:localhost:/etc/deluser.conf
>
> Tramp opens an empty buffer, without showing any error message.
>
> I understand now that the second hop should be "sudo:example.com:",
> but it felt intuitive to use localhost, and for most files on the
> remote host it actually worked.

I'd suspect that https://stackoverflow.com/a/16408592/324105 explains
why it 'worked':

> The trap here is that sudo:: does actually appear to work -- however
> when you do that the HOST for the dynamic proxy entry will be the
> hostname you originated from rather than the host you connected
> to. This will not only look confusing (as the wrong host will be
> displayed in the file paths), but it will also mean that any
> subsequent attempt to use sudo:: on your localhost will instead be
> proxied to the remote server!

i.e. /ssh:[email-masked]|sudo:localhost was previously creating a proxy
that said that when you request files as root@localhost (for *any*
tramp method!) it should proxy via "/ssh:[email-masked]:".  The sudo
method didn't actually need or care about the specified host, so that
"worked" -- but the proxy you'd created was then a problem waiting to
bite you.

Ooohh.

Michael, that actually still remains a problem in the new version.

Despite the error message, the unintended proxy is still created,
and hence can still break things.

i.e. I try to visit:

/ssh:[email-masked]|sudo:localhost

I get the new error message:

Host name ‘localhost’ does not match ‘^example.com$’

but I *also* get a new proxy entry:

("localhost" "root" "/ssh:[email-masked]:")

So when I then visit:

/sudo:localhost:

I get the error message:

Host name ‘localhost’ does not match ‘^example.com$’

etc, etc...

Conversely, it seems that the "::" case has been attended to so that
it now transparently DWIM ?

i.e. When I try /ssh:[email-masked]|sudo:: I get a proxy entry of:
("example.com" "root" "/ssh:[email-masked]:")

whereas in earlier versions of Emacs I get the undesirable:
("<FOO>" "root" "/ssh:[email-masked]:")
Where <FOO> is my local hostname.

That's excellent, and possibly also deserves a note in the NEWS?

Currently it reads:

*** For some connection methods, like "su" or "sudo", the host name in
ad-hoc multi-hop file names must match the previous hop.

We could perhaps append:

If the hostname is left empty (e.g. "sudo::") then the host from the
previous hop is used automatically.

cheers,
-Phil

p.s. I find the new error slightly confusing to dismiss.  It's not
entirely obvious how to get back to the prompt.  Not a big problem,
as ideally people don't run into it at all, but I just thought I'd
mention it.

The error sticks around persistently until I type C-g, at which point
I get a new error "Tramp: Opening connection for root@localhost using
sudo...failed".  That error also sticks around for a couple of seconds,
which is long enough to make one suspect that it also needs to be
dismissed with C-g -- which will actually exit the minibuffer entirely,
meaning you can't simply edit the incorrect path to fix the problem,
but must start over.

(So the correct sequence is C-g and then either wait a couple of
seconds, or just start typing blindly.)

It would be nice if that was a bit smoother -- but again, I don't
think this is a significant issue in reality, so I wouldn't worry
about it unless you think it's easy to deal with.