commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Otto Fowler (JIRA)" <>
Subject [jira] [Commented] (VFS-651) SftpFileSystem Should not switch to root directory when not absolutely needed
Date Tue, 13 Feb 2018 23:30:00 GMT


Otto Fowler commented on VFS-651:

Are we sure that this is not working correctly?

Can you post a small snippet of code or a description of how you configure can connect?  And
what you are trying to do that does not work if you set it to true?

> SftpFileSystem Should not switch to root directory when not absolutely needed
> -----------------------------------------------------------------------------
>                 Key: VFS-651
>                 URL:
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Syed Aqeel Ashiq
>            Priority: Major
>             Fix For: 2.3
> Consider a user X only has read/write access to let's say /sftp and /sftp/abc directory
on a sftp server. And default directory for user is /sftp
> In this case, we have to set userDirIsRoot to false, and thus vfs will try to switch
to root directory, which will fail due to lack of read permission.
> This is the underlying code responsible in
> {code:java}
> org.apache.commons.vfs.provider.sftp.SftpFileSystem
> {code}
> :
> {code:java}
> Boolean userDirIsRoot = SftpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(getFileSystemOptions());
> String workingDirectory = getRootName().getPath();
> if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue()))
>     try {
>     } catch (SftpException e) {
>         throw new FileSystemException("vfs.provider.sftp/change-work-directory.error",
>     }
> }{code}
> It purposelessly switches to root directory of filesystem. There is a fair use-case that
root directory doesn't have read access.
> *Possible Fix:* It should not switch to root directory, rather it should switch to actual
final directory. This approach would be the safest. E.g. if the needed directory is '/sftp/abc'
then it can switch to that directory in above code, rather than switching to root.
> Please also see related SO question:

This message was sent by Atlassian JIRA

View raw message