_SC_GETPW_R_SIZE_MAX undefined in sysconf.c, what is correct value?

Christopher J. Ruwe cjr at cruwe.de
Sun Oct 23 22:11:59 UTC 2011

I need to get the maximum size of an pwd-entry to determine the correct
buffersize for calling getpwnam_r("uname",&pwd, buf, bufsize, &pwdp). I
would like to use sysconf(_SC_GETPW_R_SIZE_MAX) to determine bufsize,
which unfornutately fails (returns -1). Currently, I used 16384, which
seems to be too much, bit works for the time being.

From recent mails I get that _SC_GETPW_R_SIZE_MAX is not available on FreeBSD, e.g., http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2009-September/173081.html and http://www.redhat.com/archives/libvir-list/2011-May/msg01013.html. This assertion seems to be backed by /usr/srclib/libc/gen/sysconf.c, line 374.

From Stevens & Rago, Adavanced Programming in the UNIX Environment, I can get that FreeBSD supports all possible members in the passwd structure, but where can I determine the maximum size of these so that I can calculate the ax size of the pwd struct therefrom? Does anybody know or know where to look what maximum size a pwd-entry can have? 

Knowing the maximum size a pwd structure can have, it seems like to be an idea to define the correct value in sysconf.c. As that is not done though suggested in the code, are there any obstacles in defining that value so nobody has done that so far?

Thanks for any help, cheers, 
Christopher J. Ruwe
TZ GMT + 2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20111023/3bceb32b/signature.pgp

More information about the freebsd-hackers mailing list