Skip to content

Conversation

@ergoithz
Copy link

@ergoithz ergoithz commented Jun 11, 2025

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, chdir being global is itself problematic, this PR addresses that.

As a side note, the full POSIX equivalent to os.chdir would be os.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 than os.chdir in my testing).

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