Re: Restoring block mode on exiting

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

 



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);

Regards,

David

_______________________________________________
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