1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

third_party: Update nss_wrapper to version 1.1.13

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Nov  9 23:15:07 UTC 2022 on sn-devel-184
This commit is contained in:
Andreas Schneider 2022-11-08 11:01:44 +01:00 committed by Andreas Schneider
parent 10537a89bb
commit 4a68d43b7b
3 changed files with 229 additions and 118 deletions

View File

@ -29,7 +29,7 @@ Build.BuildContext.CHECK_SOCKET_WRAPPER = CHECK_SOCKET_WRAPPER
@conf
def CHECK_NSS_WRAPPER(conf):
return conf.CHECK_BUNDLED_SYSTEM_PKG('nss_wrapper', minversion='1.1.12')
return conf.CHECK_BUNDLED_SYSTEM_PKG('nss_wrapper', minversion='1.1.13')
Build.BuildContext.CHECK_NSS_WRAPPER = CHECK_NSS_WRAPPER
@conf

View File

@ -177,17 +177,6 @@ typedef nss_status_t NSS_STATUS;
#define NWRAP_INET_ADDRSTRLEN INET_ADDRSTRLEN
#endif
#define NWRAP_LOCK(m) do { \
pthread_mutex_lock(&( m ## _mutex)); \
} while(0)
#define NWRAP_UNLOCK(m) do { \
pthread_mutex_unlock(&( m ## _mutex)); \
} while(0)
static pthread_mutex_t libc_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t nss_module_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER;
static bool nwrap_initialized = false;
static pthread_mutex_t nwrap_initialized_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -198,50 +187,49 @@ static pthread_mutex_t nwrap_he_global_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t nwrap_pw_global_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t nwrap_sp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
#define nss_wrapper_init_mutex(m) \
_nss_wrapper_init_mutex(m, #m)
/* Add new global locks here please */
/* Also don't forget to add locks to
* nwrap_init() function.
*/
# define NWRAP_REINIT_ALL do { \
int ret; \
ret = nss_wrapper_init_mutex(&nwrap_initialized_mutex); \
if (ret != 0) exit(-1); \
ret = nss_wrapper_init_mutex(&nwrap_global_mutex); \
if (ret != 0) exit(-1); \
ret = nss_wrapper_init_mutex(&nwrap_gr_global_mutex); \
if (ret != 0) exit(-1); \
ret = nss_wrapper_init_mutex(&nwrap_he_global_mutex); \
if (ret != 0) exit(-1); \
ret = nss_wrapper_init_mutex(&nwrap_pw_global_mutex); \
if (ret != 0) exit(-1); \
ret = nss_wrapper_init_mutex(&nwrap_sp_global_mutex); \
if (ret != 0) exit(-1); \
} while(0)
# define NWRAP_LOCK_ALL do { \
NWRAP_LOCK(libc_symbol_binding); \
NWRAP_LOCK(nss_module_symbol_binding); \
NWRAP_LOCK(nwrap_initialized); \
NWRAP_LOCK(nwrap_global); \
NWRAP_LOCK(nwrap_gr_global); \
NWRAP_LOCK(nwrap_he_global); \
NWRAP_LOCK(nwrap_pw_global); \
NWRAP_LOCK(nwrap_sp_global); \
nwrap_mutex_lock(&nwrap_initialized_mutex); \
nwrap_mutex_lock(&nwrap_global_mutex); \
nwrap_mutex_lock(&nwrap_gr_global_mutex); \
nwrap_mutex_lock(&nwrap_he_global_mutex); \
nwrap_mutex_lock(&nwrap_pw_global_mutex); \
nwrap_mutex_lock(&nwrap_sp_global_mutex); \
} while (0);
# define NWRAP_UNLOCK_ALL do {\
NWRAP_UNLOCK(nwrap_sp_global); \
NWRAP_UNLOCK(nwrap_pw_global); \
NWRAP_UNLOCK(nwrap_he_global); \
NWRAP_UNLOCK(nwrap_gr_global); \
NWRAP_UNLOCK(nwrap_global); \
NWRAP_UNLOCK(nwrap_initialized); \
NWRAP_UNLOCK(nss_module_symbol_binding); \
NWRAP_UNLOCK(libc_symbol_binding); \
nwrap_mutex_unlock(&nwrap_sp_global_mutex); \
nwrap_mutex_unlock(&nwrap_pw_global_mutex); \
nwrap_mutex_unlock(&nwrap_he_global_mutex); \
nwrap_mutex_unlock(&nwrap_gr_global_mutex); \
nwrap_mutex_unlock(&nwrap_global_mutex); \
nwrap_mutex_unlock(&nwrap_initialized_mutex); \
} while (0);
static void nwrap_init(void);
static void nwrap_thread_prepare(void)
{
nwrap_init();
NWRAP_LOCK_ALL;
}
static void nwrap_thread_parent(void)
{
NWRAP_UNLOCK_ALL;
}
static void nwrap_thread_child(void)
{
NWRAP_UNLOCK_ALL;
}
enum nwrap_dbglvl_e {
NWRAP_LOG_ERROR = 0,
NWRAP_LOG_WARN,
@ -1230,37 +1218,57 @@ static void *_nwrap_bind_symbol(enum nwrap_lib lib, const char *fn_name)
return func;
}
#define nwrap_mutex_lock(m) _nwrap_mutex_lock(m, #m, __func__, __LINE__)
static void _nwrap_mutex_lock(pthread_mutex_t *mutex, const char *name, const char *caller, unsigned line)
{
int ret;
ret = pthread_mutex_lock(mutex);
if (ret != 0) {
NWRAP_LOG(NWRAP_LOG_ERROR, "PID(%d):PPID(%d): %s(%u): Couldn't lock pthread mutex(%s) - %s",
getpid(), getppid(), caller, line, name, strerror(ret));
abort();
}
}
#define nwrap_mutex_unlock(m) _nwrap_mutex_unlock(m, #m, __func__, __LINE__)
static void _nwrap_mutex_unlock(pthread_mutex_t *mutex, const char *name, const char *caller, unsigned line)
{
int ret;
ret = pthread_mutex_unlock(mutex);
if (ret != 0) {
NWRAP_LOG(NWRAP_LOG_ERROR, "PID(%d):PPID(%d): %s(%u): Couldn't unlock pthread mutex(%s) - %s",
getpid(), getppid(), caller, line, name, strerror(ret));
abort();
}
}
#define nwrap_bind_symbol_libc(sym_name) \
NWRAP_LOCK(libc_symbol_binding); \
if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
_nwrap_bind_symbol(NWRAP_LIBC, #sym_name); \
} \
NWRAP_UNLOCK(libc_symbol_binding)
#define nwrap_bind_symbol_libc_posix(sym_name) \
NWRAP_LOCK(libc_symbol_binding); \
if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
_nwrap_bind_symbol(NWRAP_LIBC, "__posix_" #sym_name); \
} \
NWRAP_UNLOCK(libc_symbol_binding)
#define nwrap_bind_symbol_libnsl(sym_name) \
NWRAP_LOCK(libc_symbol_binding); \
if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
_nwrap_bind_symbol(NWRAP_LIBNSL, #sym_name); \
} \
NWRAP_UNLOCK(libc_symbol_binding)
#define nwrap_bind_symbol_libsocket(sym_name) \
NWRAP_LOCK(libc_symbol_binding); \
if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
_nwrap_bind_symbol(NWRAP_LIBSOCKET, #sym_name); \
} \
NWRAP_UNLOCK(libc_symbol_binding)
static void nwrap_bind_symbol_all(void);
/* INTERNAL HELPER FUNCTIONS */
static void nwrap_lines_unload(struct nwrap_cache *const nwrap)
@ -1285,7 +1293,7 @@ static void nwrap_lines_unload(struct nwrap_cache *const nwrap)
*/
static struct passwd *libc_getpwnam(const char *name)
{
nwrap_bind_symbol_libc(getpwnam);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getpwnam.f(name);
}
@ -1297,11 +1305,7 @@ static int libc_getpwnam_r(const char *name,
size_t buflen,
struct passwd **result)
{
#ifdef HAVE___POSIX_GETPWNAM_R
nwrap_bind_symbol_libc_posix(getpwnam_r);
#else
nwrap_bind_symbol_libc(getpwnam_r);
#endif
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getpwnam_r.f(name,
pwd,
@ -1313,7 +1317,7 @@ static int libc_getpwnam_r(const char *name,
static struct passwd *libc_getpwuid(uid_t uid)
{
nwrap_bind_symbol_libc(getpwuid);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getpwuid.f(uid);
}
@ -1325,11 +1329,7 @@ static int libc_getpwuid_r(uid_t uid,
size_t buflen,
struct passwd **result)
{
#ifdef HAVE___POSIX_GETPWUID_R
nwrap_bind_symbol_libc_posix(getpwuid_r);
#else
nwrap_bind_symbol_libc(getpwuid_r);
#endif
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getpwuid_r.f(uid,
pwd,
@ -1372,14 +1372,14 @@ static bool str_tolower_copy(char **dst_name, const char *const src_name)
static void libc_setpwent(void)
{
nwrap_bind_symbol_libc(setpwent);
nwrap_bind_symbol_all();
nwrap_main_global->libc->symbols._libc_setpwent.f();
}
static struct passwd *libc_getpwent(void)
{
nwrap_bind_symbol_libc(getpwent);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getpwent.f();
}
@ -1390,7 +1390,7 @@ static struct passwd *libc_getpwent_r(struct passwd *pwdst,
char *buf,
int buflen)
{
nwrap_bind_symbol_libc(getpwent_r);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getpwent_r.f(pwdst,
buf,
@ -1402,7 +1402,7 @@ static int libc_getpwent_r(struct passwd *pwdst,
size_t buflen,
struct passwd **pwdstp)
{
nwrap_bind_symbol_libc(getpwent_r);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getpwent_r.f(pwdst,
buf,
@ -1414,21 +1414,21 @@ static int libc_getpwent_r(struct passwd *pwdst,
static void libc_endpwent(void)
{
nwrap_bind_symbol_libc(endpwent);
nwrap_bind_symbol_all();
nwrap_main_global->libc->symbols._libc_endpwent.f();
}
static int libc_initgroups(const char *user, gid_t gid)
{
nwrap_bind_symbol_libc(initgroups);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_initgroups.f(user, gid);
}
static struct group *libc_getgrnam(const char *name)
{
nwrap_bind_symbol_libc(getgrnam);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getgrnam.f(name);
}
@ -1440,11 +1440,7 @@ static int libc_getgrnam_r(const char *name,
size_t buflen,
struct group **result)
{
#ifdef HAVE___POSIX_GETGRNAM_R
nwrap_bind_symbol_libc_posix(getgrnam_r);
#else
nwrap_bind_symbol_libc(getgrnam_r);
#endif
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getgrnam_r.f(name,
grp,
@ -1456,7 +1452,7 @@ static int libc_getgrnam_r(const char *name,
static struct group *libc_getgrgid(gid_t gid)
{
nwrap_bind_symbol_libc(getgrgid);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getgrgid.f(gid);
}
@ -1468,14 +1464,7 @@ static int libc_getgrgid_r(gid_t gid,
size_t buflen,
struct group **result)
{
#ifdef HAVE___POSIX_GETGRGID_R
if (nwrap_main_global->libc->symbols._libc_getgrgid_r == NULL) {
*(void **) (&nwrap_main_global->libc->symbols._libc_getgrgid_r) =
_nwrap_bind_symbol_libc("__posix_getgrgid_r");
}
#else
nwrap_bind_symbol_libc(getgrgid_r);
#endif
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getgrgid_r.f(gid,
grp,
@ -1487,14 +1476,14 @@ static int libc_getgrgid_r(gid_t gid,
static void libc_setgrent(void)
{
nwrap_bind_symbol_libc(setgrent);
nwrap_bind_symbol_all();
nwrap_main_global->libc->symbols._libc_setgrent.f();
}
static struct group *libc_getgrent(void)
{
nwrap_bind_symbol_libc(getgrent);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getgrent.f();
}
@ -1505,7 +1494,7 @@ static struct group *libc_getgrent_r(struct group *group,
char *buf,
size_t buflen)
{
nwrap_bind_symbol_libc(getgrent_r);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getgrent_r.f(group,
buf,
@ -1517,7 +1506,7 @@ static int libc_getgrent_r(struct group *group,
size_t buflen,
struct group **result)
{
nwrap_bind_symbol_libc(getgrent_r);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getgrent_r.f(group,
buf,
@ -1529,7 +1518,7 @@ static int libc_getgrent_r(struct group *group,
static void libc_endgrent(void)
{
nwrap_bind_symbol_libc(endgrent);
nwrap_bind_symbol_all();
nwrap_main_global->libc->symbols._libc_endgrent.f();
}
@ -1540,7 +1529,7 @@ static int libc_getgrouplist(const char *user,
gid_t *groups,
int *ngroups)
{
nwrap_bind_symbol_libc(getgrouplist);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getgrouplist.f(user,
group,
@ -1551,28 +1540,28 @@ static int libc_getgrouplist(const char *user,
static void libc_sethostent(int stayopen)
{
nwrap_bind_symbol_libnsl(sethostent);
nwrap_bind_symbol_all();
nwrap_main_global->libc->symbols._libc_sethostent.f(stayopen);
}
static struct hostent *libc_gethostent(void)
{
nwrap_bind_symbol_libnsl(gethostent);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_gethostent.f();
}
static void libc_endhostent(void)
{
nwrap_bind_symbol_libnsl(endhostent);
nwrap_bind_symbol_all();
nwrap_main_global->libc->symbols._libc_endhostent.f();
}
static struct hostent *libc_gethostbyname(const char *name)
{
nwrap_bind_symbol_libnsl(gethostbyname);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_gethostbyname.f(name);
}
@ -1580,7 +1569,7 @@ static struct hostent *libc_gethostbyname(const char *name)
#ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
static struct hostent *libc_gethostbyname2(const char *name, int af)
{
nwrap_bind_symbol_libnsl(gethostbyname2);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_gethostbyname2.f(name, af);
}
@ -1595,7 +1584,7 @@ static int libc_gethostbyname2_r(const char *name,
struct hostent **result,
int *h_errnop)
{
nwrap_bind_symbol_libnsl(gethostbyname2_r);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_gethostbyname2_r.f(name,
af,
@ -1611,7 +1600,7 @@ static struct hostent *libc_gethostbyaddr(const void *addr,
socklen_t len,
int type)
{
nwrap_bind_symbol_libnsl(gethostbyaddr);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_gethostbyaddr.f(addr,
len,
@ -1620,7 +1609,7 @@ static struct hostent *libc_gethostbyaddr(const void *addr,
static int libc_gethostname(char *name, size_t len)
{
nwrap_bind_symbol_libnsl(gethostname);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_gethostname.f(name, len);
}
@ -1633,7 +1622,7 @@ static int libc_gethostbyname_r(const char *name,
struct hostent **result,
int *h_errnop)
{
nwrap_bind_symbol_libnsl(gethostbyname_r);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_gethostbyname_r.f(name,
ret,
@ -1654,7 +1643,7 @@ static int libc_gethostbyaddr_r(const void *addr,
struct hostent **result,
int *h_errnop)
{
nwrap_bind_symbol_libnsl(gethostbyaddr_r);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_gethostbyaddr_r.f(addr,
len,
@ -1672,7 +1661,7 @@ static int libc_getaddrinfo(const char *node,
const struct addrinfo *hints,
struct addrinfo **res)
{
nwrap_bind_symbol_libsocket(getaddrinfo);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getaddrinfo.f(node,
service,
@ -1688,7 +1677,7 @@ static int libc_getnameinfo(const struct sockaddr *sa,
size_t servlen,
int flags)
{
nwrap_bind_symbol_libsocket(getnameinfo);
nwrap_bind_symbol_all();
return nwrap_main_global->libc->symbols._libc_getnameinfo.f(sa,
salen,
@ -1699,6 +1688,81 @@ static int libc_getnameinfo(const struct sockaddr *sa,
flags);
}
static void __nwrap_bind_symbol_all_once(void)
{
nwrap_bind_symbol_libc(getpwnam);
#ifdef HAVE_GETPWNAM_R
# ifdef HAVE___POSIX_GETPWNAM_R
nwrap_bind_symbol_libc_posix(getpwnam_r);
# else
nwrap_bind_symbol_libc(getpwnam_r);
# endif
#endif
nwrap_bind_symbol_libc(getpwuid);
#ifdef HAVE_GETPWUID_R
# ifdef HAVE___POSIX_GETPWUID_R
nwrap_bind_symbol_libc_posix(getpwuid_r);
# else
nwrap_bind_symbol_libc(getpwuid_r);
# endif
#endif
nwrap_bind_symbol_libc(setpwent);
nwrap_bind_symbol_libc(getpwent);
#ifdef HAVE_GETPWENT_R
nwrap_bind_symbol_libc(getpwent_r);
#endif
nwrap_bind_symbol_libc(endpwent);
nwrap_bind_symbol_libc(initgroups);
nwrap_bind_symbol_libc(getgrnam);
#ifdef HAVE_GETGRNAM_R
# ifdef HAVE___POSIX_GETGRNAM_R
nwrap_bind_symbol_libc_posix(getgrnam_r);
# else
nwrap_bind_symbol_libc(getgrnam_r);
# endif
#endif
nwrap_bind_symbol_libc(getgrgid);
#ifdef HAVE_GETGRGID_R
# ifdef HAVE___POSIX_GETGRGID_R
nwrap_bind_symbol_libc_posix(getgrgid_r);
# else
nwrap_bind_symbol_libc(getgrgid_r);
# endif
#endif
nwrap_bind_symbol_libc(setgrent);
nwrap_bind_symbol_libc(getgrent);
nwrap_bind_symbol_libc(getgrent_r);
nwrap_bind_symbol_libc(endgrent);
nwrap_bind_symbol_libc(getgrouplist);
nwrap_bind_symbol_libnsl(sethostent);
nwrap_bind_symbol_libnsl(gethostent);
nwrap_bind_symbol_libnsl(endhostent);
nwrap_bind_symbol_libnsl(gethostbyname);
#ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
nwrap_bind_symbol_libnsl(gethostbyname2);
#endif
#ifdef HAVE_GETHOSTBYNAME2_R /* GNU extension */
nwrap_bind_symbol_libnsl(gethostbyname2_r);
#endif
nwrap_bind_symbol_libnsl(gethostbyaddr);
nwrap_bind_symbol_libnsl(gethostname);
#ifdef HAVE_GETHOSTBYNAME_R
nwrap_bind_symbol_libnsl(gethostbyname_r);
#endif
#ifdef HAVE_GETHOSTBYADDR_R
nwrap_bind_symbol_libnsl(gethostbyaddr_r);
#endif
nwrap_bind_symbol_libsocket(getaddrinfo);
nwrap_bind_symbol_libsocket(getnameinfo);
}
static void nwrap_bind_symbol_all(void)
{
static pthread_once_t all_symbol_binding_once = PTHREAD_ONCE_INIT;
pthread_once(&all_symbol_binding_once, __nwrap_bind_symbol_all_once);
}
/*********************************************************
* NWRAP NSS MODULE LOADER FUNCTIONS
*********************************************************/
@ -1732,20 +1796,16 @@ static void *_nwrap_bind_nss_module_symbol(struct nwrap_backend *b,
}
#define nwrap_nss_module_bind_symbol(sym_name) \
NWRAP_LOCK(nss_module_symbol_binding); \
if (symbols->_nss_##sym_name.obj == NULL) { \
symbols->_nss_##sym_name.obj = \
_nwrap_bind_nss_module_symbol(b, #sym_name); \
} \
NWRAP_UNLOCK(nss_module_symbol_binding)
}
#define nwrap_nss_module_bind_symbol2(sym_name, alt_name) \
NWRAP_LOCK(nss_module_symbol_binding); \
if (symbols->_nss_##sym_name.obj == NULL) { \
symbols->_nss_##sym_name.obj = \
_nwrap_bind_nss_module_symbol(b, #alt_name); \
} \
NWRAP_UNLOCK(nss_module_symbol_binding)
}
static struct nwrap_nss_module_symbols *
nwrap_bind_nss_module_symbols(struct nwrap_backend *b)
@ -1876,6 +1936,34 @@ static void nwrap_backend_init(struct nwrap_main *r)
}
}
static int _nss_wrapper_init_mutex(pthread_mutex_t *m, const char *name)
{
pthread_mutexattr_t ma;
bool need_destroy = false;
int ret = 0;
#define __CHECK(cmd) do { \
ret = cmd; \
if (ret != 0) { \
NWRAP_LOG(NWRAP_LOG_ERROR, \
"%s: %s - failed %d", \
name, #cmd, ret); \
goto done; \
} \
} while(0)
*m = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
__CHECK(pthread_mutexattr_init(&ma));
need_destroy = true;
__CHECK(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK));
__CHECK(pthread_mutex_init(m, &ma));
done:
if (need_destroy) {
pthread_mutexattr_destroy(&ma);
}
return ret;
}
static void nwrap_init(void)
{
const char *env;
@ -1883,9 +1971,9 @@ static void nwrap_init(void)
size_t max_hostents_tmp;
int ok;
NWRAP_LOCK(nwrap_initialized);
nwrap_mutex_lock(&nwrap_initialized_mutex);
if (nwrap_initialized) {
NWRAP_UNLOCK(nwrap_initialized);
nwrap_mutex_unlock(&nwrap_initialized_mutex);
return;
}
@ -1894,11 +1982,11 @@ static void nwrap_init(void)
* We don't use NWRAP_(UN)LOCK_ALL macros here because we
* want to avoid overhead when other threads do their job.
*/
NWRAP_LOCK(nwrap_global);
NWRAP_LOCK(nwrap_gr_global);
NWRAP_LOCK(nwrap_he_global);
NWRAP_LOCK(nwrap_pw_global);
NWRAP_LOCK(nwrap_sp_global);
nwrap_mutex_lock(&nwrap_global_mutex);
nwrap_mutex_lock(&nwrap_gr_global_mutex);
nwrap_mutex_lock(&nwrap_he_global_mutex);
nwrap_mutex_lock(&nwrap_pw_global_mutex);
nwrap_mutex_lock(&nwrap_sp_global_mutex);
nwrap_initialized = true;
@ -1977,7 +2065,12 @@ static void nwrap_init(void)
nwrap_he_global.cache->unload = nwrap_he_unload;
/* We hold all locks here so we can use NWRAP_UNLOCK_ALL. */
NWRAP_UNLOCK_ALL;
nwrap_mutex_unlock(&nwrap_sp_global_mutex);
nwrap_mutex_unlock(&nwrap_pw_global_mutex);
nwrap_mutex_unlock(&nwrap_he_global_mutex);
nwrap_mutex_unlock(&nwrap_gr_global_mutex);
nwrap_mutex_unlock(&nwrap_global_mutex);
nwrap_mutex_unlock(&nwrap_initialized_mutex);
}
bool nss_wrapper_enabled(void)
@ -6352,11 +6445,29 @@ int gethostname(char *name, size_t len)
return nwrap_gethostname(name, len);
}
static void nwrap_thread_prepare(void)
{
nwrap_init();
NWRAP_LOCK_ALL;
}
static void nwrap_thread_parent(void)
{
NWRAP_UNLOCK_ALL;
}
static void nwrap_thread_child(void)
{
NWRAP_REINIT_ALL;
}
/****************************
* CONSTRUCTOR
***************************/
void nwrap_constructor(void)
{
NWRAP_REINIT_ALL;
/*
* If we hold a lock and the application forks, then the child
* is not able to unlock the mutex and we are in a deadlock.

View File

@ -2,7 +2,7 @@
import os
VERSION="1.1.12"
VERSION="1.1.13"
def configure(conf):
if conf.CHECK_NSS_WRAPPER():