From bf6906d3dd8288fa2b31892f561ddd8d6e03a5a9 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Fri, 1 Sep 2006 02:51:38 +0000 Subject: [PATCH] Reject old OpenLDAP versions with bugs tickled by this code. Clean up some warnings during the build. * ldap_misc.c (strptime) [NEED_STRPTIME_PROTO]: Declare, conditionally. (krb5_ldap_errcode_2_string): Return string, not error code, to fit with DAL interface spec. * kdb_ldap.h: Error out for OpenLDAP versions before 2.2.24. (LDAP_DEPRECATED): Define; openldap-2.3.27 defaults to undefined. (krb5_ldap_lib_init): Prototype. (krb5_get_policydn): Declare. (krb5_ldap_errcode_2_string): Fix return type. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18558 dc483132-0cff-0310-8789-dd5450dbe970 --- src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h | 17 +++++++++++++++-- src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c | 10 ++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h index 295ba263b..81fc6f636 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h +++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h @@ -32,7 +32,17 @@ #ifndef _KDB_LDAP_H #define _KDB_LDAP_H 1 +/* We want the interfaces marked "deprecated" in OpenLDAP. */ +#define LDAP_DEPRECATED 1 #include + +/* Check for acceptable versions. */ +#if defined(LDAP_API_FEATURE_X_OPENLDAP) +# if LDAP_VENDOR_VERSION < 20224 +# error This code triggers bugs in old OpenLDAP implementations. Please update to 2.2.24 or later. +# endif +#endif + #include #include #include "k5-int.h" @@ -229,7 +239,7 @@ krb5_error_code krb5_ldap_db_get_age(krb5_context, char *, time_t *); krb5_error_code -krb5_ldap_lib_init(); +krb5_ldap_lib_init(void); krb5_error_code krb5_ldap_lib_cleanup(void); @@ -259,6 +269,9 @@ krb5_ldap_read_startup_information(krb5_context ); int has_sasl_external_mech(krb5_context, char *); +krb5_error_code +krb5_get_policydn(krb5_context, krb5_db_entry *, char **); + /* DAL functions */ krb5_error_code @@ -276,7 +289,7 @@ krb5_ldap_supported_realms( krb5_context, char ** ); krb5_error_code krb5_ldap_free_supported_realms( krb5_context, char ** ); -krb5_error_code +const char * krb5_ldap_errcode_2_string( krb5_context, long ); #endif diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c index 41cea5ff2..f64d7d0e2 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c @@ -33,6 +33,10 @@ #include "ldap_misc.h" #include "ldap_err.h" +#ifdef NEED_STRPTIME_PROTO +extern char *strptime (const char *, const char *, struct tm *); +#endif + /* * This function reads the parameters from the krb5.conf file. The parameters read here are * DAL-LDAP specific attributes. Some of these are ldap_port, ldap_server .... @@ -1505,11 +1509,9 @@ krb5_ldap_free_supported_realms(krb5_context kcontext, char **realms) return status; } -krb5_error_code +const char * krb5_ldap_errcode_2_string(krb5_context kcontext, long err_code) { - krb5_error_code status = KRB5_PLUGIN_OP_NOTSUPP; - krb5_set_error_message(kcontext, status, "LDAP %s", error_message(status)); - return status; + return error_message(err_code); } -- 2.26.2