Kaleb Pederson
Kaleb Pederson

Reputation: 46479

Does getpwnam respect /etc/nsswitch.conf?

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

Upvotes: 1

Views: 915

Answers (2)

Gunther Piez
Gunther Piez

Reputation: 30449

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

Upvotes: 1

mark4o
mark4o

Reputation: 60923

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.

Upvotes: 2

Related Questions