sysconf(_SC_GETGR_R_SIZE_MAX) is just a hint for getgrnam_r()
When there is a group that has a lot of members, TestProcess#test_execopts_gid fails. Following is a more simple example:
$ ruby -e 'system("true", gid: "largegroup")' -e:1:in `system': Numerical result out of range - getgrnam_r (Errno::ERANGE) from -e:1:in `<main>'
This wrong exception happens because obj2gid() in process.c calls getgrnam_r() with a buffer that was allocated based on the size returned by sysconf(_SC_GETGR_R_SIZE_MAX). In Linux, sysconf(_SC_GETGR_R_SIZE_MAX) returns 1024, but actually this value is just a hint, so obj2gid() should gradually extend the buffer until getgrnam_r() no longer throws ERANGE.
The same issue was reported in the following page:
Updated by naruse (Yui NARUSE) over 8 years ago
Rei Odaira wrote:
but actually this value is just a hint, so obj2gid() should gradually extend the buffer until getgrnam_r() no longer throws ERANGE.
SuSv7 changes it.
- http://pubs.opengroup.org/onlinepubs/009695399/functions/getgrnam.html v6's getgrnam_r
- http://pubs.opengroup.org/onlinepubs/9699919799/functions/getgrnam.html v7's getgrnam_r
- http://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html v7's sysconf
SD5-XSH-ERN-166 is applied, changing "Maximum size" to "Initial size" for the "Maximum size of ..." entries in the table in the DESCRIPTION.
But I didn't find SD5-XSH-ERN-166 itself.
Updated by akr (Akira Tanaka) over 8 years ago
Yui NARUSE wrote:
SuSv7 changes it.
There is no Single Unix Specification version 7 (yet).
The issue number is not the version number.
| The Single UNIX Specification, Version 3 is made up of the Base Specifications, Issue 6 and
| X/Open Curses, Issue 4, Version 2.
| The Single UNIX Specification uses The Open Group Base Specifications, Issue 7 documentation as its core.
| The documentation is structured as follows:
| * The Base Specifications, Issue 7, composed of:
| - Base Definitions, Issue 7 (XBD7)
| - System Interfaces, Issue 7 (XSH7)
| - Shell and Utilities, Issue 7 (XCU7)
| - Rationale, Issue 7, (XRAT7) (Informative)
| * X/Open Curses, Issue 7
Updated by djberg96 (Daniel Berger) over 8 years ago
I don't think there's a way to get it. You'll have to rescue and retry with a realloc'ed buffer.
One bit of trickiness is that different platforms seem to set errno to different values on different platforms. In my own sys-admin gem, I caught Errno::ERANGE on Linux and Solaris, while on Darwin it was Errno::ENOENT, and on FreeBSD it was Errno::ENOTTY.
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100