The branch, master has been updated
       via  4a68d43b7b0 third_party: Update nss_wrapper to version 1.1.13
      from  10537a89bb0 s4: libcli: Ignore errors when getting A records after 
fetching AAAA records.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4a68d43b7b02e191f007baac56b8b0e47e99b64d
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Nov 8 11:01:44 2022 +0100

    third_party: Update nss_wrapper to version 1.1.13
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>
    
    Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org>
    Autobuild-Date(master): Wed Nov  9 23:15:07 UTC 2022 on sn-devel-184

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafsamba/samba_third_party.py |   2 +-
 third_party/nss_wrapper/nss_wrapper.c    | 343 ++++++++++++++++++++-----------
 third_party/nss_wrapper/wscript          |   2 +-
 3 files changed, 229 insertions(+), 118 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_third_party.py 
b/buildtools/wafsamba/samba_third_party.py
index c83fdcf795b..d98c0eeb18e 100644
--- a/buildtools/wafsamba/samba_third_party.py
+++ b/buildtools/wafsamba/samba_third_party.py
@@ -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
diff --git a/third_party/nss_wrapper/nss_wrapper.c 
b/third_party/nss_wrapper/nss_wrapper.c
index 88e81d9c652..07c975765e4 100644
--- a/third_party/nss_wrapper/nss_wrapper.c
+++ b/third_party/nss_wrapper/nss_wrapper.c
@@ -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


-- 
Samba Shared Repository

Reply via email to