Skip to content

Conversation

artembilan
Copy link
Member

Fixes #3969

In previous version for SFTP client (Jsch), the empty path for LS command has meant a user home.
Turns out the MINA SftpClient does not support automatic user home resolution from the empty path.

  • Fix SftpSession to resolve an empty path into a user home via canicalPath() operation

Fixes spring-projects#3969

In previous version for SFTP client (Jsch), the empty path for `LS` command
has meant a `user home`.
Turns out the MINA `SftpClient` does not support automatic user home resolution
from the empty path.

* Fix `SftpSession` to resolve an empty path into a user home via `canicalPath()` operation
remoteDir = remotePath;
}
}
remoteDir = remoteDir.length() == 0 ? this.sftpClient.canonicalPath("") : remoteDir;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this works, I wonder if the intent would be clearer with this...

Suggested change
remoteDir = remoteDir.length() == 0 ? this.sftpClient.canonicalPath("") : remoteDir;
remoteDir = remoteDir.length() == 0 ? this.sftpClient.canonicalPath(".") : remoteDir;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, Gary: even if my tests against MINA confirms that . is resolved to the user home, it was a reason before with Jsch to have it as an empty string.
BTW, the Jsch client does this: byte[] _home=_realpath("");. So, it is really an empty string for user home request. 🤷
See their ChannelSftp.getHome()

@garyrussell garyrussell merged commit 1c836f0 into spring-projects:main Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No remote path exception when upgrading to Spring Integration Sftp 6.0

2 participants