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

Add initgroups support #26

Merged
merged 1 commit into from
Aug 11, 2021
Merged

Add initgroups support #26

merged 1 commit into from
Aug 11, 2021

Conversation

geofft
Copy link
Collaborator

@geofft geofft commented May 24, 2021

Apart from its own inherent value in rounding out user/group support,
glibc uses the same variable to cache whether the current NSCD
implementation handles group (GETGRBYNAME/GETGRBYGID) and INITGROUPS
requests, so we need to have a working implementation of it.

src/handlers.rs Outdated
let user = User::from_name(key.to_str()?)?;
debug!(log, "got user"; "user" => ?user);
let groups = if let Some(user) = user {
getgrouplist(key, user.gid)?
Copy link
Collaborator

Choose a reason for hiding this comment

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

the comment above says to always return success, but this line implies it bails early if something goes wrong. looks like nix adds a too-many-groups error condition, even though libc is never going to return an error.

https://docs.rs/nix/0.20.0/nix/unistd/fn.getgrouplist.html

Copy link
Collaborator

Choose a reason for hiding this comment

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

might be less confusing to pull this if/else into serialize_initgroups and change than fn so it takes the username and primary gid

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. I changed this specific line to log that error condition and return an empty list, and I expanded the comment to explain why we return an empty list.
  2. There are still error conditions in serialize_initgroups that we don't handle. It's potentially important that we don't drop the connection there. However, that's a problem for all of the serialize_ functions, i.e, I think we should consider teaching main() not to drop the connection but instead to provide some perfunctory reply and log what's going on, because all of those cases can cause glibc to decide that there isn't a working NSCD. I think that's for another PR, and we shouldn't special-case serialize_initgroups here. (I also think that several of these cases can be statically proven not to be problems, if we try harder, since they're integer conversions.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

However, that's a problem for all of the serialize_ functions, i.e, I think we should consider teaching main() not to drop the connection but instead to provide some perfunctory reply and log what's going on, because all of those cases can cause glibc to decide that there isn't a working NSCD. I think that's for another PR, and we shouldn't special-case serialize_initgroups here.

+1

@blinsay blinsay self-requested a review May 24, 2021 20:25
Apart from its own inherent value in rounding out user/group support,
glibc uses the same variable to cache whether the current NSCD
implementation handles group (GETGRBYNAME/GETGRBYGID) and INITGROUPS
requests, so we need to have a working implementation of it.
Copy link
Collaborator

@blinsay blinsay left a comment

Choose a reason for hiding this comment

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

this all lgtm

@geofft geofft merged commit 9d888a3 into main Aug 11, 2021
@flokli flokli mentioned this pull request Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants