From 23469c9c7ce464eb94b6a69550935e3bee7ff44e Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 4 Sep 2020 18:07:08 +0100 Subject: [PATCH] ftp: add --ftp-disable-msld option to ignore MLSD for really old servers This is useful for servers which advertise MLSD (eg some versions of Serv-U) but don't support it properly. See: https://forum.rclone.org/t/double-folder-names-on-target-destination-paths-ftp/18822 See: https://github.com/jlaffaye/ftp/pull/196 --- backend/ftp/ftp.go | 9 +++++++++ go.mod | 2 +- go.sum | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go index bfa0ee44f..f034d2346 100644 --- a/backend/ftp/ftp.go +++ b/backend/ftp/ftp.go @@ -85,6 +85,11 @@ to an encrypted one. Cannot be used in combination with implicit FTP.`, Help: "Disable using EPSV even if server advertises support", Default: false, Advanced: true, + }, { + Name: "disable_mlsd", + Help: "Disable using MLSD even if server advertises support", + Default: false, + Advanced: true, }, { Name: config.ConfigEncoding, Help: config.ConfigEncodingHelp, @@ -111,6 +116,7 @@ type Options struct { Concurrency int `config:"concurrency"` SkipVerifyTLSCert bool `config:"no_check_certificate"` DisableEPSV bool `config:"disable_epsv"` + DisableMLSD bool `config:"disable_mlsd"` Enc encoder.MultiEncoder `config:"encoding"` } @@ -226,6 +232,9 @@ func (f *Fs) ftpConnection() (*ftp.ServerConn, error) { if f.opt.DisableEPSV { ftpConfig = append(ftpConfig, ftp.DialWithDisabledEPSV(true)) } + if f.opt.DisableMLSD { + ftpConfig = append(ftpConfig, ftp.DialWithDisabledMLSD(true)) + } if fs.Config.Dump&(fs.DumpHeaders|fs.DumpBodies|fs.DumpRequests|fs.DumpResponses) != 0 { ftpConfig = append(ftpConfig, ftp.DialWithDebugOutput(&debugLog{auth: fs.Config.Dump&fs.DumpAuth != 0})) } diff --git a/go.mod b/go.mod index 701529ffb..12b7513be 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/google/go-querystring v1.0.0 // indirect github.com/hanwen/go-fuse/v2 v2.0.3 github.com/iguanesolutions/go-systemd/v5 v5.0.0 - github.com/jlaffaye/ftp v0.0.0-20201021201046-0de5c29d4555 + github.com/jlaffaye/ftp v0.0.0-20201112195030-9aae4d151126 github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect github.com/klauspost/compress v1.11.2 diff --git a/go.sum b/go.sum index 2648d2f98..c9d81869a 100644 --- a/go.sum +++ b/go.sum @@ -328,6 +328,8 @@ github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf/go.mod h1:lli8NYPQOFy3O++YmYbqVgOcQ1JPCwdOy+5zSjKJ9qY= github.com/jlaffaye/ftp v0.0.0-20201021201046-0de5c29d4555 h1:bd2tFFziQpwjrRcj7seCELvu08uplHN7Fs5t2/9kQNE= github.com/jlaffaye/ftp v0.0.0-20201021201046-0de5c29d4555/go.mod h1:2lmrmq866uF2tnje75wQHzmPXhmSWUt7Gyx2vgK1RCU= +github.com/jlaffaye/ftp v0.0.0-20201112195030-9aae4d151126 h1:ly2C51IMpCCV8RpTDRXgzG/L9iZXb8ePEixaew/HwBs= +github.com/jlaffaye/ftp v0.0.0-20201112195030-9aae4d151126/go.mod h1:2lmrmq866uF2tnje75wQHzmPXhmSWUt7Gyx2vgK1RCU= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=