I'm encountering surprising behavior from the SFtp subsystem of the MINA SSHD 
server, and I'm hoping that someone can help me understand it.


In short, read-only file opens succeed even if the file does not exist.  The 
subsequent file read commands are doomed to failure.  This causes annoying 
behavior in my application.


In greater detail:

SftpSubsystem.process() has a switch statement that processes commands.  File 
open processing is done by the SSH_FXP_OPEN case.  The code here succeeds if 
file.doesExist() is false and the SSH_FXF_CREAT bit isn't set.  As a result, a 
handle is returned to the client as if everything were OK.  But when the client 
tries to do a SSH_FXP_READ on that handle, there will be no file that's 
actually open.  In this case, my application not unreasonably returns an error.


The problem is that this works poorly with some clients - most notably the 
widely-used PSFTP.EXE.  What happens is that the client, seeing that the open 
succeeded, issues a large number of initial read requests, in order to optimize 
the flow of packets.  However, every one of these read requests fails.  And in 
my case, each results in a error record being logged in the application.  For 
PSFTP, that's 32 errors logged for each open of a non-existing file.


It seems to me that SftpSubsystem.process() should return an error if the file 
doesn't exist and the caller doesn't want to create the file.

Or am I missing something?


Thanks.


Mark R

Reply via email to