Skip to content

SftpInboundFileSynchronizer fails to synchronize files if the directory path is a symbolic link #9821

Closed
@jandurovec

Description

@jandurovec

In what version(s) of Spring Integration are you seeing this issue?

6.4.1

Describe the bug

After upgrading from previous version (as part of Spring Boot 2.x -> SpringBoot 3.x migration) SftpInboundFileSynchronizer stopped syncing the files. We have isolated the problem to be related to a situation where the directory to synchronize is a symlink (i.e. last element in the path is a symlink).

To Reproduce

  • Create /tmp/realdir on SFTP server and place a file (eg aaa.txt there)
  • Create /tmp/link on SFTP server as a symlink pointing to /tmp/realdir
  • Configure SftpInboundFileSynchronizer to synchronize the content of /tmp/link

Expected behavior

aaa.txt is downloaded from SFTP to local filesystem

Analysis

SftpInboundFileSynchronizer (via its parent AbstractInboundFileSynchronizer) calls list() method to retrieve the directory content

The problem is that SftpSession calls lstat on a file/directory and if it is not reported as a directory (which it isn't since it's a symbolic link), it fails silently and returns empty list.

SftpClient.Attributes attributes = this.sftpClient.lstat(path);
if (!attributes.isDirectory()) {
return Stream.of(new SftpClient.DirEntry(remoteFile, path, attributes));
}

I believe that SftpSession.doList(String path) method should call stat() instead of lstat() so that it resolves also symlinks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions