X-Git-Url: http://andersk.mit.edu/gitweb/nss_nonlocal.git/blobdiff_plain/25468b961ce1288b802ae075a80640e4c30ee375..23ca0ded6f524a412d868f5bdc5bd7c9b6b1cc4e:/nonlocal-passwd.c diff --git a/nonlocal-passwd.c b/nonlocal-passwd.c index 7529d9b..41ea498 100644 --- a/nonlocal-passwd.c +++ b/nonlocal-passwd.c @@ -25,18 +25,19 @@ #define _GNU_SOURCE + #include -#include -#include -#include -#include #include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include + #include "nsswitch-internal.h" #include "nonlocal.h" @@ -161,6 +162,7 @@ get_nonlocal_passwd(const char *name, struct passwd *pwd, char **buffer, } +static bool pwent_initialized = false; static service_user *pwent_startp, *pwent_nip; static void *pwent_fct_start; static union { @@ -185,9 +187,12 @@ _nss_nonlocal_setpwent(int stayopen) if (status != NSS_STATUS_SUCCESS) return status; - if (pwent_fct_start == NULL) + if (!pwent_initialized) { __nss_passwd_nonlocal_lookup(&pwent_startp, pwent_fct_name, &pwent_fct_start); + __sync_synchronize(); + pwent_initialized = true; + } pwent_nip = pwent_startp; pwent_fct.ptr = pwent_fct_start; return NSS_STATUS_SUCCESS; @@ -199,7 +204,7 @@ _nss_nonlocal_endpwent(void) enum nss_status status; const struct walk_nss w = { .lookup = &__nss_passwd_nonlocal_lookup, .fct_name = "endpwent", - .status = &status + .status = &status, .all_values = 1, }; const __typeof__(&_nss_nonlocal_endpwent) self = NULL;