uucore/entries: fix getgrouplist wrapper to handle a bug in macOS's getgrouplist implementation#2416
Merged
tertsdiepraam merged 1 commit intouutils:masterfrom Jun 16, 2021
Merged
Conversation
`getgrouplist` implementation * add documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While testing my PR for
id(#2361) I noticed that (although coreutils Testsuite passes forid) my tests on macOS return less groups than both GNU's coreutilsidand Darwin'sid:The first thing I saw is that in
uucore::entriesthe return value of the second call togetgrouplistwasn't handled and on macOS it is always -1. Then I did some digging and learned that this is a bug in Darwin's implementation ofgetgrouplistwheregetgrouplistdoesn't updatengroupsifngroupsis too small.First i thought the solution would be to query
libc::sysconfand then just use the run time value of_SC_NGROUPS_MAXforngroups. However, that turned out to be always 16, although the realngroupscould be much higher.So the only solution is to call
getgrouplistrepeatedly and to manually increasengroupsif not done so automatically bygetgrouplist.Note1: I checked and this solution is also done by gnulib
Note2: it's not enough to solely rely on the results from coreutils 8.32 Testsuite