Implement 550 for RNFR command#539
Merged
Merged
Conversation
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.
Collaborator
|
Thank you Javex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.