From 98fd00a655cada0bda53b7be3d54dd656a8ab21c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 4 Aug 2022 16:11:22 +0100 Subject: [PATCH] serve sftp: fix checksum detection - Fixes #6351 Before this change, rclone serve sftp operating with a new rclone after the md5sum/sha1sum detection was reworked to just run a plain `md5sum`/`sha1sum` command in 3ea82032e796d1f1 sftp: support md5/sha1 with rsync.net #3254 Failed to signal to the remote that md5sum/sha1sum wasn't supported as in 71e172a139f00291 serve/sftp: support empty "md5sum" and "sha1sum" commands We unconditionally return good hashes even if the remote being served doesn't support the hash type in question. This fix checks the hash type is supported and returns an error MD5 hash not supported When the backend is first contacted this will cause the sftp backend to detect that the hash type isn't available. Unfortunately this may have cached the wrong state so editing or remaking the config may be necessary to fix it. --- cmd/serve/sftp/connection.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/serve/sftp/connection.go b/cmd/serve/sftp/connection.go index d8be2bce5..d9eaf855d 100644 --- a/cmd/serve/sftp/connection.go +++ b/cmd/serve/sftp/connection.go @@ -101,6 +101,9 @@ func (c *conn) execCommand(ctx context.Context, out io.Writer, command string) ( if binary == "sha1sum" { ht = hash.SHA1 } + if !c.vfs.Fs().Hashes().Contains(ht) { + return fmt.Errorf("%v hash not supported", ht) + } var hashSum string if args == "" { // empty hash for no input