X-Git-Url: http://andersk.mit.edu/gitweb/nss_nonlocal.git/blobdiff_plain/775f7dc3865d6ddfa74d88e77c132f78e0667ac9..4893970472bd815b8dbb6f6058dd26358700110e:/nonlocal-passwd.c diff --git a/nonlocal-passwd.c b/nonlocal-passwd.c index a401c49..f8e7f96 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; @@ -279,7 +284,7 @@ _nss_nonlocal_getpwnam_r(const char *name, struct passwd *pwd, if (status != NSS_STATUS_SUCCESS) return status; - if (check_nonlocal_gid(name, pwd->pw_gid, &group_errno) != + if (check_nonlocal_gid(name, NULL, pwd->pw_gid, &group_errno) != NSS_STATUS_SUCCESS) pwd->pw_gid = 65534 /* nogroup */; return NSS_STATUS_SUCCESS; @@ -316,7 +321,7 @@ _nss_nonlocal_getpwuid_r(uid_t uid, struct passwd *pwd, if (status != NSS_STATUS_SUCCESS) return status; - if (check_nonlocal_gid(pwd->pw_name, pwd->pw_gid, &group_errno) != + if (check_nonlocal_gid(pwd->pw_name, NULL, pwd->pw_gid, &group_errno) != NSS_STATUS_SUCCESS) pwd->pw_gid = 65534 /* nogroup */; return NSS_STATUS_SUCCESS;