I've tracked the "culprit" code to this method org.springframework.integration.file.remote.handler.FileTransferringMessageHandler#makeDirectories. For path "/target", the file will be appended with the separator "target/", that will processed then be processed, splitted in pathsToCreate, this list will contain two string "" and "target".
While this could be an improvement in JSCH, I think Spring should handle this case, as the XSD documentation says it is possible to have directories starting with a slash "/". Plus the fix is fairly easy in removing empty string from the list.
Affects: 2.2. GA
2 votes, 4 watchers
The text was updated successfully, but these errors were encountered:
FYI, this is only an issue if the top level directory does not exist on the server. The path can start with '/' if the top directory exists.
Also, most admins typically chroot sftp users so they can't browse the entire file system. In this case, the chrooted directory must be owned by root and not writable by the user so the top-level directory will always exist (so the user has a writeable directory).
When you are NOT chrooted, you typically wouldn't want to (and likely won't have permission to) create a top level directory in the root (/) of the file system.
So remote-directory="/home/ftptest/foobar" works fine (because /home/ftptest already exists) and remote-directory="foobar" works too because foobar is relative to /home/ftptest. Whereas remote-directory="/foobar" would fail due to permissions (even if we apply your suggested fix to avoid the exception).
I am not saying this isn't a bug, I just want to explain why this has not been discovered/reported sooner because, in practice, the top level directory usually already exists.
Brice Dutheil opened INT-2954 and commented
There is an exception thrown by JSCH if the remote-directory starts with a slash "/".
For example if the outbound adapter is configured in the following way, notice the "/target"
Then we'll have the following stacktrace:
I've tracked the "culprit" code to this method
org.springframework.integration.file.remote.handler.FileTransferringMessageHandler#makeDirectories
. For path "/target", the file will be appended with the separator "target/", that will processed then be processed, splitted inpathsToCreate
, this list will contain two string""
and"target"
.While this could be an improvement in JSCH, I think Spring should handle this case, as the XSD documentation says it is possible to have directories starting with a slash "/". Plus the fix is fairly easy in removing empty string from the list.
Affects: 2.2. GA
2 votes, 4 watchers
The text was updated successfully, but these errors were encountered: