Where are the errors ?

Oct 25, 2012 at 9:46 AM

Did not found a better subject title, sorry ^^

I was wondering why we do not have sftp server errors?

I try to explain. I use the library in one application that provide Sftp connections to users.
There is a case where the user cannot connect to the Sftp server because it doesn't have the right to access a directory, for example:

It should be logged into /usr/username, but for unknown reason it doesn't have access to /usr, so it cannot log into /usr/username.

If I use Filezilla I receive this message:
Connection closed by server with exitcode 128

With the library, it get stuck in

var index = EventWaitHandle.WaitAny(waitHandles, operationTimeout);

in

internal void WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout)

of SubsystemSession.cs.

The only way I found to get errors is to set the OperationTimeout to 2 seconds.
Which throw me a SshOperationTimeoutException(). The problem is that I'm not really fond of this, because this is no timeout, and I could timeout on other operation just because I may have set a value to low. 

I've tried to understand how it works and how to "unstuck" from WaitHandle, but I can't find anything.

Coordinator
Dec 27, 2012 at 10:38 PM

Hi,

 

From what I managed to check, when an error occurs all I get is status code and message, which I wrapping into exception and throw it to the client.

The only thing I can think of is that maybe Filezilla can support higher SFTP version then 3 and that's why it can return more accurate information.

 

But lets say if that's true then you cant relay on it since what if you connect to the server that does not support higher version.

 

I will look into higher SFTP versions to see if that's an issue and could be resolved in the future.

 

Thanks,

Oleg

Coordinator
Dec 28, 2012 at 12:19 AM

Hey,

From what I could see is that later SFTP protocols support more error codes.

For example version 4 already have SSH_FX_WRITE_PROTECT status code which might be relevant in your case.

Unfortunately I only support version 3, at least at this point, since that what I found was mostly common.

 

I might be able to add support for more versions in the future as time permits.

 

Thanks,

Oleg

Dec 28, 2012 at 9:26 AM

Ok, I can understand that.

But why does it get stuck in the method ? Is there any other solution (except the timeout?)

Coordinator
Dec 28, 2012 at 3:19 PM

Hmm,

Thats I will need to investigate I guess.

 

Since I am not a UNIX person I will need some help with that :(:(

How can I set up similar environment on my server?

What I mean is how to create a user who doesnt have access right to a folder when he logs in?

I created a user and then removed his right to access a folder but then what happened is when I logged in it went to the root folder and lists me root folders.

Or if you have test environment on your end that I can connect I could try that, you can send me info privately in this case.

 

Thanks,

Oleg

Jan 4, 2013 at 9:44 AM
Edited Jan 4, 2013 at 9:59 AM

This happens only on MacOS X sftp servers, so I send you a private message with the information to connect and try it.

Coordinator
Jan 4, 2013 at 12:38 PM

Thanks,

Ok, So I found an issue.

What happens is that SFTP channel is being closed and I am not handling this situation in that case,

Will try to come up with a generic fix and will let you know.

 

Thanks,

Oleg

Coordinator
Jan 4, 2013 at 12:55 PM

Hey,

 

I just commited a fix for the problem you described.

I could not find an error message to display but now it does not hang but throws an exception saying that channel was closed.

 

Please let me know if you have suggestion for a better solution or this will work.

 

Thanks,

Oleg