Subject: Re: getpw*_r standards
To: John Nemeth <>
From: Klaus Klein <>
List: current-users
Date: 04/10/2005 22:49:48
On Sun, Apr 10, 2005 at 12:21:30PM -0700, John Nemeth wrote:

> The POSIX definition of getpwnam_r is located here:
> At the above URL, there are no error codes listed that can be used to
> indicate the entry wasn't found.  The Solaris manpage says that in this
> case, it returns 0 and sets the result to NULL.  The NetBSD manpage
> doesn't specifically mention this case.  The NetBSD code returns ENOENT
> in this case.

> Is it standards compliant to return codes not mentioned
> in the standard?

Per se it is, as long it does not conflict with the standard.
However there's further details involved in this case.

> 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.

So yes, we should change the implementation, including the result
pointer location being set to NULL in the error (non-zero return)

Thanks for catching this!

- Klaus