X-Git-Url: http://andersk.mit.edu/gitweb/nss_nonlocal.git/blobdiff_plain/25468b961ce1288b802ae075a80640e4c30ee375..4893970472bd815b8dbb6f6058dd26358700110e:/nonlocal-group.c diff --git a/nonlocal-group.c b/nonlocal-group.c index 5b4dd7d..9bbe156 100644 --- a/nonlocal-group.c +++ b/nonlocal-group.c @@ -24,18 +24,20 @@ */ #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" @@ -169,6 +171,7 @@ get_local_group(const char *name, struct group *grp, char **buffer, int *errnop) return status; } +static bool grent_initialized = false; static service_user *grent_startp, *grent_nip; static void *grent_fct_start; static union { @@ -193,9 +196,12 @@ _nss_nonlocal_setgrent(int stayopen) if (status != NSS_STATUS_SUCCESS) return status; - if (grent_fct_start == NULL) + if (!grent_initialized) { __nss_group_nonlocal_lookup(&grent_startp, grent_fct_name, &grent_fct_start); + __sync_synchronize(); + grent_initialized = true; + } grent_nip = grent_startp; grent_fct.ptr = grent_fct_start; return NSS_STATUS_SUCCESS;