Skip to content

Fails with large groups #1572

@jethrogb

Description

@jethrogb

Describe the bug
When a group has a lot of members, sudo-rs doesn't work properly.

When sudo-rs tries to determine the gid of a named group, it calls getgrnam_r. It supplies a buffer of sysconf(_SC_GETGR_R_SIZE_MAX) or 16384 bytes. If that buffer is too small, getgrnam_r fails with ERANGE, and sudo-rs assumes the named group doesn't exist.

Expected behavior
sudo-rs should properly resolve group names for evaluating authorizations. Note that groups can have hundreds of thousands of members in large organizations.

Here's what the Linux man page for getgrnam_r states in relevant part:

The call

         sysconf(_SC_GETGR_R_SIZE_MAX)

returns either -1, without changing errno, or an initial suggested size for buf. (If this size is too small, the call fails with ERANGE, in which case the caller can retry with a larger buffer.)

If getgrnam_r returns ERANGE, sudo-rs should retry with increasingly large buffer sizes.

Environment (please complete the following information):
On my system, _SC_GETGR_R_SIZE_MAX is 1024 but I have a group entry of 1182 bytes.

Metadata

Metadata

Assignees

Labels

C-operatingsystemLow-level glue layersbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions