sftpfs: map path resolution error to permission denied

we do the same for os fs so that the problematic directory is excluded
from the webdav listing instead of failing the whole directory listing
This commit is contained in:
Nicola Murino
2021-10-16 10:32:18 +02:00
parent a80ac80fcd
commit 4a6a4ce28d
5 changed files with 20 additions and 16 deletions

View File

@@ -427,6 +427,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)
}
@@ -584,11 +587,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
}