Skip to content

Use openldap.h on OpenLDAP 2.4.48 #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Modules/LDAPObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Modules/berval.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 24 additions & 0 deletions Modules/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@
#include "config.h"
#endif

#include <lber.h>
#include <ldap.h>
#include <ldap_features.h>

#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 <openldap.h>
#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 <winsock.h>
#else /* unix */
Expand Down
2 changes: 0 additions & 2 deletions Modules/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "common.h"
#include "constants.h"
#include "ldapcontrol.h"
#include "lber.h"
#include "ldap.h"

/* the base exception class */

Expand Down
2 changes: 0 additions & 2 deletions Modules/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 1 addition & 19 deletions Modules/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,7 @@ l_ldap_initialize(PyObject *unused, PyObject *args)
return (PyObject *)newLDAPObject(ld);
}

#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)
Expand Down Expand Up @@ -97,7 +82,6 @@ l_ldap_initialize_fd(PyObject *unused, PyObject *args)

return (PyObject *)newLDAPObject(ld);
}
#endif /* HAVE_LDAP_INIT_FD */

/* ldap_str2dn */

Expand Down Expand Up @@ -206,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},
Expand Down
2 changes: 0 additions & 2 deletions Modules/ldapcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Modules/ldapcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#define __h_ldapcontrol

#include "common.h"
#include "ldap.h"

void LDAPinit_control(PyObject *d);
void LDAPControl_List_DEL(LDAPControl **);
Expand Down
2 changes: 0 additions & 2 deletions Modules/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class OpenLDAP2:
('LDAPMODULE_VERSION', pkginfo.__version__),
('LDAPMODULE_AUTHOR', pkginfo.__author__),
('LDAPMODULE_LICENSE', pkginfo.__license__),
('HAVE_LDAP_INIT_FD', None),
]
),
],
Expand Down