JSCH (SFTP) fails on change dir on sub folders level (second level) -
jsch's sftp channel fails change directory when previous directory not in root directory (ftp home). happens on sftp servers , not of them.
for example directory structure this:
- /
- level-1
- level-2
- level-2
- level-1
cd level-1
(ok)
cd level-2
(fails)
it throws exception this
4: folder not found: /level-1/level-2 @ com.jcraft.jsch.channelsftp.throwstatuserror(channelsftp.java:2569) @ com.jcraft.jsch.channelsftp._realpath(channelsftp.java:2100) @ com.jcraft.jsch.channelsftp.cd(channelsftp.java:315)
the sftp server error returns /
realpath root. other server didn't fail returns full path list /usr/account
.
i found source code jsch 0.1.49 , traced it. found out there method named _realpath throws exception when server fails return realpath. input parameter method absolute path of remote folder commented exception out , instead returned absolute path. works fine.
this modified code. note original code works of time , change made rare situation server fails return realpath on second level directory (sub folders), , there no guarantee works servers.
//com.jcraft.jsch.channelsftp private byte[] _realpath(string path) throws ... { ... if (type == ssh_fxp_status) { = buf.getint(); /* servers fail return realpath on second level of directory (subfolders). original code commented out , replaced return.*/ //throwstatuserror(buf, i); return (path.getbytes()); } ...
Comments
Post a Comment