Skip to content

FS Does not support secure directory streams & NOFOLLOW_LINKS on IBM i #742

@Stefan4112

Description

@Stefan4112

Version

2.12.1

Bug description

The new WinSCP client version 6.5 sends the FileAttribute "size" when opening a file. This leads to following Exception:

java.lang.UnsupportedOperationException: FS Does not support secure directory streams.
	at org.apache.sshd.sftp.server.SftpFileSystemAccessor.secure(SftpFileSystemAccessor.java:593)
	at org.apache.sshd.sftp.server.SftpFileSystemAccessor.secureResolveDirectoryStream(SftpFileSystemAccessor.java:585)
	at org.apache.sshd.sftp.server.SftpFileSystemAccessor.seekableByteChannelNoLinkFollow(SftpFileSystemAccessor.java:565)
	at org.apache.sshd.sftp.server.SftpFileSystemAccessor.openFile(SftpFileSystemAccessor.java:217)
	at org.apache.sshd.sftp.server.AbstractSftpSubsystemHelper.setFileAttributes(AbstractSftpSubsystemHelper.java:2707)
	at org.apache.sshd.sftp.server.AbstractSftpSubsystemHelper.doSetAttributes(AbstractSftpSubsystemHelper.java:2671)
	at org.apache.sshd.sftp.server.FileHandle.<init>(FileHandle.java:94)
	at org.apache.sshd.sftp.server.SftpSubsystem.doOpen(SftpSubsystem.java:968)
	at org.apache.sshd.sftp.server.AbstractSftpSubsystemHelper.doOpen(AbstractSftpSubsystemHelper.java:496)
	at org.apache.sshd.sftp.server.AbstractSftpSubsystemHelper.doProcess(AbstractSftpSubsystemHelper.java:353)
	at org.apache.sshd.sftp.server.SftpSubsystem.doProcess(SftpSubsystem.java:355)
	at org.apache.sshd.sftp.server.AbstractSftpSubsystemHelper.process(AbstractSftpSubsystemHelper.java:344)
	at org.apache.sshd.sftp.server.SftpSubsystem.run(SftpSubsystem.java:331)

I identified the problem in org.apache.sshd.sftp.server.FileHandle.java

SftpFileSystemAccessor accessor = subsystem.getFileSystemAccessor();
SeekableByteChannel channel;
try {
    channel = accessor.openFile(
            subsystem, this, file, handle, openOptions, fileAttrs);
} catch (UnsupportedOperationException e) {
    channel = accessor.openFile(
            subsystem, this, file, handle, openOptions, IoUtils.EMPTY_FILE_ATTRIBUTES);
    subsystem.doSetAttributes(SftpConstants.SSH_FXP_OPEN, "", file, attrs, false);
}

Actual behavior

  1. The first accessor.openFile(...) throws an exception that is not shown in log
  2. Second accessor.openFile(...) creates file, but subsystem.doSetAttributes(...) throws Exception "FS Does not support secure directory streams", because followLinks is hard-coded to false and not supported on IBM i.

Expected behavior

  1. Show the exception on debug/trace log
  2. Do not use followLinks=false if it can lead to problems. A fallback as it is mentioned before the exception. Or maybe some way to configure it?

Relevant log output

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    sftp_3.0SFTP issues planned to be fixed in version 3.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions