Subject: bug#34192: 26.1; Bash 5.0 breaks TRAMP sudo

From: Allen Li <[email-masked]>
Date: Thu, 7 Feb 2019 07:04:11 +0000

I finally traced the problem down to setting tramp-histfile-override to t.

Apparently, Bash 5.0 doesn't like HISTSIZE=0.  Changing it to
HISTSIZE=1 fixes the error.

Attached patch demonstrating workaround.

I couldn't reproduce it by hand however: env HISTFILE=''
HISTFILESIZE=0 HISTSIZE=0 bash </tmp/tmp.sh

Since it's a SIGSEGV, presumably the stars have to be perfectly
aligned for the error to happen.

Reproduce:

1. emacs -Q
2. (setq tramp-histfile-override t)
3. C-x C-f /sudo::/ TAB <enter sudo password> RET

Versions:

"GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-07-05"
GNU bash, version 5.0.0(1)-release (x86_64-pc-linux-gnu)

On Mon, Feb 4, 2019 at 11:53 AM Michael Albinus <[email-masked]> wrote:
>
> Allen Li <[email-masked]> writes:
>
> Hi Allen,
>
> > I took the liberty of removing the 2>/dev/null in
> > tramp-send-command-and-check as well, but
> > I don't think there's a lot of info.
>
> > 16:13:19.704866 tramp-send-command (6) #
> > tramp_perl_file_name_all_completions () {
> > \perl -e '
> > opendir(d, $ARGV[0]) || die("$ARGV[0]: $!\nfail\n");
> > @files = readdir(d); closedir(d);
> > foreach $f (@files) {
> >  if (-d "$ARGV[0]/$f") {
> >   print "$f/\n";
> >  }
> >  else {
> >   print "$f\n";
> >  }
> > }
> > print "ok\n"
> > ' "$1"
> > } ; echo tramp_exit_status $?
> > 16:13:19.704957 tramp-get-connection-property (7) # process-name nil
> > 16:13:19.705087 tramp-get-connection-property (7) # chunksize 0
> > 16:13:19.705193 tramp-set-connection-property (7) # last-cmd-time
> > (23638 12831 705148 363000)
> > 16:13:19.705294 tramp-send-string (10) #
> > tramp_perl_file_name_all_completions () {
> > \perl -e '
> > opendir(d, $ARGV[0]) || die("$ARGV[0]: $!\nfail\n");
> > @files = readdir(d); closedir(d);
> > foreach $f (@files) {
> >  if (-d "$ARGV[0]/$f") {
> >   print "$f/\n";
> >  }
> >  else {
> >   print "$f\n";
> >  }
> > }
> > print "ok\n"
> > ' "$1"
> > } ; echo tramp_exit_status $?
> > 16:13:19.705404 tramp-get-connection-property (7) # process-buffer nil
> > 16:13:19.705518 tramp-get-connection-property (7) # check-remote-echo nil
> > 16:13:19.705597 tramp-get-connection-property (7) # check-remote-echo nil
> > 16:13:21.402934 tramp-maybe-send-script (5) # Sending script
> > ‘tramp_perl_file_name_all_completions’...failed
>
> Yes, there's even no trace 10 output about the result. Hmm, that's very
> strange.
>
> Could you, pls, send the contents of the *tramp/sudo root@cielnosurge* buffer?
>
> Best regards, Michael.
From c46cfe1b1bf4a7f218eea15012f7ce9b04524c6c Mon Sep 17 00:00:00 2001
From: Allen Li <[email-masked]>
Date: Wed, 6 Feb 2019 22:56:12 -0800
Subject: [PATCH] Workaround 34192

---
 lisp/net/tramp-sh.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 404fae9197..88968c83d6 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -4075,7 +4075,7 @@ tramp-open-shell
 		(format "HISTFILE=%s"
 			(tramp-shell-quote-argument tramp-histfile-override))
 	      (if tramp-histfile-override
-		  "HISTFILE='' HISTFILESIZE=0 HISTSIZE=0"
+		  "HISTFILE='' HISTFILESIZE=0 HISTSIZE=1"
 		""))
 	    (tramp-shell-quote-argument tramp-end-of-output)
 	    shell (or extra-args ""))
-- 
2.20.1