On Thu, Aug 18, 2011 at 3:36 PM, Tim van der Molen <tb...@xs4all.nl> wrote: > When run without root privileges, getpwent(), getpwnam() and friends > always set errno, even if they succeed. Because of this, it is > impossible to distinguish between true errors (for which errno should be > set) and conditions like "end of database" and "no such user" (for which > errno should not be set). > > The problem is caused by __initdb() in lib/libc/gen/getpwent.c. It first > tries to open /etc/spwd.db. If that fails, it tries /etc/pwd.db. Opening > /etc/spwd.db always fails for non-root users and this causes errno to be > set. > > The simplest solution is to save the original errno value before > attempting to open the password databases and then restore it when > either database has been opened successfully.
Committed (though I changed the temp variable name to "saved_errno" as that's used in other parts of the get*ent.c code). Thanks! Philip Guenther