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

improve setgroups error message and inline documentation #129

Merged
merged 3 commits into from
Jan 18, 2025

Conversation

garlick
Copy link
Member

@garlick garlick commented Jan 18, 2025

The diod server, when mounted in access=user mode, uses a thread pool to service the requests from different users. Setting the user's credentials in each thread is tricky. The scheme for setting supplemental groups in this mode is fragile, but includes a runtime test that ensures its tenuous assumption still holds. When the test fails, the error message is not super helpful. Furthermore, when auditing this code, I found it to look a little scary at first and it took me a while to understand it. The comments were outdated and insufficient.

So this improves both the error message and the comments, plus tidies up some related stuff.

Problem: the code for setting supplemental groups under Linux seems
fragile at first glance.

It was carefully designed, but the code comments have not aged well.
Also, when the runtime check fails, the warning message is not very helpful.

Improve the warning message.
Improve the code comments.
Problem: on failure, the runtime test of SYS_setgroups replaces diod's
supplementary groups with the test ones.

Pass size=0 to getgroups() when testing the group count.
Problem: the diod server checks at runtime whether or not its supplemenatary
group switching strategy works with the kernel hosting the server, but we
also have a unit test that does the same on the build system.

It's a little pointless to test the build system.
Drop that test.
Copy link
Member

@grondo grondo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@garlick
Copy link
Member Author

garlick commented Jan 18, 2025

Thanks!

@mergify mergify bot merged commit 655a9fe into chaos:master Jan 18, 2025
5 checks passed
@garlick garlick deleted the setgroups branch January 18, 2025 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants