Re: Restoring block mode on exiting

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



Dear David,
Thank you for your recommendations!

On Fri, Apr 23, 2021 at 4:47 AM David Newall <openssh@xxxxxxxxxxxxxxx>
wrote:

> Hi Dmitry,
>
> On 23/4/21 1:06 am, Dmitry Belyavskiy wrote:
> > OpenSSH incorrectly restores the standard mode (blocking mode) on
> standard
> > output upon exiting.
>
> I agree that SSH should *restore* the blocking mode.  I've only spent a
> small
> amount of timelooking at it and I think SSH currently does not do that, and
> your patch also does not.
>
> Your patch sets blocking mode if SSH cleared it.  I think it would be more
> correct to restore it tothe state that it was when SSH took over the file
> because we shouldn't assume.
>
> In channel_register_fds, don't record if we set non-blocking mode, record
> what mode it currentlyhas:
>
>     c->nonblock = (get_nonblock(rfd) << 2) | (get_nonblock(wfd) << 1) |
>     get_nonblock(efd);
>
> Restore in channel_close_fds:
>
>     channel_close_fd(ssh, &c->sock, 0);
>     if (rfd != sock) channel_close_fd(ssh, &c->rfd, c->nonblock & 4);
>     if (wfd != sock) channel_close_fd(ssh, &c->wfd, c->nonblock & 2);
>     if (efd != sock) channel_close_fd(ssh, &c->efd, c->nonblock & 1);
>
> In channel_close_fd:
>
>     if (fd != -1) (nonblock?set_nonblock:unset_nonblock)(fd);
>

Could you please take a look at the updated version of the patch?
If I understand correctly, it provides the same blocking state after
closing the channel as it was before closing.

https://github.com/openssh/openssh-portable/pull/246

Many thanks!

-- 
Dmitry Belyavskiy
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux