Repository: mina-sshd
Updated Branches:
  refs/heads/master 51822113d -> b3d255464


[SSHD-825] Use the filesystem default dir as the sftp subsystem default dir


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/b3d25546
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/b3d25546
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/b3d25546

Branch: refs/heads/master
Commit: b3d255464d25adee580a6e0184d9d734dd3238cb
Parents: 5182211
Author: Guillaume Nodet <gno...@apache.org>
Authored: Fri May 25 20:53:54 2018 +0200
Committer: Guillaume Nodet <gno...@apache.org>
Committed: Fri May 25 20:53:54 2018 +0200

----------------------------------------------------------------------
 .../apache/sshd/server/subsystem/sftp/SftpSubsystem.java    | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/b3d25546/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.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 5b809a5..369d1b2 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();
         }
     }
 

Reply via email to