You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Stefan Mueller <st...@menten.com> on 2014/07/07 12:33:52 UTC
SSHD Problems with SFTP
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.
Re: SSHD Problems with SFTP
Posted by Stefan Mueller <st...@menten.com>.
Oh, I already raised an JIRA issue:
https://issues.apache.org/jira/browse/SSHD-355?jql=project%20in%20(COMPRESS%2C%20SSHD%2C%20FTPSERVER)%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22)%20ORDER%20BY%20updated%20DESC%2C%20resolved%20DESC
--
View this message in context: http://apache-mina.10907.n7.nabble.com/SSHD-Problems-with-SFTP-tp42625p44104.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
Re: SSHD Problems with SFTP
Posted by Guillaume Nodet <gn...@apache.org>.
Ok, i understand now.
Please raise a JIRA issue.
I think there are a few things to review around that.
2014-09-26 15:56 GMT+02:00 Stefan Mueller <st...@menten.com>:
> It did work. So the method isWritable() has to be called in truncate() as
> it
> is already done in other methods.
> And developers (me ;) ) have to make sure to call it in their
> implementation
> of SshFile.
>
>
>
> --
> View this message in context:
> http://apache-mina.10907.n7.nabble.com/SSHD-Problems-with-SFTP-tp42625p44101.html
> Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
>
Re: SSHD Problems with SFTP
Posted by Stefan Mueller <st...@menten.com>.
It did work. So the method isWritable() has to be called in truncate() as it
is already done in other methods.
And developers (me ;) ) have to make sure to call it in their implementation
of SshFile.
--
View this message in context: http://apache-mina.10907.n7.nabble.com/SSHD-Problems-with-SFTP-tp42625p44101.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
Re: SSHD Problems with SFTP
Posted by Stefan Mueller <st...@menten.com>.
Maybe the problem is that isWritable() is never called before truncate?!
In the version 0.11 the method truncate() is called from the interface
SshFile. Depending on the implementation it can call isWritable() or not. In
the class NativeSshFile it is not called. The same counts for my
implementation, because I did copy it.
So one solution should be to call isWritable() in truncate as it is done in
createOutputStream(). I will test it.
--
View this message in context: http://apache-mina.10907.n7.nabble.com/SSHD-Problems-with-SFTP-tp42625p44100.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
Re: SSHD Problems with SFTP
Posted by Guillaume Nodet <gn...@apache.org>.
Please raise a JIRA issue.
I was about to fix that a few minutes ago but then there's something I
don't get.
If file.isWriteable() is supposed to return false, then the call to
truncate should also be rejected by the OS, right ?
So in this use case, there's something I don't understand ... Thoughts ?
2014-09-26 12:19 GMT+02:00 Stefan Mueller <st...@menten.com>:
> Guillaume Nodet-3 wrote
> > 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.
>
> I am back to FTP/SFTP now. Sorry, that I switched so fast to another
> project. Did you look at this or should I raise a JIRA?
>
>
>
> --
> View this message in context:
> http://apache-mina.10907.n7.nabble.com/SSHD-Problems-with-SFTP-tp42625p44094.html
> Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
>
Re: SSHD Problems with SFTP
Posted by Stefan Mueller <st...@menten.com>.
Guillaume Nodet-3 wrote
> 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.
I am back to FTP/SFTP now. Sorry, that I switched so fast to another
project. Did you look at this or should I raise a JIRA?
--
View this message in context: http://apache-mina.10907.n7.nabble.com/SSHD-Problems-with-SFTP-tp42625p44094.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
Re: SSHD Problems with SFTP
Posted by Guillaume Nodet <gn...@apache.org>.
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 <st...@menten.com>:
> 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.
>