Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not following symlinks in File.exists? and File.chmod #13291

Open
HertzDevil opened this issue Apr 5, 2023 · 1 comment
Open

Not following symlinks in File.exists? and File.chmod #13291

HertzDevil opened this issue Apr 5, 2023 · 1 comment

Comments

@HertzDevil
Copy link
Contributor

File.exists? and File.chmod are two methods that always dereference symlinks; when File.readlink was implemented on Windows, those two methods call Crystal::System::File.realpath internally to match the default behavior of the equivalent POSIX implementations. They should support the follow_symlinks parameter, which requires additional work for Unix-like systems:

  • I believe File.exists? requires using lstat instead of access
  • For File.chmod, fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW) ignores symlinks
@HertzDevil
Copy link
Contributor Author

HertzDevil commented Apr 21, 2024

Same goes for .readable?, .writable?, and .executable? actually, which are all currently variants of .exists?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant