replace chdir with permission check on ftp_CWD #661
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.
Perform directory permission check instead of
chdir, addressing #475 and #483 .An user of my application found that stressing pyftpdlib ftp_CWD calls can lead to race conditions ( https://gitlab.com/ergoithz/umftpd/-/issues/7 ) which shouldn't be theoretically possible using ioloop (might be a n issue in cpython), but regardless of the reason,
chdirbeing global is itself problematic, this PR addresses that.As a side note, the full POSIX equivalent to
os.chdirwould beos.close(os.open(path, os.R_OK | os.O_DIRECTORY)), but it's 2x slower and not portable, so I'm checking access and inode type instead (which isn't substantially slower thanos.chdirin my testing).