Li Fangning commented on SSHD-761:

I have seen _Unix_ version of the code, and I think it is OK, the resources are 
closed in the _closeImmediately0_ method, but I have no environment to verify 

For the _local_ implementation, we wrote the _agent.close_ call to 
_closeImmediately0_ at first, but we found an issue:
When we use the _"ssh -A xxx.xxx.xxx.xxx"_ command to pass the agent forwarding 
channel to another Linux server, and then quit normally from that server (see 
screenshot-1.png), we found the new created agent forwarding channel have not 
been closed normally (see screenshot-2.png, each _"ssh -A a.b.c.d"_ will create 
a new channel, but the channel won't be closed when logging off). When we move 
the _agent.close_ call to _handleEof_, the issue is gone.

Anyway, all channels will be closed after the final quit if we move the 
_agent.close_ call to _closeImmediately0_.
But we think that it is more reasonable to put it in the _handleEof_, recycling 
resources more timely.


> The agent forwarding channel is not closed at the end of the session
> --------------------------------------------------------------------
>                 Key: SSHD-761
>                 URL: https://issues.apache.org/jira/browse/SSHD-761
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 1.6.0
>            Reporter: Li Fangning
>            Assignee: Goldstein Lyor
>         Attachments: screenshot-1.png, screenshot-2.png
> Use the Putty client to connect to SSHD and enable Agent Forwarding.
> When the session is closed (with the "exit" command), the putty client does 
> not exit properly because the agent forwarding channel is still open.
> I modified the SSH source code to fix this issue:
> org.apache.sshd.agent.local.ChannelAgentForwarding
> {code:java}
> ......
>     // Overwide org.apache.sshd.common.channel.AbstractChannel#handleEof()
>     @Override
>     public void handleEof() throws IOException {
>         // Close agent forwarding channel
>         if (agent != null) {
>             agent.close();
>         }
>         super.handleEof();
>     }
> }
> {code}
> However, it works
> Please help me confirm whether this change is OK.
> Thanks

This message was sent by Atlassian JIRA

Reply via email to