1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
Description: Handle removal of __libc_lock_lock and similar symbols from libc
Bug: http://bugzilla.padl.com/show_bug.cgi?id=445
Bug-Debian: http://bugs.debian.org/727177
Bug-Arch-Linux-ARM: https://github.com/archlinuxarm/PKGBUILDs/issues/296
Bug-Gentoo: https://bugs.gentoo.org/show_bug.cgi?id=438692
Author: Dennis Schridde <devurandom@gmx.net>
--- a/ldap-nss.c
+++ b/ldap-nss.c
@@ -142,7 +142,7 @@ static void (*__sigpipe_handler) (int) =
*/
static ldap_session_t __session = { NULL, NULL, 0, LS_UNINITIALIZED };
-#if defined(HAVE_PTHREAD_ATFORK) || defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#if defined(HAVE_PTHREAD_ATFORK) || defined(HAVE___LIBC_ONCE)
static pthread_once_t __once = PTHREAD_ONCE_INIT;
#endif
@@ -150,7 +150,7 @@ static pthread_once_t __once = PTHREAD_O
static FILE *__debugfile;
#endif /* LBER_OPT_LOG_PRINT_FILE */
-#ifndef HAVE_PTHREAD_ATFORK
+#if !defined(HAVE_PTHREAD_ATFORK) || !defined(HAVE___LIBC_ONCE)
/*
* Process ID that opened the session.
*/
@@ -162,7 +162,7 @@ static uid_t __euid = -1;
static int __ssl_initialized = 0;
#endif /* HAVE_LDAPSSL_CLIENT_INIT */
-#if defined(HAVE_PTHREAD_ATFORK) || defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#if defined(HAVE_PTHREAD_ATFORK) || defined(HAVE___LIBC_ONCE)
/*
* Prepare for fork(); lock mutex.
*/
@@ -514,7 +514,7 @@ _nss_ldap_default_constr (nss_ldap_backe
}
#endif /* HAVE_NSSWITCH_H */
-#if defined(HAVE_PTHREAD_ATFORK) || defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#if defined(HAVE_PTHREAD_ATFORK) || defined(HAVE___LIBC_ONCE)
static void
do_atfork_prepare (void)
{
@@ -548,7 +548,7 @@ do_atfork_setup (void)
#ifdef HAVE_PTHREAD_ATFORK
(void) pthread_atfork (do_atfork_prepare, do_atfork_parent,
do_atfork_child);
-#elif defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#elif defined(HAVE___LIBC_ATFORK)
(void) __libc_atfork (do_atfork_prepare, do_atfork_parent, do_atfork_child);
#endif
@@ -1111,7 +1111,7 @@ static NSS_STATUS
do_init (void)
{
ldap_config_t *cfg;
-#ifndef HAVE_PTHREAD_ATFORK
+#if !defined(HAVE_PTHREAD_ATFORK) || !defined(HAVE___LIBC_ONCE)
pid_t pid;
#endif
uid_t euid;
@@ -1128,7 +1128,7 @@ do_init (void)
}
#ifndef HAVE_PTHREAD_ATFORK
-#if defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#if defined(HAVE___LIBC_ONCE)
/*
* This bogosity is necessary because Linux uses different
* PIDs for different threads (like IRIX, which we don't
@@ -1160,7 +1160,7 @@ do_init (void)
pid = -1; /* linked against libpthreads, don't care */
#else
pid = getpid ();
-#endif /* HAVE_LIBC_LOCK_H || HAVE_BITS_LIBC_LOCK_H */
+#endif /* HAVE___LIBC_ONCE */
#endif /* HAVE_PTHREAD_ATFORK */
euid = geteuid ();
@@ -1170,7 +1170,7 @@ do_init (void)
syslog (LOG_AUTHPRIV | LOG_DEBUG,
"nss_ldap: __session.ls_state=%d, __session.ls_conn=%p, __euid=%i, euid=%i",
__session.ls_state, __session.ls_conn, __euid, euid);
-#elif defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#elif defined(HAVE___LIBC_ONCE)
syslog (LOG_AUTHPRIV | LOG_DEBUG,
"nss_ldap: libpthreads=%s, __session.ls_state=%d, __session.ls_conn=%p, __pid=%i, pid=%i, __euid=%i, euid=%i",
((__pthread_once == NULL || __pthread_atfork == NULL) ? "FALSE" : "TRUE"),
@@ -1194,11 +1194,11 @@ do_init (void)
}
else
#ifndef HAVE_PTHREAD_ATFORK
-#if defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#if defined(HAVE___LIBC_ONCE)
if ((__pthread_once == NULL || __pthread_atfork == NULL) && __pid != pid)
#else
if (__pid != pid)
-#endif /* HAVE_LIBC_LOCK_H || HAVE_BITS_LIBC_LOCK_H */
+#endif /* HAVE___LIBC_ONCE */
{
do_close_no_unbind ();
}
@@ -1259,9 +1259,9 @@ do_init (void)
debug ("<== do_init (pthread_once failed)");
return NSS_UNAVAIL;
}
-#elif defined(HAVE_PTHREAD_ATFORK) && ( defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H) )
+#elif defined(HAVE_PTHREAD_ATFORK) && defined(HAVE___LIBC_ONCE)
__libc_once (__once, do_atfork_setup);
-#elif defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#elif defined(HAVE___LIBC_ONCE)
/*
* Only install the pthread_atfork() handlers i
* we are linked against libpthreads. Otherwise,
--- a/ldap-nss.h
+++ b/ldap-nss.h
@@ -670,7 +670,7 @@ extern int __multi_threaded;
#define NSS_LDAP_LOCK(m) mutex_lock(&m)
#define NSS_LDAP_UNLOCK(m) mutex_unlock(&m)
#define NSS_LDAP_DEFINE_LOCK(m) static mutex_t m = DEFAULTMUTEX
-#elif defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
+#elif defined(HAVE___LIBC_LOCK_LOCK) && defined(HAVE___LIBC_LOCK_UNLOCK)
#define NSS_LDAP_LOCK(m) __libc_lock_lock(m)
#define NSS_LDAP_UNLOCK(m) __libc_lock_unlock(m)
#define NSS_LDAP_DEFINE_LOCK(m) static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER
--- a/configure.in
+++ b/configure.in
@@ -234,6 +234,7 @@ AC_CHECK_FUNCS(pthread_atfork)
AC_CHECK_FUNCS(pthread_once)
AC_CHECK_FUNCS(ether_aton)
AC_CHECK_FUNCS(ether_ntoa)
+AC_CHECK_FUNCS(__libc_once __libc_atfork __libc_lock_lock __libc_lock_unlock)
AC_MSG_CHECKING(for struct ether_addr)
AC_TRY_COMPILE([#include <sys/types.h>
|