From 2ac77ac001eb2affa9c77b962cd12e756dd61014 Mon Sep 17 00:00:00 2001 From: Laszlo Magyar Date: Sun, 2 Jun 2024 02:31:14 +0200 Subject: [PATCH] let all directory be readable if it is executable, revert using isExecutable in the server --- primitiveFTPd/src/org/primftpd/filesystem/FsSshFile.java | 5 +++++ .../src/org/apache/sshd/server/sftp/SftpSubsystem.java | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/primitiveFTPd/src/org/primftpd/filesystem/FsSshFile.java b/primitiveFTPd/src/org/primftpd/filesystem/FsSshFile.java index 5dbe3b4e..84473c2c 100644 --- a/primitiveFTPd/src/org/primftpd/filesystem/FsSshFile.java +++ b/primitiveFTPd/src/org/primftpd/filesystem/FsSshFile.java @@ -49,6 +49,11 @@ public SshFile getParentFile() { return new FsSshFile(file.getParentFile(), pftpdService, session); } + @Override + public boolean isReadable() { + return super.isReadable() || isDirectory() && isExecutable(); + } + @Override public boolean isExecutable() { logger.trace("[{}] isExecutable()", name); diff --git a/sshd-core-0.14.0/src/org/apache/sshd/server/sftp/SftpSubsystem.java b/sshd-core-0.14.0/src/org/apache/sshd/server/sftp/SftpSubsystem.java index 5d7c42e0..281fb7d2 100644 --- a/sshd-core-0.14.0/src/org/apache/sshd/server/sftp/SftpSubsystem.java +++ b/sshd-core-0.14.0/src/org/apache/sshd/server/sftp/SftpSubsystem.java @@ -689,7 +689,7 @@ protected void process(Buffer buffer) throws IOException { sendStatus(id, SSH_FX_NO_SUCH_FILE, path); } else if (!p.isDirectory()) { sendStatus(id, SSH_FX_NO_SUCH_FILE, path); - } else if (!p.isExecutable()) { + } else if (!p.isReadable()) { sendStatus(id, SSH_FX_PERMISSION_DENIED, path); } else { String handle = UUID.randomUUID().toString(); @@ -714,7 +714,7 @@ protected void process(Buffer buffer) throws IOException { sendStatus(id, SSH_FX_NO_SUCH_FILE, p.getFile().getAbsolutePath()); } else if (!p.getFile().isDirectory()) { sendStatus(id, SSH_FX_NO_SUCH_FILE, p.getFile().getAbsolutePath()); - } else if (!p.getFile().isExecutable()) { + } else if (!p.getFile().isReadable()) { sendStatus(id, SSH_FX_PERMISSION_DENIED, p.getFile().getAbsolutePath()); } else { DirectoryHandle dh = (DirectoryHandle) p;