-
Notifications
You must be signed in to change notification settings - Fork 186
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
File::Stat#executable?
returns true
when it shouldn't with root user
#2690
Comments
I cannot reproduce outside Docker:
|
But I can indeed reproduce with your instructions in Docker. In general I recommend trying outside Docker (e.g. use ruby-build to install truffleruby-dev), to avoid this root issue, it is quite different than what GitHub Actions does which does not use the root user. |
This is a bug we inherited from Rubinius: https://github.com/rubinius/rubinius/blob/b7a755c83f3dd3f0c1f5e546f0e58fb61851ea44/core/stat.rb#L158 @andrykonchin Could you fix this? BTW, |
File::Stat#executable?
returns true
when it shouldn't?File::Stat#executable?
returns true
when it shouldn't with root user
Actually access() might slower than stat(), b250992, but access/eaccess is convenient here to check the right bit for us, so we should check if that's faster than truffleposix_stat_mode() + checking the bits. Either should be faster than going through File::Stat. |
@eregon Yes, will work on it. |
It's interesting actually, root can read or write any file, but it can only execute a file if one of the executable bits is set (no matter if it's on the user and root does not own the file), from my reading of CRuby's code handling this. Regarding performance, it seems stat() is actually fastest on macOS like on Linux (compared to access/eaccess), probably due to being better cached. |
Fixed in 78264ff. Thank you for reporting. |
TruffleRuby
(Started with
docker run --rm -it -v $(pwd):/app -w /app ghcr.io/flavorjones/truffleruby:nightly-slim bash
, it saidDigest: sha256:97f4726094dee47d3e516c36f2bc0bf3980243017f0aa3d32fab4b1346e4f4ce
in the output)MRI
(
docker run --rm -it -v $PWD:/app -w /app ruby:3.0.3 bash
,Digest: sha256:7c57b474163e01f1518ff830dffef023fbd014378edd414526562137edc1400f
)The text was updated successfully, but these errors were encountered: