Skip to content

Conversation

@Javex
Copy link

@Javex Javex commented Aug 23, 2025

Some FTP clients expect the server to indicate whether a file exists when they send the RNFR command. If it does, they expect a 350 (which currently happens). If it doesn't, the expect a 550 ("Requested action not taken") to indicate the file isn't available.

This adds this behaviour to the RNFR command and adds tests for both behaviours. I moved some functions from pass_security.rs to common.rs where I re-use them in the new tests.

I came across this because my scanner complained that the file I'm trying to scan already exists and I noticed it was sending RNFR and got confused by the 350 reply.

I decided to use the metadata command to check if a file exists since it seemed to be the best candidate. Please let me know if there's anything I can improve about the PR.

I ran make pr-prep, but I think the current failures are unrelated to my changes so I didn't fix them to keep the commit clean.

Some FTP clients expect the server to indicate whether a file exists
when they send the RNFR command. If it does, they expect a 350 (which
currently happens). If it doesn't, the expect a 550 ("Requested action
not taken") to indicate the file isn't available.

This adds this behaviour to the RNFR command and adds tests for both
behaviours. I moved some functions from pass_security.rs to common.rs
where I re-use them in the new tests.
Javex added a commit to Javex/ftp2webdav-rs that referenced this pull request Aug 24, 2025
In bolcom/libunftp#539 I've created PR that adds
behaviour to the RNFR command that is necessary for some FTP clients:
They use this command to check if a file exists, but the library always
returned a result that indicated that it did, even if the file didn't
exist.

I have a use case where my scanner uses FTP to upload scans, and it uses
this trick. If I try to scan a file it responds that the file already
exists, so the FTP server needs a new response code when the file
doesn't exist yet. With this patch applied, it works. Once the change
has been merged, the patch can be removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant