Subject: Re: getpw*_r standards
To: None <current-users@netbsd.org>
From: Christos Zoulas <christos@tac.gw.com>
List: current-users
Date: 04/10/2005 22:35:01
In article <20050411004037.GL27524@mewburn.net>,
Luke Mewburn  <lukem@NetBSD.org> wrote:
>-=-=-=-=-=-
>
>On Sun, Apr 10, 2005 at 10:49:48PM +0200, Klaus Klein wrote:
>  | > Should NetBSD code follow the Solaris way for maximum
>  | > portability?
>  | 
>  | The issue here is that the standard does distinguish between
>  | "successfully no entry found" and "an error caused no entry to be
>  | found", viz. "A NULL pointer shall be returned at the location pointed
>  | to by result on error _or_ if the requested entry is not found"
>  | (getpwnam_r, emphasis added by me).  Its wording is less concise
>  | for getpwnam, but comparing -current against 2.0 shows a regression
>  | in now setting errno to ENOENT in the former case.
>
>Please be more explicit, as it's unclear to me the context of
>"in the former case".
>
>2.0 doesn't have getpwnam_r().
>3 and -current do.
>AFAICT, Klaus & Nathan are recommending that getpwnam_r():
>    *	return 0 and set result to NULL for "notfound", and
>    *	return errno (!0) and set result to NULL for "error".
>If I have understood that correctly, we can change get{pw,gr}*_r()
>to do this.
>
>2.0's getpwnam() returns NULL in both the "not found" and "error"
>case, and in both cases errno is indeterminately set depending
>on what the back-end modules (files, nis, dns, ...) do.
>-current's getpwnam() has the same behaviour.
>
>
>  | So yes, we should change the implementation, including the result
>  | pointer location being set to NULL in the error (non-zero return)
>  | case.
>
>Once I understand exactly what you're asking to change,
>I'll change it ;-)
>

And I will fix userland... :-)

christos