Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Dec 2003 14:14:33 +1100
From:      Lachlan O'Dea <odela01@ca.com>
To:        "Jacques A. Vidrine" <nectar@FreeBSD.org>
Cc:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/60287: [patch] NSS does not handle NSS_STATUS_TRYAGAIN properly
Message-ID:  <778706BE-31D1-11D8-867A-000A95DBB47C@ca.com>
In-Reply-To: <20031218145453.GB35590@madman.celabo.org>
References:  <200312181414.hBIEENcW093868@freefall.freebsd.org> <20031218145453.GB35590@madman.celabo.org>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 19 Dec 2003, at 01:54, Jacques A. Vidrine wrote:

> Hi Lachlan,
>
> Thank you for your report!  I believe your analysis is correct.
>
> There is one subtlety that must also be resolved.  Within FreeBSD's
> nsswitch, one indicates that the given buffer is too small by setting
> errno to ERANGE and return RETURN.  The convention for GNU libc
> modules seems to be to set errno to ERANGE and return TRYAGAIN.
> Unfortunately, nss_ldap seems to do neither :-)  It does return
> TRYAGAIN, but it does not set errno, so one cannot distinguish between
> providing a too-small-buffer and, say, not enough heap memory.
>
> So, I believe I need to apply something approximating your patch,
> but also nss_ldap needs to be corrected to set ERANGE where
> appropriate.

Are you certain that the module should actually set errno? At the 
moment, nss_ldap does return ERANGE, but not in errno. In the LDAP 
case, getgrent seems to end up calling:

NSS_STATUS
_nss_ldap_getgrent_r (struct group *result,
                       char *buffer, size_t buflen, int *errnop)

In the buffer too small case, *errnop _is_ set to ERANGE. This ends up 
being checked by libc before it expands the buffer in getgr in 
getgrent.c.

In any case, I don't think my patch needs to be changed? I think you're 
saying that the errno code tells us why TRYAGAIN was returned. But 
regardless of why, TRYAGAIN implies that the operation can be, well, 
tried again. So we never want to set the terminate flag in the TRYAGAIN 
case, regardless of the errno value.

> P.S. If I cannot address this today, I'm afraid it will be early
> January before I get to it--- I'm leaving home early tomorrow and
> won't be back until then.

Okally-dokally. Thanks!

- --
Lachlan O'Dea
Computer Associates
Programmer
tel: +61 3 8416 5627
fax: +61 3 8416 5810
mobile: +61 412 390 650
odela01@ca.com

Relax and enjoy your shoes!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQE/4m0ZoBZahcUBONoRAv8JAJwOKOWRWJ6xh5IVlrhx07EknzPfhgCgjiCf
f93pzISGJHeDQC5tzIIRu0s=
=OElB
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?778706BE-31D1-11D8-867A-000A95DBB47C>