Page MenuHomePhabricator

Opening sftp fails in non-blocking mode
Open, LowPublic


If a session is set into non-blocking mode, trying to initialize a new sftp session using sftp_new will always fail. The SFTP subsystem should support async operations same as everything else.

The reason it fails is obvious (in sftp.c:150):

if (ssh_channel_open_session(sftp->channel)) {
    goto error;

if (ssh_channel_request_sftp(sftp->channel)) {
    goto error;

Both ssh_channel_open_session and ssh_channel_request_sftp can return SSH_AGAIN which is not handled at all in the above section. I think these parts of the initialization should be moved out of sftp_new and into sftp_init or some other function. Or alternatively sftp_new should be callable multiple times, same as most other functions.

Event Timeline

Jakuje triaged this task as Low priority.Apr 9 2020, 6:56 PM
Jakuje added a subscriber: Jakuje.

Thank you for the report. You are right, this does not look like covered by any existing test case. The only one covered is the blocking mode in tests/client/torture_sftp_read.c. Contributions are always welcomed.