Serve ftp, --passive-port validity check?

What is the problem you are having with rclone?

I'm running rclone as a service with NSSM. I'd been trying to figure out why it would only work when run from powershell, not NSSM or cmd. While writing all this out I've realised it's down to the single quotes around the port range. Without the quotes it works fine everywhere. Should this be checking for a valid port range at start? It seems to accept any random string and then only fails when a client tries to connect. With complete nonsense in there it at least gives the error "empty port" when a client connects but with a valid port range in single quotes there's no error shown unless -v is set.

What is your rclone version (output from rclone version)

rclone v1.57.0

  • os/version: Microsoft Windows Server 2022 Standard 2009 (64 bit)
  • os/kernel: 10.0.20348.230 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.17.2
  • go/linking: dynamic
  • go/tags: cmount

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Microsoft Windows Server 2022 Standard 64 bit Server Core

Which cloud storage system are you using? (eg Google Drive)

OneDrive/Office365 SharePoint/Teams

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone.exe serve ftp aqscans: --user scans --pass hunter2 --addr 0.0.0.0:2121 --vfs-cache-mode full --passive-port '30000-30100' -vv --config C:\rclone\rclone.conf --log-file C:\rclone\rclone.log

The rclone config contents with secrets removed.

[aqteams]
type = onedrive
token = {"access_token":"abc123","expiry":"2021-11-12T10:40:15.9247315+10:30"}
drive_id = xyz987-
drive_type = documentLibrary

[aqscans]
type = alias
remote = aqteams:/General/Scans


A log from the command with the -vv flag

2021/11/11 17:34:38 DEBUG : rclone: Version "v1.57.0" starting with parameters ["C:\\rclone\\rclone\\rclone.exe" "serve" "ftp" "aqscans:" "--user" "scans" "--pass" "hunter2" "--addr" "0.0.0.0:2121" "--vfs-cache-mode" "full" "--passive-port" "'30000-30100'" "-vv" "--config" "C:\\rclone\\rclone.conf" "--log-file" "C:\\rclone\\rclone.log"]
2021/11/11 17:34:38 DEBUG : Creating backend with remote "aqscans:"
2021/11/11 17:34:38 DEBUG : Using config file from "C:\\rclone\\rclone.conf"
2021/11/11 17:34:38 DEBUG : Creating backend with remote "aqteams:/General/Scans"
2021/11/11 17:34:39 DEBUG : fs cache: renaming cache item "aqteams:/General/Scans" to be canonical "aqteams:General/Scans"
2021/11/11 17:34:39 DEBUG : fs cache: renaming cache item "aqscans:" to be canonical "aqteams:General/Scans"
2021/11/11 17:34:39 INFO  : One drive root 'General/Scans': poll-interval is not supported by this remote
2021/11/11 17:34:39 DEBUG : vfs cache: root is "C:\\Users\\scans\\AppData\\Local\\rclone"
2021/11/11 17:34:39 DEBUG : vfs cache: data root is "\\\\?\\C:\\Users\\scans\\AppData\\Local\\rclone\\vfs\\aqteams\\General\\Scans"
2021/11/11 17:34:39 DEBUG : vfs cache: metadata root is "\\\\?\\C:\\Users\\scans\\AppData\\Local\\rclone\\vfsMeta\\aqteams\\General\\Scans"
2021/11/11 17:34:39 DEBUG : Creating backend with remote "C:/Users/scans/AppData/Local/rclone/vfs/aqteams/General/Scans"
2021/11/11 17:34:39 DEBUG : fs cache: renaming cache item "C:/Users/scans/AppData/Local/rclone/vfs/aqteams/General/Scans" to be canonical "//?/C:/Users/scans/AppData/Local/rclone/vfs/aqteams/General/Scans"
2021/11/11 17:34:39 DEBUG : Creating backend with remote "C:/Users/scans/AppData/Local/rclone/vfsMeta/aqteams/General/Scans"
2021/11/11 17:34:39 DEBUG : fs cache: renaming cache item "C:/Users/scans/AppData/Local/rclone/vfsMeta/aqteams/General/Scans" to be canonical "//?/C:/Users/scans/AppData/Local/rclone/vfsMeta/aqteams/General/Scans"
2021/11/11 17:34:39 NOTICE: One drive root 'General/Scans': Serving FTP on 0.0.0.0:2121
2021/11/11 17:34:39 INFO  : : Rclone FTP Server listening on 2121
2021/11/11 17:34:39 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: Connection Established
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: < 220 Welcome to Rclone v1.57.0 FTP Server
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: > USER scans
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: < 331 User name ok, password required
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: > PASS ****
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: < 230 Password ok, continue
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: > PWD 
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: < 257 "/" is the current directory
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: > TYPE I
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: < 200 Type set to binary
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: > PASV 
2021/11/11 17:35:30 INFO  : 5f37228c1d7673c62f8b: Handler crashed with error: invalid argument to Intn
runtime/panic.go:1038
math/rand/rand.go:168
math/rand/rand.go:337
goftp.io/server@v0.4.1/core/conn.go:108
goftp.io/server@v0.4.1/core/socket.go:149
goftp.io/server@v0.4.1/core/cmd.go:700
goftp.io/server@v0.4.1/core/conn.go:217
goftp.io/server@v0.4.1/core/conn.go:145
runtime/asm_amd64.s:1581
2021/11/11 17:35:39 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2021/11/11 17:36:00 INFO  : 5f37228c1d7673c62f8b: > QUIT 
2021/11/11 17:36:00 INFO  : 5f37228c1d7673c62f8b: < 221 Goodbye
2021/11/11 17:36:00 INFO  : 5f37228c1d7673c62f8b: Connection Terminated

Yes an error would be nice here wouldn't it.

This is caused by CMD not understanding 'strings' and passing the string with the ' to rclone. You can see this in the rclone startup

"--passive-port" "'30000-30100'"

By the look of it passive ports is parsed by the FTP server library and it looks like it does a terrible job of it, just ignoring any errors in the parse.

I made rclone check the format here - can you give this a go?

v1.58.0-beta.5880.822c1bdf4.fix-ftp-serve-ports on branch fix-ftp-serve-ports (uploaded in 15-30 mins)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.