Add setfsuid and setfsgid implementation for filesystem checks#1163
Add setfsuid and setfsgid implementation for filesystem checks#1163bors[bot] merged 1 commit intonix-rust:masterfrom
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 |
asomers
left a comment
There was a problem hiding this comment.
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 |
| // 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.
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.
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. |
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 <gliderkite@gmail.com>
Build failed |
|
That failure happened deep within libstd. Perhaps a QEMU bug? bors retry |
Build succeeded |
I noticed that the filesystem checks API
setfsuidandsetfsgidwhere missing (while available inlibc). This PR adds the implementation for both of them.