Does getpwnam respect /etc/nsswitch.conf?

856 views Asked by At

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

2

There are 2 answers

0
Gunther Piez On BEST ANSWER

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

1
mark4o On

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.