Allow QUIT during an active transfer to defer until transfer completes #162
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.
I'm not sure if this is the ideal way to fix this issue, if it introduces other issues, or if the current behaviour is preferred by the developers.
The problem I am having is with blackbox firmware (Cisco IOS and other network vendors) pushing config to an FTP and expecting command pipelining to delay a QUIT until data transfers complete. They are simple clients that just blast commands and wait for sockets to close. Looking at RFC959, this is probably expected behaviour - it's not precisely stated. With current pure-ftpd, this results in aborting mid-transfer and truncated uploads.
My assumption on the RFC appears to be matched by a few other FTP daemons I checked (vsftpd, proftpd and pyftpdlib), only pure-ftpd treated a QUIT like an immediate ABOR.
This fix delays the reaction to a QUIT until all data transfers complete (an ABOR will still kill a transfer as expected), plus it will actually react like a QUIT and cleanup immediately on return to the parser loop, rather than waiting for the client to disconnect.
I've done some one-shot testing of this workaround patch against netkit ftp, ncftp, python 3.10 ftplib, winscp and the problem devices without issue.