Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

sftp: terminate the missing-ancestor permission walk at the root

Chris Lu6bac50684239
diff --git a/weed/sftpd/sftp_permissions.go b/weed/sftpd/sftp_permissions.go
index 8eea53f60a..1a32107839 100644
--- a/weed/sftpd/sftp_permissions.go
+++ b/weed/sftpd/sftp_permissions.go
@@ -67,6 +67,9 @@ func (fs *SftpServer) CheckFilePermission(path string, perm string) error {
// check permissions on the parent directory instead
if err == os.ErrNotExist {
parentPath := stdpath.Dir(path)
+ if parentPath == path {
+ return os.ErrPermission
+ }
// Check if user can write to the parent directory
return fs.CheckFilePermission(parentPath, perm)
}