[8.0p1] After the remote ssh command execution, the session does not terminate until an active disconnect
djm at mindrot.org
Tue Aug 20 16:27:16 AEST 2019
On Tue, 20 Aug 2019, Hong Cho wrote:
> We recently upgraded OpenSSH from 7.5p1 to 8.0p1, and received a report
> that there was a behavioral differences where the ssh session did not
> disconnect after a remote background command execution. For example, "ssh
> user at example.com 'tail -f /var/xxx &'
> After looking at the debug logs and comparing the code, it seems there was
> a bug in the portable version during the adaptation of the 1.367 change
> (refactoring) of channels.c.
> The OpenBSD version looks correct, but for the portable version, the exit
> condition of channel_handle_efd_read() didn't get converted correctly, but
> somehow got copy-and-pasted from the rfd version. I couldn't find the
> change history for the portable version, so I can't when/how this happened.
> This should make the "force" condition the same as before the refactoring
> of the portable version of channels.c.
> --- /tmp/tmp.48415.39 2019-08-19 19:24:29.000000000 -0700
> +++ crypto/openssh/channels.c 2019-08-19 19:19:39.000000000 -0700
> @@ -2103,7 +2103,15 @@ channel_handle_efd_read(struct ssh *ssh,
> ssize_t len;
> int r, force;
> + force = c->detach_close;
> - force = c->isatty && c->detach_close && c->istate != CHAN_INPUT_CLOSED;
This change wasn't a refactor or a mistake, but an intentional bugfix for
Anyway, I don't see any change in behaviour for your testcase between
OpenSSH 7.2 and 8.0 on Linux - they both wait for the tail process to
terminate before dropping the connection. Applying your suggested change
doesn't make any difference either.
The behaviour at close has always been a tricky area and there are
divergences between portable OpenSSH and OpenBSD for a long time, driven
by how more SysV-ish systems like Linux differ from BSDs.
BTW line-by-line change history can be extracted using "git blame"
on a checkout of the portable OpenSSH git tree.
More information about the openssh-unix-dev