From 681a146fe83413ebb0b73b01292840e90f7a8327 Mon Sep 17 00:00:00 2001 From: Kurt Spanier Date: Mon, 13 Sep 1999 16:28:30 +0000 Subject: [PATCH] Adopt TWEB to LDAP_API_VERSION >= 2003. --- contrib/tweb/dn.c | 16 +++++++----- contrib/tweb/queries.c | 53 ++++++++++++++++++------------------- contrib/tweb/tgeneral.h | 22 ++++++++++++++-- contrib/tweb/tglobal.h | 15 +++++------ contrib/tweb/tweb.h | 17 +++++------- contrib/tweb/x500.c | 58 ++++++++++++++++++++++------------------- 6 files changed, 99 insertions(+), 82 deletions(-) diff --git a/contrib/tweb/dn.c b/contrib/tweb/dn.c index 7518372cbe..86060bbfe9 100644 --- a/contrib/tweb/dn.c +++ b/contrib/tweb/dn.c @@ -16,21 +16,27 @@ * Creation date: Z D D V V * * April 24 1996 Z D D V V * * Last modification: Z D D V V * -* December 14 1996 ZZZZ DDD V * +* September 13 1999 ZZZZ DDD V * * * _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ /* - * $Id: dn.c,v 1.6 1999/09/10 15:01:16 zrnsk01 Exp $ + * $Id: dn.c,v 1.8 1999/09/13 13:47:44 zrnsk01 Exp $ * */ /* dn.c - routines for dealing with distinguished names */ #include "tgeneral.h" +#include "tglobal.h" #include "strng_exp.h" #include "dn.h" +#if OL_LDAPV == 2 +#define LDAP_DEBUG_ANY 0xffff +#endif + + /* * dn_normalize - put dn into a canonical format. the dn is * normalized in place, as well as returned. @@ -119,10 +125,7 @@ char *dn; break; default: -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 - -# define LDAP_DEBUG_ANY 0xffff +#if OL_LDAPV >= 2 if ( ldap_debug & LDAP_DEBUG_ANY ) fprintf( stderr, "dn_normalize - unknown state %d\n", state ); @@ -131,7 +134,6 @@ char *dn; syslog( ldap_syslog_level, "dn_normalize - unknown state %d\n", state ); -# endif #else Debug( LDAP_DEBUG_ANY, "dn_normalize - unknown state %d\n", state, 0, 0 ); diff --git a/contrib/tweb/queries.c b/contrib/tweb/queries.c index 1e0ebb40cc..5c19448465 100644 --- a/contrib/tweb/queries.c +++ b/contrib/tweb/queries.c @@ -15,12 +15,12 @@ * Creation date: Z D D V V * * August 16 1995 Z D D V V * * Last modification: Z D D V V * -* May 11 1999 ZZZZ DDD V * +* September 13 1999 ZZZZ DDD V * * * _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ /* - * $Id: queries.c,v 1.6 1999/09/10 15:01:18 zrnsk01 Exp $ + * $Id: queries.c,v 1.8 1999/09/13 13:47:47 zrnsk01 Exp $ * */ @@ -43,6 +43,10 @@ struct hostent *hp; LDAP *ld; char tstring[100]; +#if OL_LDAPV > 0 + int ldap_opt; +#endif + /* get time for performance log */ gettimeofday(×tore[2], NULL); @@ -85,7 +89,13 @@ struct hostent *hp; len = strlen( buf ); if ( debug ) { fprintf( stderr, "got %d bytes\n", len ); + +#if OL_LDAPV > 2 + ber_bprint( buf, len ); +#else lber_bprint( buf, len ); +#endif + } /* strip of white spaces */ @@ -309,23 +319,21 @@ struct hostent *hp; rewind(fp); /* follow aliases while searching */ -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS ); + ldap_opt = LDAP_DEREF_ALWAYS; + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = LDAP_DEREF_ALWAYS; #endif if ( !searchaliases ) -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_FINDING ); + ldap_opt = LDAP_DEREF_FINDING; + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = LDAP_DEREF_FINDING; #endif @@ -376,32 +384,29 @@ struct hostent *hp; glob->svc_cnt); /* accesses with resolvation of alias-entries */ -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS ); + ldap_opt = LDAP_DEREF_ALWAYS; + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = LDAP_DEREF_ALWAYS; #endif if ( !searchaliases ) -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_FINDING ); + ldap_opt = LDAP_DEREF_FINDING; + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = LDAP_DEREF_FINDING; #endif /* bind to DSA by order of the user as Web-DN - (if with DN1 or DN2 was decided at check4access) */ + (DN1 or DN2 was decided at check4access) */ -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 /* a dummy call as long as socket connections are not settled * with OpenLDAP @@ -409,12 +414,6 @@ struct hostent *hp; if ( dosyslog ) syslog( LOG_INFO, "do_queries(): calling ldap_simple_bind_s()...\n" ); -# else - - if ( dosyslog ) - syslog( LOG_INFO, "do_queries(): calling ldap_simple_bind_s()...\n" ); - -# endif #endif if ( (rc=ldap_simple_bind_s( ld, glob->webdn, glob->webpw )) diff --git a/contrib/tweb/tgeneral.h b/contrib/tweb/tgeneral.h index 4eb0adcbf8..bdaf57be7f 100644 --- a/contrib/tweb/tgeneral.h +++ b/contrib/tweb/tgeneral.h @@ -14,12 +14,12 @@ * Creation date: Z D D V V * * August 16 1995 Z D D V V * * Last modification: Z D D V V * -* May 14 1999 ZZZZ DDD V * +* September 13 1999 ZZZZ DDD V * * * _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ /* - * $Id: tgeneral.h,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $ + * $Id: tgeneral.h,v 1.8 1999/09/13 13:47:47 zrnsk01 Exp $ * */ @@ -68,6 +68,24 @@ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ #include #include +/* Support of LDAP API versions */ +#if LDAP_API_VERSION >= 2003 && LDAP_API_VERSION <= 2010 +#define OL_LDAPV 3 +#else +# if LDAP_API_VERSION >= 2001 && LDAP_API_VERSION <= 2010 +# define OL_LDAPV 2 +# else +# define OL_LDAPV 0 +# endif +#endif + +# define ldap_debug debug + +#if OL_LDAPV > 2 +# include "portable.h" +# include "ldap_log.h" +#endif + extern int errno; diff --git a/contrib/tweb/tglobal.h b/contrib/tweb/tglobal.h index f115592ad5..147c32049b 100644 --- a/contrib/tweb/tglobal.h +++ b/contrib/tweb/tglobal.h @@ -13,12 +13,12 @@ * Creation date: Z D D V V * * August 16 1996 Z D D V V * * Last modification: Z D D V V * -* December 29 1998 ZZZZ DDD V * +* September 13 1999 ZZZZ DDD V * * * _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ /* - * $Id: tglobal.h,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $ + * $Id: tglobal.h,v 1.8 1999/09/13 13:47:47 zrnsk01 Exp $ * */ @@ -32,21 +32,18 @@ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ extern int debug; extern int dosyslog; +extern int ldap_syslog; +extern int ldap_syslog_level; + extern struct timeval timestore[]; extern int items_displayed; extern int searchaliases; -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 - -extern LDAPFriendlyMap *fm; - -# else +#if OL_LDAPV >= 2 extern LDAPFriendlyMap *fm; -# endif #else extern FriendlyMap *fm; diff --git a/contrib/tweb/tweb.h b/contrib/tweb/tweb.h index fe1d49ec61..1c6869e851 100644 --- a/contrib/tweb/tweb.h +++ b/contrib/tweb/tweb.h @@ -14,12 +14,12 @@ * Creation date: Z D D V V * * August 16 1995 Z D D V V * * Last modification: Z D D V V * -* December 31 1998 ZZZZ DDD V * +* September 13 1999 ZZZZ DDD V * * * _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ /* - * $Id: tweb.h,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $ + * $Id: tweb.h,v 1.8 1999/09/13 13:47:47 zrnsk01 Exp $ * */ @@ -34,23 +34,20 @@ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ #include "support_exp.h" PRIVATE void do_child(); -int debug; +int debug = 0; +int ldap_syslog = 0; +int ldap_syslog_level = 0; + int dosyslog = 0; GLOB_STRUCT *globP; int searchaliases = 1; -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 - -LDAPFriendlyMap *fm = NULL; - -# else +#if OL_LDAPV >= 2 LDAPFriendlyMap *fm = NULL; -# endif #else FriendlyMap *fm = NULL; diff --git a/contrib/tweb/x500.c b/contrib/tweb/x500.c index a8a02f70a2..447060fbde 100644 --- a/contrib/tweb/x500.c +++ b/contrib/tweb/x500.c @@ -15,12 +15,12 @@ * Creation date: Z D D V V * * August 16 1995 Z D D V V * * Last modification: Z D D V V * -* September 10 1999 ZZZZZ DDD V * +* September 13 1999 ZZZZZ DDD V * * * _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ /* - * $Id: x500.c,v 1.8 1999/09/10 15:01:20 zrnsk01 Exp $ + * $Id: x500.c,v 1.10 1999/09/13 13:47:48 zrnsk01 Exp $ * */ @@ -143,6 +143,10 @@ GLOB_STRUCT *glob; int count; char *ufn; +#if OL_LDAPV > 0 + int ldap_opt; +#endif + if(!attrs) attrs = (char**) charray_dup(sattrs); @@ -162,12 +166,11 @@ GLOB_STRUCT *glob; timeout.tv_sec = glob->timeout; timeout.tv_usec = 0; -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS ); + ldap_opt = LDAP_DEREF_FINDING; + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = LDAP_DEREF_FINDING; #endif @@ -182,12 +185,11 @@ GLOB_STRUCT *glob; if (rc == LDAP_SIZELIMIT_EXCEEDED) glob->persRestricted = TRUE; -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS ); + ldap_opt = LDAP_DEREF_ALWAYS; + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = LDAP_DEREF_ALWAYS; #endif @@ -348,6 +350,10 @@ GLOB_STRUCT *glob; char *ufn; char title[BUFSIZ], title2[BUFSIZ]; +#if OL_LDAPV > 0 + int ldap_opt; +#endif + glob->no_browse = FALSE; /* query string: base-DN?[OS]=filter @@ -384,14 +390,12 @@ GLOB_STRUCT *glob; filtertype = (scope == LDAP_SCOPE_ONELEVEL ? "web500gw onelevel" : "web500gw subtree"); -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, - scope == LDAP_SCOPE_ONELEVEL ? LDAP_DEREF_FINDING : - LDAP_DEREF_ALWAYS ); + ldap_opt = ( scope == LDAP_SCOPE_ONELEVEL ? LDAP_DEREF_FINDING : + LDAP_DEREF_ALWAYS ); + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = (scope == LDAP_SCOPE_ONELEVEL ? LDAP_DEREF_FINDING : LDAP_DEREF_ALWAYS); @@ -408,8 +412,7 @@ GLOB_STRUCT *glob; if (dosyslog) { -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 int ld_errno; @@ -417,7 +420,6 @@ GLOB_STRUCT *glob; syslog (LOG_INFO, "ldap_search_st(): %s", ldap_err2string ( ld_errno )); -# endif #else syslog (LOG_INFO, "ldap_search_st(): %s", ldap_err2string (ld->ld_errno)); @@ -437,12 +439,11 @@ GLOB_STRUCT *glob; } items_displayed = count; -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS ); + ldap_opt = LDAP_DEREF_ALWAYS; + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = LDAP_DEREF_ALWAYS; #endif @@ -1660,6 +1661,10 @@ GLOB_STRUCT *glob; char *url = NULL; char **uri = NULL, *urlnola, raw_string[BUFSIZ]; +#if OL_LDAPV > 0 + int ldap_opt; +#endif + oc = ldap_get_values( ld, e, "objectClass" ); if(!(aoc = make_oc_to_string(oc))) return; @@ -1816,12 +1821,11 @@ GLOB_STRUCT *glob; timeout.tv_sec = glob->timeout; timeout.tv_usec = 0; -#if defined LDAP_VENDOR_NAME && defined LDAP_API_VERSION -# if LDAP_API_VERSION > 2001 && LDAP_API_VERSION < 2010 +#if OL_LDAPV > 0 - ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS ); + ldap_opt = LDAP_DEREF_ALWAYS; + ldap_set_option( ld, LDAP_OPT_DEREF, &ldap_opt ); -# endif #else ld->ld_deref = LDAP_DEREF_ALWAYS; #endif -- 2.39.5