Restoring block mode on exiting

Dmitry Belyavskiy dbelyavs at redhat.com
Fri Apr 23 01:36:21 AEST 2021


Hello,

OpenSSH incorrectly restores the standard mode (blocking mode) on standard
output upon exiting. This causes the next shell scripts commands to
potentially fail in EAGAIN.
The reproducer is:

#!/bin/sh
(
ssh localhost true
cat /dev/zero
) | sleep 30

Restoring the blocking modes happens with the duped file descriptors and
too late.

The changes causing this problem was introduced in
https://github.com/openssh/openssh-portable/commit/4d5456c7de108e17603a0920c4d15bca87244921

The 2 possible fixes can be found in
https://github.com/openssh/openssh-portable/pull/244 (adhoc patch) and
https://github.com/openssh/openssh-portable/pull/246 (more robust one).

I think it's worth fixing the issue in this, that or any other way.
I'll be happy to adopt any of those patches to the state when they become
suitable for upstream.

Many thanks in advance!

-- 
Dmitry Belyavskiy


More information about the openssh-unix-dev mailing list