Skip to content

Commit

Permalink
instead of switching use startdir like a chroot jail in case of VirtFS
Browse files Browse the repository at this point in the history
  • Loading branch information
lmagyar committed Jun 3, 2024
1 parent 0dcd097 commit d502c3f
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.primftpd.filesystem;

import java.io.File;
import java.nio.file.Paths;

import org.primftpd.services.PftpdService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -50,12 +53,8 @@ public MinaType getFile(String file) {
return createFile(absoluteVirtualPath, null, true, pftpdService);
} else if (absoluteVirtualPath.startsWith("/" + PREFIX_FS)) {
String realPath = toRealPath(absoluteVirtualPath, "/" + PREFIX_FS);
realPath = Paths.get(pftpdService.getPrefsBean().getStartDir().getAbsolutePath(), realPath).toString();
logger.debug("Using FS '{}' for '{}'", realPath, absoluteVirtualPath);
if ("/".equals(realPath)) {
realPath = pftpdService.getPrefsBean().getStartDir().getAbsolutePath();
absoluteVirtualPath = "/" + PREFIX_FS + realPath;
logger.debug(" switching to FS default dir: '{}'", absoluteVirtualPath);
}
AbstractFile delegate = fsFileSystemView.getFile(realPath);
return createFile(absoluteVirtualPath, delegate, pftpdService);
} else if (absoluteVirtualPath.startsWith("/" + PREFIX_ROOT)) {
Expand Down

0 comments on commit d502c3f

Please sign in to comment.