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

unistd: Increase maximum passwd/group buffer to 1MB #1409

Merged
merged 1 commit into from
Apr 4, 2021

Conversation

geofft
Copy link
Contributor

@geofft geofft commented Mar 25, 2021

We have one UNIX group that contains most of our users whose size is
about 20 kB, so Group::from_name is failing with ERANGE.

The discussion on PR #864 suggests that 1 MB is a reasonable maximum -
it follows what FreeBSD's libc does. (glibc appears to have no maximum
on the _r function and will just double the buffer until malloc fails,
but that's not particularly Rusty.)

@geofft
Copy link
Contributor Author

geofft commented Mar 25, 2021

Happy to add a changelog entry if this needs one.

Also, the way this code currently works is that if the platform supports sysconf(_GETPW_R_SIZE_MAX), it will use that as the initial buffer size, otherwise it will use the maximum. So on platforms without _GETPW_R_SIZE_MAX, we'll start out allocating a 1MB buffer. If that's unwanted, I can change it to default to start allocating a 16kB buffer, doubling until it hits 1MB.

Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

Yeah, we probably don't want to start out at 1MB. That could take a little bit of time to malloc.

We have one UNIX group that contains most of our users whose size is
about 20 kB, so `Group::from_name` is failing with ERANGE.

The discussion on PR nix-rust#864 suggests that 1 MB is a reasonable maximum -
it follows what FreeBSD's libc does. (glibc appears to have no maximum
on the _r function and will just double the buffer until malloc fails,
but that's not particularly Rusty.)
Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

bors r+

@bors bors bot merged commit c5d75b8 into nix-rust:master Apr 4, 2021
geofft added a commit to twosigma/nsncd that referenced this pull request Aug 15, 2021
This pulls in nix-rust/nix#1409 "unistd: Increase maximum passwd/group
buffer to 1MB".

The only breaking change that is relevant to us is that atoi now parses
minus signs by default, but that (oddly) appears to match glibc nscd's
behavior.

There are also some MSRV bumps. Don't update nix to the very latest
version to maintain MSRV <= 1.41 for compatibility with Debian Stretch
(see #29); the other updates aree fine.

Also run `cargo update` with 1.41, which removes the `version = 3`
marker from Cargo.lock.
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.

2 participants