Date: Fri, 4 Jul 2014 18:20:24 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Dmitry Sivachenko <trtrmitya@gmail.com> Cc: freebsd-standards@freebsd.org Subject: Re: About sysconf(_SC_GETPW_R_SIZE_MAX) Message-ID: <20140704152024.GI93733@kib.kiev.ua> In-Reply-To: <5EA35BF7-3984-4FD4-B523-9767E142475A@gmail.com> References: <DDC4C361-1C27-4913-91BB-1974AD1163A7@gmail.com> <20140704130017.GG93733@kib.kiev.ua> <5EA35BF7-3984-4FD4-B523-9767E142475A@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--XNnk+1bw058nV8qh Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 04, 2014 at 06:17:18PM +0400, Dmitry Sivachenko wrote: >=20 > On 04 =C9=C0=CC=D1 2014 =C7., at 17:00, Konstantin Belousov <kostikbel@gm= ail.com> wrote: >=20 > > On Fri, Jul 04, 2014 at 11:05:46AM +0400, Dmitry Sivachenko wrote: > >> Hello! > >>=20 > >> (FreeBSD-10/stable). > >>=20 > >> According to sysconf(3), _SC_GETPW_R_SIZE_MAX is the valid argument to= sysconf(): > >>=20 > >> _SC_GETPW_R_SIZE_MAX > >> Suggested initial value for the size of the password entry > >> buffer. > >>=20 > >> But the following test program fails: > >>=20 > >> #include <unistd.h> > >> #include <err.h> > >> #include <errno.h> > >> #include <stdio.h> > >>=20 > >> int main() { > >> int buf_sz; > >>=20 > >> errno=3D0; > >> buf_sz =3D sysconf(_SC_GETPW_R_SIZE_MAX); > >> printf("%d\n", buf_sz); > >> warn("sysconf: "); > >> return 0; > >> } > >>=20 > >> % ./a.out=20 > >> -1 > >> a.out: sysconf: : Invalid argument > >>=20 > >>=20 > >> What is wrong? > >=20 > > From lib/libc/gen/sysconf.c, around line 327: > > #if _POSIX_THREAD_SAFE_FUNCTIONS > -1 > > case _SC_GETGR_R_SIZE_MAX: > > case _SC_GETPW_R_SIZE_MAX: > > #error "somebody needs to implement this" > > #endif >=20 >=20 > May be remove these two from man page? I suppose it is better to implement them, trivially: diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index b7952b1..2b3acfb 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -367,11 +367,17 @@ yesno: * _POSIX_FILE_LOCKING, so we can't answer this one. */ #endif -#if _POSIX_THREAD_SAFE_FUNCTIONS > -1 + + /* + * SUSv4tc1 says the following about _SC_GETGR_R_SIZE_MAX and + * _SC_GETPW_R_SIZE_MAX: + * Note that sysconf(_SC_GETGR_R_SIZE_MAX) may return -1 if + * there is no hard limit on the size of the buffer needed to + * store all the groups returned. + */ case _SC_GETGR_R_SIZE_MAX: case _SC_GETPW_R_SIZE_MAX: -#error "somebody needs to implement this" -#endif + return (-1); case _SC_HOST_NAME_MAX: return (MAXHOSTNAMELEN - 1); /* does not include \0 */ case _SC_LOGIN_NAME_MAX: --XNnk+1bw058nV8qh Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJTtsY3AAoJEJDCuSvBvK1BFTAQAJHYHa1vZHcZ/BOiFsglakcS ok3A78UWTyWIP2Lxp4NCK0qwoQ6kABzN0GLhLzWGl6JNdAfxGr661KJhiZtOOlMM pc/1YF+5o8qmOChd+GHcYeLyNo1zrLMXPWf18ccmEOaDdwq7qfzXzGrzklZ5mnEm KI1YU8f526KOkC2Mh+tusZhLheffJZfGlzhJNSWHEiWcTwbInotzvGXUZtWn92iE 4fgV25idehTmOR787GhodzDZFq65tNISciU6g58o8XxUT/vDMGqCSjAwhK/s2HXD mIB8H5IV9EV9k/VVaXVmGk+aBjDq15u8dY1WvmNR4KIyJYX0Fsv0uv6UpSLuK4qh ysioxJO/U2iPooIQ8+elJ2OaoHtLBMnHE1w5czk+NwpnunlsVN3gggMZGc/DmS1j MeLfpsiSt1RiB7ZrqwOZtJbOTQuHylMsnnJb85LX2qNW5LvYmaab6TeTg6Qy9To+ d5F6KgujCeOl5PG40qAwCWmksiIJaST7UkpNa17eee28JNXfpqse5A0akvaikmMo h5ZkJDFXiHn3D70bhdaSqaTaCnVpVazHdVBvvy6rocPLHKAyZ/BoVvbMp103B7f8 97RtaoxLrcB1pZwM5vVce9xNCdv3wbLqchEgkcaDDQ7MAFX2DIF1M7/F0ZY3noZZ bzg8CNLP829zDMNjU812 =75Kl -----END PGP SIGNATURE----- --XNnk+1bw058nV8qh--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140704152024.GI93733>