I use maven wagon ssh/sftp. When ChannelSftp.cd() is called with a directory that is not (yet) present on the server, the ChannelSftp._realpath() method throws an exception with id=0, message=Success
The response header type is SSH_FXP_STATUS.
I'm using JSch 0.1.41
I'm not quite sure, if this is adhering to the protocol or a problem on the server side. I do not know which server is used.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2009-02-27
The supplied patch interprets the 0/Success according to the general rfc section:
"When the operation is successful, and no data needs to be returned, the SSH_FXP_STATUS response with SSH_FX_OK status is appropriate."
.. and just returns the path passed to the method - afterwards, the cd methods makes a stat on the path anyway so this can't do much harm.
I use maven wagon ssh/sftp. When ChannelSftp.cd() is called with a directory that is not (yet) present on the server, the ChannelSftp._realpath() method throws an exception with id=0, message=Success
The response header type is SSH_FXP_STATUS.
I'm using JSch 0.1.41
I'm not quite sure, if this is adhering to the protocol or a problem on the server side. I do not know which server is used.
The supplied patch interprets the 0/Success according to the general rfc section:
"When the operation is successful, and no data needs to be returned, the SSH_FXP_STATUS response with SSH_FX_OK status is appropriate."
.. and just returns the path passed to the method - afterwards, the cd methods makes a stat on the path anyway so this can't do much harm.
--- ./ChannelSftp.java.orig 2009-02-27 00:19:48.000000000 +0100
+++ ./ChannelSftp.java 2009-02-27 02:10:52.000000000 +0100
@@ -1804,7 +1804,8 @@
}
private byte[] _realpath(String path) throws SftpException, IOException, Exception{
- sendREALPATH(Util.str2byte(path, fEncoding));
+ byte[] pathByte = Util.str2byte(path, fEncoding);
+ sendREALPATH(pathByte);
Header header=new Header();
header=header(buf, header);
@@ -1819,7 +1820,11 @@
int i;
if(type==SSH_FXP_STATUS){
i=buf.getInt();
- throwStatusError(buf, i);
+ if(i==SSH_FX_OK){
+ return pathByte;
+ } else {
+ throwStatusError(buf, i);
+ }
}
i=buf.getInt(); // count