[
https://issues.apache.org/jira/browse/SSHD-825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16490587#comment-16490587
]
Guillaume Nodet commented on SSHD-825:
--------------------------------------
What about the following patch:
{code:java}
diff --git
a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
index 5b809a5e..369d1b20 100644
---
a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
+++
b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
@@ -35,7 +35,6 @@ import java.nio.file.NotDirectoryException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
@@ -145,7 +144,7 @@ public class SftpSubsystem
protected Future<?> pendingFuture;
protected byte[] workBuf = new byte[Math.max(DEFAULT_FILE_HANDLE_SIZE,
Integer.BYTES)];
protected FileSystem fileSystem = FileSystems.getDefault();
- protected Path defaultDir =
fileSystem.getPath(System.getProperty("user.dir"));
+ protected Path defaultDir =
fileSystem.getPath("").toAbsolutePath().normalize();
protected int version;
protected ServerSession serverSession;
@@ -236,11 +235,7 @@ public class SftpSubsystem
public void setFileSystem(FileSystem fileSystem) {
if (fileSystem != this.fileSystem) {
this.fileSystem = fileSystem;
-
- Iterable<Path> roots =
Objects.requireNonNull(fileSystem.getRootDirectories(), "No root directories");
- Iterator<Path> available =
Objects.requireNonNull(roots.iterator(), "No roots iterator");
- ValidateUtils.checkTrue(available.hasNext(), "No available root");
- this.defaultDir = available.next();
+ this.defaultDir =
fileSystem.getPath("").toAbsolutePath().normalize();
}
}
{code}
This default directory for the SftpSubsystem would default to the default
directory of the FileSystem. You would still have to implement a custom
FileSystemFactory, but this would be easier to figure out imho.
Toughts ?
> Add support for non-chrooted SFTP users with a virtual filesystem
> -----------------------------------------------------------------
>
> Key: SSHD-825
> URL: https://issues.apache.org/jira/browse/SSHD-825
> Project: MINA SSHD
> Issue Type: Improvement
> Affects Versions: 1.7.0
> Reporter: Quinn Stevenson
> Priority: Minor
> Fix For: 2.0.0
>
>
> When the SshServer is configured for SFTP with a VirtualFileSystemFactory,
> the user is always chrooted to either the defaultHomeDir or the specific
> homeDir for the user.
> However, in order to simulate systems that are configured such that users are
> not chrooted, there should be a way to configure the system with a virtual
> root and a home directory for the use in that virtual root that is also the
> initial directory for the user when they login.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)