On Fri, Jul 24, 2009 at 11:32:59PM +0200, Matthias Kilian wrote: > The portable way would be to enlarge the buffer and retry whenever > you get ERANGE. I ran into this problem several weeks ago for GHC > (and a diff doing the try/enlarge/retry-game had been accepted > upstream). IIRC, there even was some #ifdef'ing around that already > increased the buffer especially for OpenBSD,
To clarify, read: increased the *statically sized buffer* especially for OpenBSD. >From libraries/unix/System/Posix/Unix.hsc (as in ghc-6.10): #if defined(HAVE_SYSCONF) && defined(HAVE_SC_GETGR_R_SIZE_MAX) grBufSize = sysconfWithDefault 2048 (#const _SC_GETGR_R_SIZE_MAX) #else grBufSize = 2048 -- just assume some value (1024 is too small on OpenBSD) #endif Anyway, on an OS without any limit on possible group members, no constant value nor any value returned by sysconf(3) is guaranteed to be large enough for getgrnam_r(3). Ciao, Kili