From 8062a30cd1ee029ad02c7553b042c240b140c8eb Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 9 Jun 2020 13:18:59 +0200 Subject: [PATCH 1/2] Use openldap.h on OpenLDAP 2.4.48 OpenLDAP 2.4.48 added openldap.h, which defines ldap_init_fd. Use the header file with 2.4.48 and define the function for older versions. The patch also cleans up #include. All OpenLDAP includes are now in common.h and use global includes ``#include `` instead of local includes ``#include "ldap.h"``. Fixes: https://github.com/python-ldap/python-ldap/issues/353 See: https://bugs.openldap.org/show_bug.cgi?id=8671 Signed-off-by: Christian Heimes --- Modules/LDAPObject.h | 6 ------ Modules/berval.h | 1 - Modules/common.h | 27 +++++++++++++++++++++++++++ Modules/constants.c | 2 -- Modules/constants.h | 2 -- Modules/functions.c | 15 +-------------- Modules/ldapcontrol.c | 2 -- Modules/ldapcontrol.h | 1 - Modules/message.h | 2 -- 9 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Modules/LDAPObject.h b/Modules/LDAPObject.h index a456bce0..1b6066db 100644 --- a/Modules/LDAPObject.h +++ b/Modules/LDAPObject.h @@ -5,12 +5,6 @@ #include "common.h" -#include "lber.h" -#include "ldap.h" -#if LDAP_API_VERSION < 2040 -#error Current python-ldap requires OpenLDAP 2.4.x -#endif - #if PYTHON_API_VERSION < 1007 typedef PyObject *_threadstate; #else diff --git a/Modules/berval.h b/Modules/berval.h index 2aa9c977..9c427240 100644 --- a/Modules/berval.h +++ b/Modules/berval.h @@ -4,7 +4,6 @@ #define __h_berval #include "common.h" -#include "lber.h" PyObject *LDAPberval_to_object(const struct berval *bv); PyObject *LDAPberval_to_unicode_object(const struct berval *bv); diff --git a/Modules/common.h b/Modules/common.h index affa5f93..bde943cd 100644 --- a/Modules/common.h +++ b/Modules/common.h @@ -12,6 +12,33 @@ #include "config.h" #endif +#include +#include +#include + +#if LDAP_API_VERSION < 2040 +#error Current python-ldap requires OpenLDAP 2.4.x +#endif + +#if LDAP_VENDOR_VERSION >= 20448 + /* openldap.h with ldap_init_fd() was introduced in 2.4.48 + * see https://bugs.openldap.org/show_bug.cgi?id=8671 + */ +#include +#ifndef HAVE_LDAP_INIT_FD +#define HAVE_LDAP_INIT_FD +#endif +#else + /* ldap_init_fd() has been around for a very long time + * SSSD has been defining the function for a while, so it's probably OK. + */ +#define LDAP_PROTO_TCP 1 +#define LDAP_PROTO_UDP 2 +#define LDAP_PROTO_IPC 3 +extern int ldap_init_fd(ber_socket_t fd, int proto, LDAP_CONST char *url, + LDAP **ldp); +#endif + #if defined(MS_WINDOWS) #include #else /* unix */ diff --git a/Modules/constants.c b/Modules/constants.c index 88658c55..8b902e02 100644 --- a/Modules/constants.c +++ b/Modules/constants.c @@ -4,8 +4,6 @@ #include "common.h" #include "constants.h" #include "ldapcontrol.h" -#include "lber.h" -#include "ldap.h" /* the base exception class */ diff --git a/Modules/constants.h b/Modules/constants.h index b8150949..7b9ce53e 100644 --- a/Modules/constants.h +++ b/Modules/constants.h @@ -4,8 +4,6 @@ #define __h_constants_ #include "common.h" -#include "lber.h" -#include "ldap.h" extern int LDAPinit_constants(PyObject *m); extern PyObject *LDAPconstant(int); diff --git a/Modules/functions.c b/Modules/functions.c index 9e0312db..e3920477 100644 --- a/Modules/functions.c +++ b/Modules/functions.c @@ -32,20 +32,7 @@ l_ldap_initialize(PyObject *unused, PyObject *args) #ifdef HAVE_LDAP_INIT_FD -/* initialize_fd(fileno, url) - * - * ldap_init_fd() is not a private API but it's not in a public header either - * SSSD has been using the function for a while, so it's probably OK. - */ - -#ifndef LDAP_PROTO_TCP -#define LDAP_PROTO_TCP 1 -#define LDAP_PROTO_UDP 2 -#define LDAP_PROTO_IPC 3 -#endif - -extern int - ldap_init_fd(ber_socket_t fd, int proto, LDAP_CONST char *url, LDAP **ldp); +/* initialize_fd(fileno, url) */ static PyObject * l_ldap_initialize_fd(PyObject *unused, PyObject *args) diff --git a/Modules/ldapcontrol.c b/Modules/ldapcontrol.c index 5e2d2ff8..e287e9a3 100644 --- a/Modules/ldapcontrol.c +++ b/Modules/ldapcontrol.c @@ -6,8 +6,6 @@ #include "berval.h" #include "constants.h" -#include "lber.h" - /* Prints to stdout the contents of an array of LDAPControl objects */ /* XXX: This is a debugging tool, and the printf generates some warnings diff --git a/Modules/ldapcontrol.h b/Modules/ldapcontrol.h index de694c07..74cae423 100644 --- a/Modules/ldapcontrol.h +++ b/Modules/ldapcontrol.h @@ -4,7 +4,6 @@ #define __h_ldapcontrol #include "common.h" -#include "ldap.h" void LDAPinit_control(PyObject *d); void LDAPControl_List_DEL(LDAPControl **); diff --git a/Modules/message.h b/Modules/message.h index 2978ea56..ed73f32c 100644 --- a/Modules/message.h +++ b/Modules/message.h @@ -4,8 +4,6 @@ #define __h_message #include "common.h" -#include "lber.h" -#include "ldap.h" extern PyObject *LDAPmessage_to_python(LDAP *ld, LDAPMessage *m, int add_ctrls, int add_intermediates); From 3288ed9f0c411897d7306014868033dcba7c7121 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 9 Jun 2020 14:05:36 +0200 Subject: [PATCH 2/2] Drop HAVE_LDAP_INIT_FD python-ldap requires OpenLDAP 2.4.0 that provides ldap_init_fd. Signed-off-by: Christian Heimes --- Modules/common.h | 3 --- Modules/functions.c | 5 ----- setup.py | 1 - 3 files changed, 9 deletions(-) diff --git a/Modules/common.h b/Modules/common.h index bde943cd..1ce2eb83 100644 --- a/Modules/common.h +++ b/Modules/common.h @@ -25,9 +25,6 @@ * see https://bugs.openldap.org/show_bug.cgi?id=8671 */ #include -#ifndef HAVE_LDAP_INIT_FD -#define HAVE_LDAP_INIT_FD -#endif #else /* ldap_init_fd() has been around for a very long time * SSSD has been defining the function for a while, so it's probably OK. diff --git a/Modules/functions.c b/Modules/functions.c index e3920477..ce4a924a 100644 --- a/Modules/functions.c +++ b/Modules/functions.c @@ -30,8 +30,6 @@ l_ldap_initialize(PyObject *unused, PyObject *args) return (PyObject *)newLDAPObject(ld); } -#ifdef HAVE_LDAP_INIT_FD - /* initialize_fd(fileno, url) */ static PyObject * @@ -84,7 +82,6 @@ l_ldap_initialize_fd(PyObject *unused, PyObject *args) return (PyObject *)newLDAPObject(ld); } -#endif /* HAVE_LDAP_INIT_FD */ /* ldap_str2dn */ @@ -193,9 +190,7 @@ l_ldap_get_option(PyObject *self, PyObject *args) static PyMethodDef methods[] = { {"initialize", (PyCFunction)l_ldap_initialize, METH_VARARGS}, -#ifdef HAVE_LDAP_INIT_FD {"initialize_fd", (PyCFunction)l_ldap_initialize_fd, METH_VARARGS}, -#endif {"str2dn", (PyCFunction)l_ldap_str2dn, METH_VARARGS}, {"set_option", (PyCFunction)l_ldap_set_option, METH_VARARGS}, {"get_option", (PyCFunction)l_ldap_get_option, METH_VARARGS}, diff --git a/setup.py b/setup.py index 4559d840..69747853 100644 --- a/setup.py +++ b/setup.py @@ -145,7 +145,6 @@ class OpenLDAP2: ('LDAPMODULE_VERSION', pkginfo.__version__), ('LDAPMODULE_AUTHOR', pkginfo.__author__), ('LDAPMODULE_LICENSE', pkginfo.__license__), - ('HAVE_LDAP_INIT_FD', None), ] ), ], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy