IETF-SSH archive

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

Re: Channel close logic, needs clarification?



> > 2. When SSH_MSG_CHANNEL_EOF is both sent and received,
> >    SSH_MSG_CHANNEL_CLOSE is sent (unless it wasn't sent earlier). This
> >    makes sense in almost all cases (and the only exceptions I'm aware
> >    of seem out-of-scope here, they are related to proxying or
> >    gatewaying channels).
> 
> I'm not sure that you can rely on getting an EOF message.
> 
> > So, what is left to decide is when to send SSH_MSG_CHANNEL_EOF. In
> > most cases, the decision is easy, but sometimes it is not.

The intention here was that the EOF message simply means "I am not going
to send more".  It is similar to TCP half-close.  However,
SSH_MSG_CHANNEL_EOF alone is not intended to initiate closing down the
channel.  However, in some situations it is possible that both sides
determine simulatenously that they will not be sending more.  A side
should initiate closing the channel (by sending SSH_MSG_CHANNEL_CLOSE)
when if it has both sent and received EOF.

It is legal to send other messages, e.g. channel requests, after both
sending and receing EOF.  However, it is illegal to send ANYTHING after
sending SSH_MSG_CHANNEL_CLOSE.

> The OpenSSH client considers the "exit-status" message just informational
> and does _not_ send an EOF message back.

This is correct behavior.  It is intended as simply a notification.

> > But appearantly, this logic doesn't work right when talking to the
> > openssh client. It doesn't send any SSH_MSG_CHANNEL_EOF, and to the
> > user it appears that the system just hangs.
> 
> The OpenSSH server does not wait for the EOF message from the client.
> However, since the servers' child process is dead, the server decides
> that it will not write to more data to the 'stdin' handle and does _not_
> wait for the EOF message from the client.  This way the the channel is
> correctly closed.

It is legal to send SSH_MSG_CHANNEL_CLOSE before receiving/sending EOF (it
is illegal to send anything, including EOF, after sending
SSH_MSG_CHANNEL_CLOSE).  The channel data structures can be freed when
CLOSE has been both sent and received (in either order).

    Tatu

SSH Communications Security           http://www.ssh.com/
SSH IPSEC Toolkit                     http://www.ipsec.com/
SSH Secure Shell                      http://www.ssh.com/products/ssh




Home | Main Index | Thread Index | Old Index