mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-21 15:10:23 +00:00
sftpfs: map path resolution error to permission denied
This commit is contained in:
parent
27b5f1bf59
commit
ca464b5ffc
1 changed files with 5 additions and 2 deletions
|
@ -455,6 +455,9 @@ func (*SFTPFs) IsNotExist(err error) bool {
|
||||||
// IsPermission returns a boolean indicating whether the error is known to
|
// IsPermission returns a boolean indicating whether the error is known to
|
||||||
// report that permission is denied.
|
// report that permission is denied.
|
||||||
func (*SFTPFs) IsPermission(err error) bool {
|
func (*SFTPFs) IsPermission(err error) bool {
|
||||||
|
if _, ok := err.(*pathResolutionError); ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
return os.IsPermission(err)
|
return os.IsPermission(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,11 +615,11 @@ func (fs *SFTPFs) isSubDir(name string) error {
|
||||||
}
|
}
|
||||||
if len(name) < len(fs.config.Prefix) {
|
if len(name) < len(fs.config.Prefix) {
|
||||||
err := fmt.Errorf("path %#v is not inside: %#v", name, 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+"/") {
|
if !strings.HasPrefix(name, fs.config.Prefix+"/") {
|
||||||
err := fmt.Errorf("path %#v is not inside: %#v", 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue