From daeeb865c329f2eb00eadb9f6d2e344f8c2d0e57 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Sat, 7 Oct 2006 06:10:27 +0000 Subject: [PATCH] Check for ldap_initialize and other functions that Solaris (Mozilla-based) LDAP does not provide, and define versions a couple of them if needed. Based on patches from and discussions with Will Fiveash. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18665 dc483132-0cff-0310-8789-dd5450dbe970 --- src/configure.in | 4 ++ src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h | 9 ++++ src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c | 51 ++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/src/configure.in b/src/configure.in index f23211ea2..8bd817057 100644 --- a/src/configure.in +++ b/src/configure.in @@ -909,6 +909,10 @@ if test -n "$OPENLDAP_PLUGIN"; then if test $ac_cv_header_ldap_h = no || test $ac_cv_header_lber_h = no; then AC_ERROR(OpenLDAP headers missing) fi + old_LIBS="$LIBS" + LIBS="$LIBS -lldap" + AC_CHECK_FUNCS(ldap_initialize ldap_url_parse_nodn ldap_unbind_ext_s ldap_str2dn ldap_explode_dn) + LIBS="$old_LIBS" AC_CONFIG_SUBDIRS(plugins/kdb/ldap/libkdb_ldap) K5_GEN_MAKEFILE(plugins/kdb/ldap) K5_GEN_MAKEFILE(plugins/kdb/ldap/ldap_util) diff --git a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h index a8ec7aa6d..93a47acf9 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h +++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h @@ -304,4 +304,13 @@ krb5_ldap_errcode_2_string( krb5_context, long ); void krb5_ldap_release_errcode_string (krb5_context, const char *); +#ifndef HAVE_LDAP_INITIALIZE +int +ldap_initialize(LDAP **, char *); +#endif +#ifndef HAVE_LDAP_UNBIND_EXT_S +int +ldap_unbind_ext_s(LDAP *, LDAPControl **, LDAPControl **); +#endif + #endif diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c index f7275916a..6a767fe68 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c @@ -1845,3 +1845,54 @@ krb5_error_code remove_overlapping_subtrees(char **listin, char ***listop, int * } return 0; } + +/* + * Solaris libldap does not provide the following functions which are in + * OpenLDAP. + */ +#ifndef HAVE_LDAP_INITIALIZE +int +ldap_initialize(LDAP **ldp, char *url) +{ + int rc = 0; + LDAP *ld = NULL; + LDAPURLDesc *ludp = NULL; + + /* For now, we don't use any DN that may be provided. And on + Solaris (based on Mozilla's LDAP client code), we need the + _nodn form to parse "ldap://host" without a trailing slash. + + Also, this version won't handle an input string which contains + multiple URLs, unlike the OpenLDAP ldap_initialize. See + https://bugzilla.mozilla.org/show_bug.cgi?id=353336#c1 . */ +#ifdef HAVE_LDAP_URL_PARSE_NODN + rc = ldap_url_parse_nodn(url, &ludp); +#else + rc = ldap_url_parse(url, &ludp); +#endif + if (rc == 0) { + + ld = ldap_init(ludp->lud_host, ludp->lud_port); + if (ld != NULL) { + *ldp = ld; +#if 0 + printf("lud_host %s lud_port %d\n", ludp->lud_host, + ludp->lud_port); +#endif + } + else + rc = KRB5_KDB_ACCESS_ERROR; + + ldap_free_urldesc(ludp); + } + return rc; +} +#endif /* HAVE_LDAP_INITIALIZE */ + +#ifndef HAVE_LDAP_UNBIND_EXT_S +int +ldap_unbind_ext_s(LDAP *ld, LDAPControl **sctrls, LDAPControl **cctrls) +{ + return ldap_unbind_ext(ld, sctrls, cctrls); +} +#endif /* HAVE_LDAP_UNBIND_EXT_S */ -- 2.26.2