Browse Source

sftpfs: map path resolution error to permission denied

Nicola Murino 3 years ago
parent
commit
ca464b5ffc
1 changed files with 5 additions and 2 deletions
  1. 5 2
      vfs/sftpfs.go

+ 5 - 2
vfs/sftpfs.go

@@ -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
 }
 }