Posts

Showing posts with the label glibc

Are multiple sources in nsswitch.conf merged for getpwent?

Image
Clash Royale CLAN TAG #URR8PPP Are multiple sources in nsswitch.conf merged for getpwent? Say I made a custom nss module called foo which defines abides by the required API: foo #include <nss.h> enum nss_status _nss_foo_getpwnam(const char *name, struct passwd *result, char *buf, size_t buflen, int *errnop); enum nss_status _nss_foo_getpwuid(uid_t uid, struct passwd *result, char *buf, size_t buflen, int *errnop); enum nss_status _nss_foo_setpwent(void); enum nss_status _nss_foo_getpwent(struct passwd *result, char *buf, size_t buflen, int *errnop); enum nss_status _nss_foo_endpwent(void); Assuming I have my nsswitch.conf setup like so: passwd: foo files It is clear from the standard that getpwnam() for user bar would first call my _nss_foo_getpwnam() and then if that returns NSS_STATUS_NOTFOUND , check /etc/passwd . However, the standard and behavior for [set|get|end]pwent() is a bit less clear to me. If I understand man 5 nsswitch.conf correctly, it sounds like this would...