sftpd: return sftp.ErrSSHFxNoSuchFile if the client ask the file for a missing path

some clients expected this error and not the generic one if the path is missing
This commit is contained in:
Nicola Murino
2019-11-14 14:18:43 +01:00
parent acdf351047
commit 08e85f6be9
4 changed files with 66 additions and 3 deletions

View File

@@ -220,7 +220,9 @@ func (c Connection) Filelist(request *sftp.Request) (sftp.ListerAt, error) {
c.Log(logger.LevelDebug, logSender, "requested list file for dir: %#v", p)
files, err := ioutil.ReadDir(p)
if err != nil {
if os.IsNotExist(err) {
return nil, sftp.ErrSSHFxNoSuchFile
} else if err != nil {
c.Log(logger.LevelError, logSender, "error listing directory: %#v", err)
return nil, sftp.ErrSSHFxFailure
}