-
Notifications
You must be signed in to change notification settings - Fork 677
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
Add setfsuid and setfsgid implementation for filesystem checks #1163
Conversation
According to the man page, those syscalls are obsolete. Do you have an actual use case for them? If not, then we should reject this PR in the interest of resisting bloat. |
As far as I understand the note you are referring to:
states that I have a specific use case for this, that is I need to be able to check filesystem permissions per thread, and using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that sounds like a reasonable use case. Could you please add a test and a CHANGELOG entry?
I added a new entry in the changelog, but regarding the tests I'm not sure what tests would you like to see. I couldn't find any test for any equivalent function such as |
Anything that minimally exercises those syscalls. For example, creating a thread, setting its fs uid to nobody, and verifying that it gets EACCES when trying to read a 640 file. |
I added the test, but it fails on CI. At the moment I can only test it locally using |
src/unistd.rs
Outdated
// spawn a new thread where to test setfsuid | ||
thread::spawn(move || { | ||
// set filesystem UID | ||
let _ = setfsuid(nobody.uid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To determine success, you should follow the procedure described in the man page. Call setfsuid(-1)
and check whether the fsuid was actually changed. I suspect that when running on Travis, it won't be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an assertion for the fsuid change.
It looks like it failed on nightly the second run, where the first run passed and the only change only included the changelog. Could you please have a look @asomers? |
It looks like a new Rust nightly has added some lints. I'll fix this in a separate PR, then you can rebase. |
Actually, it looks like the failures were due to a bug in the compiler. I just restarted the build, it used a newer compiler version than the previous build (nightly-2020-02-28 vs nightly-2020-02-27), and it passed this time. |
Please squash your commits. Then I'll merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
1163: Add setfsuid and setfsgid implementation for filesystem checks r=asomers a=gliderkite I noticed that the filesystem checks API `setfsuid` and `setfsgid` where missing (while available in `libc`). This PR adds the implementation for both of them. Co-authored-by: Marco Conte <[email protected]>
Build failed |
That failure happened deep within libstd. Perhaps a QEMU bug? bors retry |
Build succeeded |
I noticed that the filesystem checks API
setfsuid
andsetfsgid
where missing (while available inlibc
). This PR adds the implementation for both of them.