Subject: Re: getpw*_r standards
To: John Nemeth <jnemeth@victoria.tc.ca>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: current-users
Date: 04/10/2005 18:01:01
jnemeth@victoria.tc.ca (John Nemeth) writes:
> Any POSIX gurus here? I'm wondering about standards compliance.
> The POSIX definition of getpwnam_r is located here:
>
> http://www.opengroup.org/onlinepubs/009695399/functions/getpwnam.html
>
> At the above URL, there are no error codes listed that can be used to
> indicate the entry wasn't found.
RETURN VALUE
The getpwnam() function shall return a pointer to a struct passwd
with the structure as defined in <pwd.h> with a matching entry if
found. A null pointer shall be returned if the requested entry is
not found, or an error occurs. On error, errno shall be set to
indicate the error.
That second sentence says to me that "entry not found" is not an
error, so we're wrong, and that Solaris is doing the right thing. The
rest of the standards text seems to back up that idea - the bit about
having to set errno in advance if you want to check for an error is
key, since it indicates that returning-NULL-but-not-setting-errno is
valid behavior.
- Nathan