From 50a3a96e2784c1db762b0e3eb630af5764098a2b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 9 Oct 2019 09:51:04 +0100 Subject: [PATCH] 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 --- cmd/serve/sftp/handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/serve/sftp/handler.go b/cmd/serve/sftp/handler.go index 5e25d28c5..64d8d8b5e 100644 --- a/cmd/serve/sftp/handler.go +++ b/cmd/serve/sftp/handler.go @@ -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 }