From ca464b5ffcc1197a9d8d3d84a378fc5cb5b40cd7 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sat, 16 Oct 2021 10:52:19 +0200 Subject: [PATCH] sftpfs: map path resolution error to permission denied --- vfs/sftpfs.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vfs/sftpfs.go b/vfs/sftpfs.go index 813e2e61..56ae8bb0 100644 --- a/vfs/sftpfs.go +++ b/vfs/sftpfs.go @@ -455,6 +455,9 @@ func (*SFTPFs) IsNotExist(err error) bool { // IsPermission returns a boolean indicating whether the error is known to // report that permission is denied. func (*SFTPFs) IsPermission(err error) bool { + if _, ok := err.(*pathResolutionError); ok { + return true + } return os.IsPermission(err) } @@ -612,11 +615,11 @@ func (fs *SFTPFs) isSubDir(name string) error { } if len(name) < len(fs.config.Prefix) { err := fmt.Errorf("path %#v is not inside: %#v", name, fs.config.Prefix) - return err + return &pathResolutionError{err: err.Error()} } if !strings.HasPrefix(name, fs.config.Prefix+"/") { err := fmt.Errorf("path %#v is not inside: %#v", name, fs.config.Prefix) - return err + return &pathResolutionError{err: err.Error()} } return nil }