views:

112

answers:

2

Does getpwnam respect /etc/nsswitch.conf?

The manpage for getpwnam states

The getpwnam() function returns a pointer to a structure containing the broken-out fields of the record in the password database (e.g., the local password file /etc/passwd, NIS, and LDAP) that matches the username name.

This leads me to believe that it should respect /etc/nsswitch.conf, iterating over whatever entries are listed for the passwd line (... but I have a bug report indicating that it's not behaving that way).

Edit: I found a 3c manpage that indicates that it does respect it, so now the question is under which operating systems is it supported

+1  A: 

Although it will normally respect /etc/nsswitch.conf (or whatever passwd-database selection mechanism the OS supports), on some systems this does not work if the application was statically linked. This is because the appropriate database library is dynamically loaded into the program.

mark4o
The static linking is a good point, although not applicable in my situation.
Kaleb Pederson
+1  A: 

It does respect /etc/nsswitch.conf under every operating system which is POSIX conform.

drhirsch