python3Packages.ldap: fix linking with openldap 2.5+

+98
+94
pkgs/development/python-modules/ldap/0001-Check-whether-libldap-is-threadsafe-on-startup.patch
···
··· 1 + From 3593e2c299c0ac0402f23d44cdbe8e6ff3687b68 Mon Sep 17 00:00:00 2001 2 + From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= <ondra@mistotebe.net> 3 + Date: Thu, 27 Jan 2022 10:35:56 +0000 4 + Subject: [PATCH] Check whether libldap is threadsafe on startup. 5 + 6 + Closes #432 7 + --- 8 + Lib/ldap/constants.py | 2 -- 9 + Modules/constants.c | 10 ++++++++++ 10 + setup.cfg | 6 ++++-- 11 + setup.py | 1 - 12 + 4 files changed, 14 insertions(+), 5 deletions(-) 13 + 14 + diff --git a/Lib/ldap/constants.py b/Lib/ldap/constants.py 15 + index 1c1d76a..f76609b 100644 16 + --- a/Lib/ldap/constants.py 17 + +++ b/Lib/ldap/constants.py 18 + @@ -341,9 +341,7 @@ CONSTANTS = ( 19 + # XXX - these should be errors 20 + Int('URL_ERR_BADSCOPE'), 21 + Int('URL_ERR_MEM'), 22 + - # Int('LIBLDAP_R'), 23 + 24 + - Feature('LIBLDAP_R', 'HAVE_LIBLDAP_R'), 25 + Feature('SASL_AVAIL', 'HAVE_SASL'), 26 + Feature('TLS_AVAIL', 'HAVE_TLS'), 27 + Feature('INIT_FD_AVAIL', 'HAVE_LDAP_INIT_FD'), 28 + diff --git a/Modules/constants.c b/Modules/constants.c 29 + index 07d6065..8d6f63b 100644 30 + --- a/Modules/constants.c 31 + +++ b/Modules/constants.c 32 + @@ -197,6 +197,8 @@ int 33 + LDAPinit_constants(PyObject *m) 34 + { 35 + PyObject *exc, *nobj; 36 + + struct ldap_apifeature_info info = { 1, "X_OPENLDAP_THREAD_SAFE", 0 }; 37 + + int thread_safe = 0; 38 + 39 + /* simple constants */ 40 + 41 + @@ -221,6 +223,14 @@ LDAPinit_constants(PyObject *m) 42 + return -1; 43 + Py_INCREF(LDAPexception_class); 44 + 45 + +#ifdef LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 46 + + if (ldap_get_option(NULL, LDAP_OPT_API_FEATURE_INFO, &info) == LDAP_SUCCESS) { 47 + + thread_safe = (info.ldapaif_version == 1); 48 + + } 49 + +#endif 50 + + if (PyModule_AddIntConstant(m, "LIBLDAP_R", thread_safe) != 0) 51 + + return -1; 52 + + 53 + /* Generated constants -- see Lib/ldap/constants.py */ 54 + 55 + #define add_err(n) do { \ 56 + diff --git a/setup.cfg b/setup.cfg 57 + index 2e372ba..a75f186 100644 58 + --- a/setup.cfg 59 + +++ b/setup.cfg 60 + @@ -5,7 +5,9 @@ license_file = LICENCE 61 + defines = HAVE_SASL HAVE_TLS HAVE_LIBLDAP_R 62 + extra_compile_args = 63 + extra_objects = 64 + -libs = ldap_r lber 65 + +# Uncomment this if your libldap is not thread-safe and you need libldap_r 66 + +# instead 67 + +#libs = ldap_r lber 68 + 69 + [install] 70 + compile = 1 71 + @@ -13,7 +15,7 @@ optimize = 1 72 + 73 + [bdist_rpm] 74 + provides = python-ldap 75 + -requires = python libldap-2_4 76 + +requires = python libldap-2 77 + vendor = python-ldap project 78 + packager = python-ldap team 79 + distribution_name = openSUSE 11.x 80 + diff --git a/setup.py b/setup.py 81 + index 119b571..b193957 100644 82 + --- a/setup.py 83 + +++ b/setup.py 84 + @@ -132,7 +132,6 @@ setup( 85 + extra_objects = LDAP_CLASS.extra_objects, 86 + runtime_library_dirs = (not sys.platform.startswith("win"))*LDAP_CLASS.library_dirs, 87 + define_macros = LDAP_CLASS.defines + \ 88 + - ('ldap_r' in LDAP_CLASS.libs or 'oldap_r' in LDAP_CLASS.libs)*[('HAVE_LIBLDAP_R',None)] + \ 89 + ('sasl' in LDAP_CLASS.libs or 'sasl2' in LDAP_CLASS.libs or 'libsasl' in LDAP_CLASS.libs)*[('HAVE_SASL',None)] + \ 90 + ('ssl' in LDAP_CLASS.libs and 'crypto' in LDAP_CLASS.libs)*[('HAVE_TLS',None)] + \ 91 + [ 92 + -- 93 + 2.36.0 94 +
+4
pkgs/development/python-modules/ldap/default.nix
··· 12 sha256 = "60464c8fc25e71e0fd40449a24eae482dcd0fb7fcf823e7de627a6525b3e0d12"; 13 }; 14 15 propagatedBuildInputs = [ pyasn1 pyasn1-modules ]; 16 17 checkInputs = [ pytestCheckHook ];
··· 12 sha256 = "60464c8fc25e71e0fd40449a24eae482dcd0fb7fcf823e7de627a6525b3e0d12"; 13 }; 14 15 + patches = [ 16 + ./0001-Check-whether-libldap-is-threadsafe-on-startup.patch 17 + ]; 18 + 19 propagatedBuildInputs = [ pyasn1 pyasn1-modules ]; 20 21 checkInputs = [ pytestCheckHook ];