serve sftp: fix crash on unsupported operations (eg Readlink)

Before this change the sftp handler returned a nil error for unknown
operations which meant the server crashed when one was encountered.

In particular the "Readlink" operations was causing problems.

After this change the handler returns ErrSshFxOpUnsupported which
signals to the remote end that we don't support that operation.

See: https://forum.rclone.org/t/rclone-serve-sftp-not-working-in-windows/12209
This commit is contained in:
Nick Craig-Wood 2019-10-09 09:51:04 +01:00
parent 8950b586c4
commit 50a3a96e27

View File

@ -94,7 +94,7 @@ func (v vfsHandler) Filecmd(r *sftp.Request) error {
// link.symlink = r.Filepath
// v.files[r.Target] = link
}
return nil
return sftp.ErrSshFxOpUnsupported
}
type listerat []os.FileInfo
@ -150,5 +150,5 @@ func (v vfsHandler) Filelist(r *sftp.Request) (l sftp.ListerAt, err error) {
// }
// return listerat([]os.FileInfo{file}), nil
}
return nil, nil
return nil, sftp.ErrSshFxOpUnsupported
}