GNU bug report logs - #46466
28.0.50; Tramp hangs with bad prompt even when using /bin/sh

Previous Next

Package: emacs;

Reported by: Erik Hetzner <egh <at> e6h.org>

Date: Fri, 12 Feb 2021 18:16:01 UTC

Severity: wishlist

Tags: notabug

Found in version 28.0.50

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 46466 <at> debbugs.gnu.org (full text, mbox):

From: Erik Hetzner <egh <at> e6h.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 46466 <at> debbugs.gnu.org
Subject: Re: bug#46466: 28.0.50;
 Tramp hangs with bad prompt even when using /bin/sh
Date: Sat, 13 Feb 2021 09:07:50 -0800
Hi Michael,

On Sat, 13 Feb 2021 00:53:35 -0800,
Michael Albinus <michael.albinus <at> gmx.de> wrote:
> 
> […]
> 
> What is /bin/sh, both locally and remote? In my case, running Fedora 33,
> I see
> 
> --8<---------------cut here---------------start------------->8---
> # ls -l /bin/sh
> lrwxrwxrwx. 1 root root 4 Jul 27  2020 /bin/sh -> bash
> --8<---------------cut here---------------end--------------->8---

Good question, I should have mentioned that. I have tested this on
both debian and ubuntu, where /bin/sh is linked to dash

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Dec 10 05:23 /bin/sh -> dash

As a follow up, I suspect that in some way this is expected behavior.
I see that the *sshx* connection method specifies the shell to run
when connecting, whereas the *ssh* connection method connects without
specifying a command, and therefore starts a default remote shell.

This suggests a fix which turns out to works. The behavior is fixed,
 for me, by adding `("-o" "RemoteCommand='%l'")` to the list of
`tramp-login-args' for `tramp-methods' (see below).

It is also possible to set the PS1 value directly with this remote
command, e.g. `("-o" "RemoteCommand='PS1=\"$ \" %l'")`, which might
provide even more safety against unusual prompts.

Is this a patch that would be welcome? It would fix cases where users
had more elaborate prompts in their default shell and where /bin/sh
was a simpler shell (debian and ubuntu, at least). Unusual prompts are
more and more popular, but users to do not usually enable them for
/bin/sh. However, it might have effects that I am not aware of.

```
(add-to-list 'tramp-methods
             `("ssh"
               (tramp-login-program        "ssh")
               (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
				            ("-e" "none")
                                            ("-o" "RemoteCommand='%l'") ("%h")))
               (tramp-async-args           (("-q")))
               (tramp-direct-async         t)
               (tramp-remote-shell         ,tramp-default-remote-shell)
               (tramp-remote-shell-login   ("-l"))
               (tramp-remote-shell-args    ("-c"))))
```

best, Erik




This bug report was last modified 3 years and 333 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.