The empty file must be caused by the truncate flag on the SSH_FXP_OPEN command. It looks like the flags passed are SSH_FXF_CREAT | SSH_FXF_TRUNC. I think you're right that if the user does not have write permission on the file, the truncate will still be done, so that's definitely a bug. If you could raise a JIRA, i'll try to fix that.
For the exception, it may be that the client abruptely close the connection, because i don't see the channel close related messages being exchanged. But the only effect is that it will force closing the connection on the server side, so that should not be an issue. Guillaume Nodet 2014-07-07 12:33 GMT+02:00 Stefan Mueller <[email protected]>: > I have two problems with SFTP that I can not chase down. I hope you can > help > me by looking at the server log, because I could not get a simple working > example yet. > > > The first problem is a big one. The content of a file gets deleted if the > user has no write permission and he tries to write. I used break points to > find where the content gets deleted, but could not find it. > > *Step 1)* FileZilla: Open/Edit file > > *Step 2)* Edi the file. Save the file. Upload the file. > > *Step 3)* Server LOG: > [pool-2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Read > 80 > bytes > [pool-2-thread-3] DEBUG org.apache.sshd.server.channel.ChannelSession - > Received SSH_MSG_CHANNEL_DATA on channel ChannelSession[id=0, > recipient=256] > [Thread-3] DEBUG org.apache.sshd.server.sftp.SftpSubsystem - Received > SSH_FXP_REALPATH (path=/test/test.txt) > [Thread-3] DEBUG org.apache.sshd.server.channel.ChannelSession - Send > SSH_MSG_CHANNEL_DATA on channel 0 > [Thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Writing 176 > bytes > [pool-2-thread-4] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Read > 96 > bytes > [pool-2-thread-4] DEBUG org.apache.sshd.server.channel.ChannelSession - > Received SSH_MSG_CHANNEL_DATA on channel ChannelSession[id=0, > recipient=256] > [pool-2-thread-5] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - > Finished writing > [Thread-3] DEBUG org.apache.sshd.server.sftp.SftpSubsystem - Received > SSH_FXP_OPEN (path=/test/test.txt, pflags=26, attrs={}) > [Thread-3] DEBUG org.apache.sshd.server.channel.ChannelSession - Send > SSH_MSG_CHANNEL_DATA on channel 0 > [Thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Writing 112 > bytes > [pool-2-thread-1] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - > Finished writing > [pool-2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Read > 128 bytes > [pool-2-thread-2] DEBUG org.apache.sshd.server.channel.ChannelSession - > Received SSH_MSG_CHANNEL_DATA on channel ChannelSession[id=0, > recipient=256] > [Thread-3] DEBUG org.apache.sshd.server.sftp.SftpSubsystem - Received > SSH_FXP_WRITE (handle=cc0e88bc-c028-45b1-aa55-f01787135b61, offset=0, > data=byte[8]) > [Thread-3] INFO sftp.filesystem.SshFtpFile - Checking authorization for > /test/test.txt > [Thread-3] INFO sftp.filesystem.SshFtpFile - Not authorized > [Thread-3] DEBUG org.apache.sshd.server.sftp.SftpSubsystem - Send > SSH_FXP_STATUS (substatus=4, msg=No write permission : test.txt) > [Thread-3] DEBUG org.apache.sshd.server.channel.ChannelSession - Send > SSH_MSG_CHANNEL_DATA on channel 0 > [Thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Writing 128 > bytes > > *Step 4)* Break point at following method: > SshFtpFile.createOutputStream(...) > { > // File is already empty! > // Then it checks write permission > if( isWritable() ) > {...} > } > > > > The second problem is an IOException thrown when the connection is closed > normally. No further problems occur. Only this message in the logs. What is > the issue? > > *Step 1)* Normal disconnect from FileZilla or closing the server. > > *Step 2)* Server LOG: > [pool-2-thread-3] DEBUG org.apache.sshd.server.channel.ChannelSession - > Received SSH_MSG_CHANNEL_DATA on channel > > ChannelSession[id=0, recipient=256] > [Thread-2] DEBUG org.apache.sshd.server.sftp.SftpSubsystem - Received > SSH_FXP_READDIR (handle=cc0370bd-5173-40ce-b1a9- > > 6c5d68bc05dd) > [Thread-2] DEBUG org.apache.sshd.server.sftp.SftpSubsystem - Send > SSH_FXP_STATUS (substatus=1, msg=) > [Thread-2] DEBUG org.apache.sshd.server.channel.ChannelSession - Send > SSH_MSG_CHANNEL_DATA on channel 0 > [Thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Writing 96 > bytes > [pool-2-thread-4] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Read > 112 bytes > [pool-2-thread-1] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - > Finished writing > [pool-2-thread-4] DEBUG org.apache.sshd.server.channel.ChannelSession - > Received SSH_MSG_CHANNEL_DATA on channel > > ChannelSession[id=0, recipient=256] > [Thread-2] DEBUG org.apache.sshd.server.sftp.SftpSubsystem - Received > SSH_FXP_CLOSE (handle=cc0370bd-5173-40ce-b1a9- > > 6c5d68bc05dd) > [Thread-2] DEBUG org.apache.sshd.server.sftp.SftpSubsystem - Send > SSH_FXP_STATUS (substatus=0, msg=) > [Thread-2] DEBUG org.apache.sshd.server.channel.ChannelSession - Send > SSH_MSG_CHANNEL_DATA on channel 0 > [Thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Writing 96 > bytes > [pool-2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - > Finished writing > [pool-2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - Caught > exception, now calling handler > [pool-2-thread-3] WARN org.apache.sshd.server.session.ServerSession - > Exception caught > java.io.IOException: Der angegebene Netzwerkname ist nicht mehr verfügbar. > > at sun.nio.ch.Iocp.translateErrorToIOException(Unknown Source) > at sun.nio.ch.Iocp.access$700(Unknown Source) > at sun.nio.ch.Iocp$EventHandlerTask.run(Unknown Source) > at java.lang.Thread.run(Unknown Source) > > > *Translation: > "java.io.IOException: The specified network name is no longer available." > > > > > -- > View this message in context: > http://apache-mina.10907.n7.nabble.com/SSHD-Problems-with-SFTP-tp42625.html > Sent from the Apache MINA User Forum mailing list archive at Nabble.com. >
