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

Allow groups_exempted, groups_enforced versions of their gids_ counterparts #47

Closed
wants to merge 2 commits into from

Conversation

stouset
Copy link
Collaborator

@stouset stouset commented Jan 9, 2019

Closes #46.

Pushing the work so far, but I'll add tests when I have a moment.

fn groupname_to_gid(groupname: &str) -> Option<gid_t> {
unsafe {
let groupname_c = CString::new(groupname).ok()?;
let group = libc::getgrnam(groupname_c.as_ptr());
Copy link

Choose a reason for hiding this comment

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

You should only need to put the unsafe around the libc::getgrnam I believe--I think it's the only unsafe thing in this function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

getgrnam returns a struct group * (a pointer!) which we dereference with the unsafe method as_ref. But the CString part is safe, so we can pull it out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed!

Copy link

Choose a reason for hiding this comment

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

Clever! I like it.

@stouset stouset force-pushed the groupnames branch 4 times, most recently from 104ba40 to f43e566 Compare January 15, 2019 01:19
klieth
klieth previously approved these changes Jan 15, 2019
@stouset
Copy link
Collaborator Author

stouset commented Oct 5, 2021

Closing this due to lack of interest from the requesting party. I'm open to updating this and merging if someone else believes it would be useful.

@stouset stouset closed this Oct 5, 2021
@stouset stouset deleted the groupnames branch October 5, 2021 09:32
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.

Wishlist: resolve group names
2 participants