diff --git a/Make-common b/Make-common index 405842cc4f..5867e37262 100644 --- a/Make-common +++ b/Make-common @@ -197,6 +197,10 @@ LDAP_DEBUG=-DLDAP_DEBUG # uncomment this line to enable support for LDAP referrals in libldap LDAP_REFERRALS=-DLDAP_REFERRALS +# uncomment this line to enable support for CRYPT passwords in LDBM +# requires UNIX crypt(3) +LDAP_CRYPT=-DLDAP_CRYPT + # uncomment this line to use soundex for approximate matches in slapd. # the default is to use the metaphone algorithm. #PHONETIC=-DSOUNDEX diff --git a/build/Make-append b/build/Make-append index 67a2f29bb0..32c3d1cc9c 100644 --- a/build/Make-append +++ b/build/Make-append @@ -21,7 +21,7 @@ # DEFS are included in CFLAGS DEFS = $(PLATFORMCFLAGS) $(LDAP_DEBUG) $(KERBEROS) $(AFSKERBEROS) \ $(UOFM) $(UOFA) $(NO_USERINTERFACE) $(CLDAP) $(NO_CACHE) \ - $(LDAP_REFERRALS) $(LDAP_DNS) $(STR_TRANSLATION) \ + $(LDAP_REFERRALS) $(LDAP_CRYPT) $(LDAP_DNS) $(STR_TRANSLATION) \ $(LIBLDAP_CHARSETS) $(LIBLDAP_DEF_CHARSET) \ $(SLAPD_BACKENDS) $(LDBMBACKEND) $(LDBMINCLUDE) $(PHONETIC) diff --git a/build/platforms/freebsd-gcc/Make-platform b/build/platforms/freebsd-gcc/Make-platform index b1e28023da..e7aef0ed8b 100644 --- a/build/platforms/freebsd-gcc/Make-platform +++ b/build/platforms/freebsd-gcc/Make-platform @@ -14,4 +14,6 @@ CC = cc PLATFORMCFLAGS= -Dfreebsd -PLATFORMLIBS= -lcrypt + +# uncomment this line if using for LDAP_CRYPT +PLATFORMLIBS= -lcrypt diff --git a/clients/fax500/xrpcomp b/clients/fax500/xrpcomp index 3a914eac78..39c59e38aa 100644 --- a/clients/fax500/xrpcomp +++ b/clients/fax500/xrpcomp @@ -1,4 +1,4 @@ -: run this script through /bin/sh +#! /bin/sh RP500=ETCDIR/rp500 diff --git a/clients/tools/Make-template b/clients/tools/Make-template index 2ad49462a5..4c577dce3d 100644 --- a/clients/tools/Make-template +++ b/clients/tools/Make-template @@ -111,8 +111,8 @@ ldapsearch.o: ../../include/ldapconfig.h ldapmodify.o: ldapmodify.c ../../include/lber.h ../../include/proto-ldap.h ldapmodify.o: ../../include/ldapconfig.h ldapdelete.o: ldapdelete.c ../../include/proto-lber.h -ldapdelete.o: ../../include/ldapconfig.h +ldapdelete.o: ../../include/proto-ldap.h ldapmodrdn.o: ldapmodrdn.c ../../include/proto-lber.h -ldapmodrdn.o: ../../include/ldapconfig.h +ldapmodrdn.o: ../../include/proto-ldap.h # IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/clients/ud/main.c b/clients/ud/main.c index cb2030c283..86c0b7567f 100644 --- a/clients/ud/main.c +++ b/clients/ud/main.c @@ -722,3 +722,22 @@ SIG_FN chwinsz() (void) signal(SIGWINCH, chwinsz); } #endif + +#if defined(NO_CACHE) + +void ldap_uncache_entry( LDAP *ld, char *dn ) +{ + +} + +int ldap_enable_cache( LDAP *ld, long timeout, long maxmem ) +{ + return 0; +} + +void ldap_flush_cache( LDAP *ld ) +{ + +} + +#endif /* NO_CACHE */ diff --git a/clients/ud/util.c b/clients/ud/util.c index 2edb5aa265..389b8a0d62 100644 --- a/clients/ud/util.c +++ b/clients/ud/util.c @@ -226,8 +226,6 @@ FILE *where; fatal(s) char *s; { - void exit(); - if (errno != 0) perror(s); #ifdef KERBEROS diff --git a/include/avl.h b/include/avl.h index 745cc17d61..46a1e7667a 100644 --- a/include/avl.h +++ b/include/avl.h @@ -21,7 +21,7 @@ typedef struct avlnode { caddr_t avl_data; - char avl_bf; + signed char avl_bf; struct avlnode *avl_left; struct avlnode *avl_right; } Avlnode; diff --git a/include/ldap.h b/include/ldap.h index 1eab5bda62..ee956742e7 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -295,7 +295,7 @@ typedef struct ldapmsg { BerElement *lm_ber; /* the ber encoded message contents */ struct ldapmsg *lm_chain; /* for search - next msg in the resp */ struct ldapmsg *lm_next; /* next response */ - unsigned long lm_time; /* used to maintain cache */ + unsigned int lm_time; /* used to maintain cache */ } LDAPMessage; #define NULLMSG ((LDAPMessage *) NULL) @@ -318,7 +318,7 @@ typedef struct ldap_server { typedef struct ldap_conn { Sockbuf *lconn_sb; int lconn_refcnt; - unsigned long lconn_lastused; /* time */ + unsigned int lconn_lastused; /* time */ int lconn_status; #define LDAP_CONNST_NEEDSOCKET 1 #define LDAP_CONNST_CONNECTING 2 @@ -569,6 +569,8 @@ extern char *strdup(); #else /* NEEDPROTOS */ #if !defined(MACOS) && !defined(DOS) && !defined(_WIN32) && !defined(WINSOCK) +#include +#include #include #endif #if defined(WINSOCK) diff --git a/include/lthread.h b/include/lthread.h index d1b34d8ecf..4a3b0a8072 100644 --- a/include/lthread.h +++ b/include/lthread.h @@ -3,7 +3,40 @@ #ifndef _LTHREAD_H #define _LTHREAD_H -#if defined( THREAD_SUNOS4_LWP ) +#if defined ( THREAD_NEXT_CTHREADS ) + +#define _THREAD + +#include + +typedef cthread_fn_t VFP; +typedef int pthread_attr_t; +typedef cthread_t pthread_t; + +/* default attr states */ +#define pthread_mutexattr_default NULL +#define pthread_condattr_default NULL + +/* thread state - joinable or not */ +#define PTHREAD_CREATE_JOINABLE 0 +#define PTHREAD_CREATE_DETACHED 1 +/* thread scope - who is in scheduling pool */ +#define PTHREAD_SCOPE_PROCESS 0 +#define PTHREAD_SCOPE_SYSTEM 1 + +/* mutex attributes and mutex type */ +typedef int pthread_mutexattr_t; +typedef struct mutex pthread_mutex_t; + +/* mutex and condition variable scope - process or system */ +#define PTHREAD_SHARE_PRIVATE 0 +#define PTHREAD_SHARE_PROCESS 1 + +/* condition variable attributes and condition variable type */ +typedef int pthread_condattr_t; +typedef struct condition pthread_cond_t; + +#elif defined( THREAD_SUNOS4_LWP ) /*********************************** * * * thread definitions for sunos4 * diff --git a/include/portable.h b/include/portable.h index a91b27a5d5..b64be6c79c 100644 --- a/include/portable.h +++ b/include/portable.h @@ -61,9 +61,9 @@ #endif /* - * on many systems, we should use waitpid() instead of waitN() + * on most systems, we should use waitpid() instead of waitN() */ -#if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix )) +#if !defined( USE_WAITPID ) && !defined( nextstep ) #define USE_WAITPID #endif diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 83242a02a8..a4fe65ae81 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -157,6 +157,7 @@ ber_getnint( BerElement *ber, long *num, int len ) { int diff, sign, i; long netnum; + char *p; /* * The tag and length have already been stripped off. We should @@ -174,11 +175,12 @@ ber_getnint( BerElement *ber, long *num, int len ) if ( ber_read( ber, ((char *) &netnum) + diff, len ) != len ) return( -1 ); - /* sign extend if necessary */ - sign = ((0x80 << ((len - 1) * 8)) & netnum); - if ( sign && len < sizeof(long) ) { - for ( i = sizeof(long) - 1; i > len - 1; i-- ) { - netnum |= (0xffL << (i * 8)); + /* sign extend if necessary */ + p = (char *) &netnum; + sign = (0x80 & *(p+diff) ); + if ( sign && len < sizeof(long) ) { + for ( i = 0; i < diff; i++ ) { + *(p+i) = 0xff; } } *num = LBER_NTOHL( netnum ); diff --git a/libraries/libldap/Make-template b/libraries/libldap/Make-template index 58aaff569b..8d04b53b77 100644 --- a/libraries/libldap/Make-template +++ b/libraries/libldap/Make-template @@ -118,11 +118,11 @@ unbind.o: unbind.c ../../include/proto-lber.h ../../include/proto-ldap.h friendly.o: friendly.c ../../include/lber.h ../../include/proto-ldap.h cldap.o: cldap.c free.o: free.c ../../include/ldap.h -disptmpl.o: disptmpl.c ../../include/proto-lber.h ../../include/proto-ldap.h -srchpref.o: srchpref.c ../../include/proto-lber.h ../../include/proto-ldap.h -dsparse.o: dsparse.c ../../include/proto-lber.h ../../include/proto-ldap.h +disptmpl.o: disptmpl.c ../../include/proto-lber.h ../../include/disptmpl.h +srchpref.o: srchpref.c ../../include/proto-lber.h ../../include/srchpref.h +dsparse.o: dsparse.c ../../include/proto-lber.h tmplout.o: tmplout.c ../../include/proto-lber.h ../../include/proto-ldap.h -sort.o: sort.c ../../include/proto-lber.h +sort.o: sort.c ../../include/proto-lber.h ../../include/proto-ldap.h getdn.o: getdn.c ../../include/lber.h ../../include/proto-ldap.h getentry.o: getentry.c ../../include/lber.h ../../include/proto-ldap.h getattr.o: getattr.c ../../include/lber.h ../../include/proto-ldap.h diff --git a/libraries/libldap/abandon.c b/libraries/libldap/abandon.c index 18324260bd..377beb7eb3 100644 --- a/libraries/libldap/abandon.c +++ b/libraries/libldap/abandon.c @@ -107,7 +107,7 @@ do_abandon( LDAP *ld, int origid, int msgid ) err = 0; if ( sendabandon ) { /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { err = -1; ld->ld_errno = LDAP_NO_MEMORY; } else { @@ -151,10 +151,10 @@ do_abandon( LDAP *ld, int origid, int msgid ) #ifdef LDAP_REFERRALS if ( lr != NULL ) { if ( sendabandon ) { - free_connection( ld, lr->lr_conn, 0, 1 ); + ldap_free_connection( ld, lr->lr_conn, 0, 1 ); } if ( origid == msgid ) { - free_request( ld, lr ); + ldap_free_request( ld, lr ); } } #endif /* LDAP_REFERRALS */ diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index b79cd09b9d..143e36e161 100644 --- a/libraries/libldap/add.c +++ b/libraries/libldap/add.c @@ -69,7 +69,7 @@ ldap_add( LDAP *ld, char *dn, LDAPMod **attrs ) Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -103,7 +103,7 @@ ldap_add( LDAP *ld, char *dn, LDAPMod **attrs ) } /* send the message */ - return( send_initial_request( ld, LDAP_REQ_ADD, dn, ber )); + return( ldap_send_initial_request( ld, LDAP_REQ_ADD, dn, ber )); } int diff --git a/libraries/libldap/cache.c b/libraries/libldap/cache.c index 197f4fb9e3..7925f08fe0 100644 --- a/libraries/libldap/cache.c +++ b/libraries/libldap/cache.c @@ -214,12 +214,12 @@ uncache_entry_or_req( LDAP *ld, void -add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) +ldap_add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) { LDAPMessage *new; long len; - Debug( LDAP_DEBUG_TRACE, "add_request_to_cache\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_add_request_to_cache\n", 0, 0, 0 ); ld->ld_errno = LDAP_SUCCESS; if ( ld->ld_cache == NULLLDCACHE || @@ -229,7 +229,7 @@ add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) if (( new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) )) != NULL ) { - if (( new->lm_ber = alloc_ber_with_options( ld )) == NULLBER ) { + if (( new->lm_ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { free( (char *)new ); return; } @@ -256,12 +256,12 @@ add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) void -add_result_to_cache( LDAP *ld, LDAPMessage *result ) +ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) { LDAPMessage *m, **mp, *req, *new, *prev; int err, keep; - Debug( LDAP_DEBUG_TRACE, "add_result_to_cache: id %d, type %d\n", + Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %d, type %d\n", result->lm_msgid, result->lm_msgtype, 0 ); if ( ld->ld_cache == NULLLDCACHE || @@ -369,14 +369,14 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result ) * will find them. */ int -check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) +ldap_check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) { LDAPMessage *m, *new, *prev, *next; BerElement reqber; int first, hash; unsigned long validtime; - Debug( LDAP_DEBUG_TRACE, "check_cache\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_check_cache\n", 0, 0, 0 ); if ( ld->ld_cache == NULLLDCACHE || ( ld->ld_cache->lc_enabled == 0 )) { diff --git a/libraries/libldap/cldap.c b/libraries/libldap/cldap.c index 19782f77d8..806a6ce91c 100644 --- a/libraries/libldap/cldap.c +++ b/libraries/libldap/cldap.c @@ -170,7 +170,7 @@ cldap_open( char *host, int port ) if ( ld->ld_sb.sb_addrs == NULL #ifdef LDAP_REFERRALS - || ( ld->ld_defconn = new_connection( ld, NULL, 1,0,0 )) == NULL + || ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL #endif /* LDAP_REFERRALS */ ) { free( ld ); @@ -316,7 +316,7 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res, "cldap_result waiting up to %d seconds for a response\n", tv.tv_sec, 0, 0 ); ber_init( &ber, 0 ); - set_ber_options( ld, &ber ); + ldap_set_ber_options( ld, &ber ); if ( cldap_getmsg( ld, &tv, &ber ) == -1 ) { ret = ld->ld_errno; @@ -432,7 +432,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, tag != LBER_DEFAULT && rc != LDAP_SUCCESS; tag = ber_next_element( ber, &len, cookie )) { if (( ldm = (LDAPMessage *)calloc( 1, sizeof(LDAPMessage))) - == NULL || ( ldm->lm_ber = alloc_ber_with_options( ld )) + == NULL || ( ldm->lm_ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { rc = LDAP_NO_MEMORY; break; /* return w/error*/ @@ -506,7 +506,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, #ifndef NO_CACHE if ( ld->ld_cache != NULL ) { - add_result_to_cache( ld, ldm ); + ldap_add_result_to_cache( ld, ldm ); } #endif /* NO_CACHE */ diff --git a/libraries/libldap/compare.c b/libraries/libldap/compare.c index 74388f1cea..ba9f89850c 100644 --- a/libraries/libldap/compare.c +++ b/libraries/libldap/compare.c @@ -52,7 +52,7 @@ ldap_compare( LDAP *ld, char *dn, char *attr, char *value ) Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -65,17 +65,17 @@ ldap_compare( LDAP *ld, char *dn, char *attr, char *value ) #ifndef NO_CACHE if ( ld->ld_cache != NULL ) { - if ( check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) { + if ( ldap_check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) { ber_free( ber, 1 ); ld->ld_errno = LDAP_SUCCESS; return( ld->ld_msgid ); } - add_request_to_cache( ld, LDAP_REQ_COMPARE, ber ); + ldap_add_request_to_cache( ld, LDAP_REQ_COMPARE, ber ); } #endif /* NO_CACHE */ /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber )); } int diff --git a/libraries/libldap/delete.c b/libraries/libldap/delete.c index 47e240ea6a..75344ddd88 100644 --- a/libraries/libldap/delete.c +++ b/libraries/libldap/delete.c @@ -51,7 +51,7 @@ ldap_delete( LDAP *ld, char *dn ) Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -63,7 +63,7 @@ ldap_delete( LDAP *ld, char *dn ) } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_DELETE, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_DELETE, dn, ber )); } diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index 50caa774c5..f893529e8c 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -36,7 +36,7 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber ) Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 ); - if ( (*ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( NULL ); } diff --git a/libraries/libldap/getdxbyname.c b/libraries/libldap/getdxbyname.c index 50683f6c37..833af5adae 100644 --- a/libraries/libldap/getdxbyname.c +++ b/libraries/libldap/getdxbyname.c @@ -3,7 +3,7 @@ * Copyright (c) 1995 Regents of the University of Michigan. * All rights reserved. * - * getdxbyname - retrieve DX records from the DNS (from TXT records for now) + * ldap_getdxbyname - retrieve DX records from the DNS (from TXT records for now) */ #include #include @@ -47,17 +47,17 @@ extern char *h_errlist[]; /* - * getdxbyname - lookup DNS DX records for domain and return an ordered + * ldap_getdxbyname - lookup DNS DX records for domain and return an ordered * array. */ char ** -getdxbyname( char *domain ) +ldap_getdxbyname( char *domain ) { unsigned char buf[ PACKETSZ ]; char **dxs; int rc; - Debug( LDAP_DEBUG_TRACE, "getdxbyname( %s )\n", domain, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_getdxbyname( %s )\n", domain, 0, 0 ); memset( buf, 0, sizeof( buf )); diff --git a/libraries/libldap/kbind.c b/libraries/libldap/kbind.c index ce4a8a7f6d..6ed05253c0 100644 --- a/libraries/libldap/kbind.c +++ b/libraries/libldap/kbind.c @@ -52,7 +52,7 @@ ldap_kerberos_bind1( LDAP *ld, char *dn ) BerElement *ber; char *cred; int rc, credlen; - char *get_kerberosv4_credentials(); + char *ldap_get_kerberosv4_credentials(); #ifdef STR_TRANSLATION int str_translation_on; #endif /* STR_TRANSLATION */ @@ -75,13 +75,13 @@ ldap_kerberos_bind1( LDAP *ld, char *dn ) if ( dn == NULL ) dn = ""; - if ( (cred = get_kerberosv4_credentials( ld, dn, "ldapserver", + if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "ldapserver", &credlen )) == NULL ) { return( -1 ); /* ld_errno should already be set */ } /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { free( cred ); return( -1 ); } @@ -119,7 +119,7 @@ ldap_kerberos_bind1( LDAP *ld, char *dn ) #endif /* !NO_CACHE */ /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); } int @@ -159,7 +159,7 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) BerElement *ber; char *cred; int rc, credlen; - char *get_kerberosv4_credentials(); + char *ldap_get_kerberosv4_credentials(); #ifdef STR_TRANSLATION int str_translation_on; #endif /* STR_TRANSLATION */ @@ -169,13 +169,13 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) if ( dn == NULL ) dn = ""; - if ( (cred = get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen )) + if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen )) == NULL ) { return( -1 ); /* ld_errno should already be set */ } /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { free( cred ); return( -1 ); } @@ -207,7 +207,7 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); } /* synchronous bind to DSA using kerberos */ @@ -249,19 +249,19 @@ ldap_kerberos_bind_s( LDAP *ld, char *dn ) #ifndef AUTHMAN /* - * get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. + * ldap_get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. * The dn of the entry to which to bind is supplied. It's assumed the * user already has a tgt. */ char * -get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) +ldap_get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) { KTEXT_ST ktxt; int err; char realm[REALM_SZ], *cred, *krbinstance; - Debug( LDAP_DEBUG_TRACE, "get_kerberosv4_credentials\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_kerberosv4_credentials\n", 0, 0, 0 ); if ( (err = krb_get_tf_realm( tkt_string(), realm )) != KSUCCESS ) { #ifndef NO_USERINTERFACE diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index 10adbe91ff..e841a35b5b 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -27,14 +27,14 @@ * in cache.c */ #ifdef NEEDPROTOS -void add_request_to_cache( LDAP *ld, unsigned long msgtype, +void ldap_add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request ); -void add_result_to_cache( LDAP *ld, LDAPMessage *result ); -int check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ); +void ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ); +int ldap_check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ); #else /* NEEDPROTOS */ -void add_request_to_cache(); -void add_result_to_cache(); -int check_cache(); +void ldap_add_request_to_cache(); +void ldap_add_result_to_cache(); +int ldap_check_cache(); #endif /* NEEDPROTOS */ @@ -43,10 +43,10 @@ int check_cache(); * in kerberos.c */ #ifdef NEEDPROTOS -char *get_kerberosv4_credentials( LDAP *ld, char *who, char *service, +char *ldap_get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ); #else /* NEEDPROTOS */ -char *get_kerberosv4_credentials(); +char *ldap_get_kerberosv4_credentials(); #endif /* NEEDPROTOS */ #endif /* KERBEROS */ @@ -67,17 +67,17 @@ int open_ldap_connection(); * in os-ip.c */ #ifdef NEEDPROTOS -int connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port, +int ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port, int async ); -void close_connection( Sockbuf *sb ); +void ldap_close_connection( Sockbuf *sb ); #else /* NEEDPROTOS */ -int connect_to_host(); -void close_connection(); +int ldap_connect_to_host(); +void ldap_close_connection(); #endif /* NEEDPROTOS */ #ifdef KERBEROS #ifdef NEEDPROTOS -char *host_connected_to( Sockbuf *sb ); +char *ldap_host_connected_to( Sockbuf *sb ); #else /* NEEDPROTOS */ char *host_connected_to(); #endif /* NEEDPROTOS */ @@ -86,22 +86,22 @@ char *host_connected_to(); #ifdef LDAP_REFERRALS #ifdef NEEDPROTOS int do_ldap_select( LDAP *ld, struct timeval *timeout ); -void *new_select_info( void ); -void free_select_info( void *sip ); -void mark_select_write( LDAP *ld, Sockbuf *sb ); -void mark_select_read( LDAP *ld, Sockbuf *sb ); -void mark_select_clear( LDAP *ld, Sockbuf *sb ); -int is_read_ready( LDAP *ld, Sockbuf *sb ); -int is_write_ready( LDAP *ld, Sockbuf *sb ); +void *ldap_new_select_info( void ); +void ldap_free_select_info( void *sip ); +void ldap_mark_select_write( LDAP *ld, Sockbuf *sb ); +void ldap_mark_select_read( LDAP *ld, Sockbuf *sb ); +void ldap_mark_select_clear( LDAP *ld, Sockbuf *sb ); +int ldap_is_read_ready( LDAP *ld, Sockbuf *sb ); +int ldap_is_write_ready( LDAP *ld, Sockbuf *sb ); #else /* NEEDPROTOS */ int do_ldap_select(); -void *new_select_info(); -void free_select_info(); -void mark_select_write(); -void mark_select_read(); -void mark_select_clear(); -int is_read_ready(); -int is_write_ready(); +void *ldap_new_select_info(); +void ldap_free_select_info(); +void ldap_mark_select_write(); +void ldap_mark_select_read(); +void ldap_mark_select_clear(); +int ldap_is_read_ready(); +int ldap_is_write_ready(); #endif /* NEEDPROTOS */ #endif /* LDAP_REFERRALS */ @@ -110,46 +110,46 @@ int is_write_ready(); * in request.c */ #ifdef NEEDPROTOS -int send_initial_request( LDAP *ld, unsigned long msgtype, +int ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, BerElement *ber ); -BerElement *alloc_ber_with_options( LDAP *ld ); -void set_ber_options( LDAP *ld, BerElement *ber ); +BerElement *ldap_alloc_ber_with_options( LDAP *ld ); +void ldap_set_ber_options( LDAP *ld, BerElement *ber ); #else /* NEEDPROTOS */ -int send_initial_request(); -BerElement *alloc_ber_with_options(); -void set_ber_options(); +int ldap_send_initial_request(); +BerElement *ldap_alloc_ber_with_options(); +void ldap_set_ber_options(); #endif /* NEEDPROTOS */ #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) #ifdef NEEDPROTOS -int send_server_request( LDAP *ld, BerElement *ber, int msgid, +int ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind ); -LDAPConn *new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, +LDAPConn *ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, int connect, int bind ); -LDAPRequest *find_request_by_msgid( LDAP *ld, int msgid ); -void free_request( LDAP *ld, LDAPRequest *lr ); -void free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ); -void dump_connection( LDAP *ld, LDAPConn *lconns, int all ); -void dump_requests_and_responses( LDAP *ld ); +LDAPRequest *ldap_find_request_by_msgid( LDAP *ld, int msgid ); +void ldap_free_request( LDAP *ld, LDAPRequest *lr ); +void ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ); +void ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all ); +void ldap_dump_requests_and_responses( LDAP *ld ); #else /* NEEDPROTOS */ -int send_server_request(); -LDAPConn *new_connection(); -LDAPRequest *find_request_by_msgid(); -void free_request(); -void free_connection(); -void dump_connection(); -void dump_requests_and_responses(); +int ldap_send_server_request(); +LDAPConn *ldap_new_connection(); +LDAPRequest *ldap_find_request_by_msgid(); +void ldap_free_request(); +void ldap_free_connection(); +void ldap_dump_connection(); +void ldap_dump_requests_and_responses(); #endif /* NEEDPROTOS */ #endif /* LDAP_REFERRALS || LDAP_DNS */ #ifdef LDAP_REFERRALS #ifdef NEEDPROTOS -int chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ); -int append_referral( LDAP *ld, char **referralsp, char *s ); +int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ); +int ldap_append_referral( LDAP *ld, char **referralsp, char *s ); #else /* NEEDPROTOS */ -int chase_referrals(); -int append_referral(); +int ldap_chase_referrals(); +int ldap_append_referral(); #endif /* NEEDPROTOS */ #endif /* LDAP_REFERRALS */ @@ -170,10 +170,10 @@ BerElement *ldap_build_search_req(); */ #ifdef NEEDPROTOS int ldap_ld_free( LDAP *ld, int close ); -int send_unbind( LDAP *ld, Sockbuf *sb ); +int ldap_send_unbind( LDAP *ld, Sockbuf *sb ); #else /* NEEDPROTOS */ int ldap_ld_free(); -int send_unbind(); +int ldap_send_unbind(); #endif /* NEEDPROTOS */ @@ -182,8 +182,31 @@ int send_unbind(); * in getdxbyname.c */ #ifdef NEEDPROTOS -char **getdxbyname( char *domain ); +char **ldap_getdxbyname( char *domain ); #else /* NEEDPROTOS */ -char **getdxbyname(); +char **ldap_getdxbyname(); #endif /* NEEDPROTOS */ #endif /* LDAP_DNS */ + +#if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET ) +/* + * in charset.c + * + * added-in this stuff so that libldap.a would build, i.e. refs to + * these routines from open.c would resolve. + * hodges@stanford.edu 5-Feb-96 + */ +#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET +#ifdef NEEDPROTOS +extern +int ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input ); +extern +int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input ); +#else /* NEEDPROTOS */ +extern +int ldap_t61_to_8859(); +extern +int ldap_8859_to_t61(); +#endif /* NEEDPROTOS */ +#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */ +#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */ diff --git a/libraries/libldap/ldapfilter.conf b/libraries/libldap/ldapfilter.conf index c602f7d2e7..8abae88636 100644 --- a/libraries/libldap/ldapfilter.conf +++ b/libraries/libldap/ldapfilter.conf @@ -24,33 +24,35 @@ # "finger and ud and go500 and go500gw subtree and web500gw subtree and rp500 and rcpt500 and ufn last" + "^$" "" "(objectclass=*)" "default filter" "=" " " "%v" "arbitrary filter" - "^[0-9][0-9-]*$" " " "(telephoneNumber=*%v)" "phone number" + "^[0-9][0-9\-]*$" " " "(telephoneNumber=*%v)" "phone number" "@" " " "(mail=%v)" "email address" "(mail=%v*)" "start of email address" - "^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial" + "^.[\. _].*" ". _" "(cn=%v1* %v2-)" "first initial" ".*[. _].$" ". _" "(cn=%v1-*)" "last initial" "[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact" "(|(sn~=%v1-)(cn~=%v1-))" "approximate" - ".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact" - "(|(cn~=%v1)(sn~=%v1))" "approximate" + ".*" ". " "(|(cn=%v1)(sn=%v1)(ou=%v1))" "exact" + "(|(cn~=%v1)(sn~=%v1)(ou~=%v1))" "approximate" "go500gw onelevel and web500gw onelevel and ufn first and ufn intermediate" + "^$" "" "(!(objectclass=dSA))" "default filter" "=" " " "%v" "arbitrary filter" - "^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact" - "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate" + "^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact2" + "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate2" " " " " "(|(o=%v)(l=%v)(co=%v)(ou=%v))" "exact" "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate" - "\." " " "(associatedDomain=%v)" "exact" + "\." " " "(associatedDomain=%v)" "exact" ".*" " " "(|(o=%v)(l=%v)(co=%v)(ou=%v))" "exact" "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate" diff --git a/libraries/libldap/modify.c b/libraries/libldap/modify.c index 316dde787f..63f1cdc023 100644 --- a/libraries/libldap/modify.c +++ b/libraries/libldap/modify.c @@ -69,7 +69,7 @@ ldap_modify( LDAP *ld, char *dn, LDAPMod **mods ) Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -105,7 +105,7 @@ ldap_modify( LDAP *ld, char *dn, LDAPMod **mods ) } /* send the message */ - return( send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber )); + return( ldap_send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber )); } int diff --git a/libraries/libldap/modrdn.c b/libraries/libldap/modrdn.c index f4624a919a..1532f86917 100644 --- a/libraries/libldap/modrdn.c +++ b/libraries/libldap/modrdn.c @@ -53,7 +53,7 @@ ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn ) Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -65,7 +65,7 @@ ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn ) } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber )); } int diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index 22cd98e377..a145ca0783 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -81,7 +81,7 @@ ldap_open( char *host, int port ) } srv->lsrv_port = ld->ld_defport; - if (( ld->ld_defconn = new_connection( ld, &srv, 1,1,0 )) == NULL ) { + if (( ld->ld_defconn = ldap_new_connection( ld, &srv, 1,1,0 )) == NULL ) { if ( ld->ld_defhost != NULL ) free( srv->lsrv_host ); free( (char *)srv ); ldap_ld_free( ld, 0 ); @@ -126,7 +126,7 @@ ldap_init( char *defhost, int defport ) } #ifdef LDAP_REFERRALS - if (( ld->ld_selectinfo = new_select_info()) == NULL ) { + if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) { free( (char*)ld ); return( NULL ); } @@ -136,7 +136,7 @@ ldap_init( char *defhost, int defport ) if ( defhost != NULL && ( ld->ld_defhost = strdup( defhost )) == NULL ) { #ifdef LDAP_REFERRALS - free_select_info( ld->ld_selectinfo ); + ldap_free_select_info( ld->ld_selectinfo ); #endif /* LDAP_REFERRALS */ free( (char*)ld ); return( NULL ); @@ -148,6 +148,10 @@ ldap_init( char *defhost, int defport ) ld->ld_lberoptions = LBER_USE_DER; ld->ld_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT; +#ifdef LDAP_REFERRALS + ld->ld_options |= LDAP_OPT_REFERRALS; +#endif /* LDAP_REFERRALS */ + #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET ) ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS; #if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET @@ -197,13 +201,13 @@ open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport, port = defport; } - if (( rc = connect_to_host( sb, curhost, 0L, + if (( rc = ldap_connect_to_host( sb, curhost, 0L, port, async )) != -1 ) { break; } } } else { - rc = connect_to_host( sb, NULL, htonl( INADDR_LOOPBACK ), + rc = ldap_connect_to_host( sb, NULL, htonl( INADDR_LOOPBACK ), defport, async ); } @@ -213,7 +217,7 @@ open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport, if ( krbinstancep != NULL ) { #ifdef KERBEROS - if (( *krbinstancep = host_connected_to( sb )) != NULL && + if (( *krbinstancep = ldap_host_connected_to( sb )) != NULL && ( p = strchr( *krbinstancep, '.' )) != NULL ) { *p = '\0'; } diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index ce1ab0e2a8..955a5fab52 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -64,9 +64,10 @@ static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of #endif /* DOS */ #endif /* MACOS */ +#include "ldap-int.h" int -connect_to_host( Sockbuf *sb, char *host, unsigned long address, +ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port, int async ) /* * if host == NULL, connect using address @@ -85,7 +86,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address, #endif /* LDAP_REFERRALS */ #endif /* notyet */ - Debug( LDAP_DEBUG_TRACE, "connect_to_host: %s:%d\n", + Debug( LDAP_DEBUG_TRACE, "ldap_connect_to_host: %s:%d\n", ( host == NULL ) ? "(by address)" : host, ntohs( port ), 0 ); connected = use_hp = 0; @@ -174,7 +175,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address, void -close_connection( Sockbuf *sb ) +ldap_close_connection( Sockbuf *sb ) { tcp_close( sb->sb_sd ); } @@ -182,7 +183,7 @@ close_connection( Sockbuf *sb ) #ifdef KERBEROS char * -host_connected_to( Sockbuf *sb ) +ldap_host_connected_to( Sockbuf *sb ) { struct hostent *hp; char *p; @@ -223,7 +224,7 @@ struct selectinfo { void -mark_select_write( LDAP *ld, Sockbuf *sb ) +ldap_mark_select_write( LDAP *ld, Sockbuf *sb ) { struct selectinfo *sip; @@ -236,7 +237,7 @@ mark_select_write( LDAP *ld, Sockbuf *sb ) void -mark_select_read( LDAP *ld, Sockbuf *sb ) +ldap_mark_select_read( LDAP *ld, Sockbuf *sb ) { struct selectinfo *sip; @@ -249,7 +250,7 @@ mark_select_read( LDAP *ld, Sockbuf *sb ) void -mark_select_clear( LDAP *ld, Sockbuf *sb ) +ldap_mark_select_clear( LDAP *ld, Sockbuf *sb ) { struct selectinfo *sip; @@ -261,7 +262,7 @@ mark_select_clear( LDAP *ld, Sockbuf *sb ) int -is_write_ready( LDAP *ld, Sockbuf *sb ) +ldap_is_write_ready( LDAP *ld, Sockbuf *sb ) { struct selectinfo *sip; @@ -272,7 +273,7 @@ is_write_ready( LDAP *ld, Sockbuf *sb ) int -is_read_ready( LDAP *ld, Sockbuf *sb ) +ldap_is_read_ready( LDAP *ld, Sockbuf *sb ) { struct selectinfo *sip; @@ -283,7 +284,7 @@ is_read_ready( LDAP *ld, Sockbuf *sb ) void * -new_select_info() +ldap_new_select_info() { struct selectinfo *sip; @@ -298,7 +299,7 @@ new_select_info() void -free_select_info( void *sip ) +ldap_free_select_info( void *sip ) { free( sip ); } diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index b8b50eac7b..1bbfab9219 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -83,7 +83,7 @@ static BerElement *re_encode_request(); BerElement * -alloc_ber_with_options( LDAP *ld ) +ldap_alloc_ber_with_options( LDAP *ld ) { BerElement *ber; @@ -91,7 +91,7 @@ alloc_ber_with_options( LDAP *ld ) ld->ld_errno = LDAP_NO_MEMORY; #ifdef STR_TRANSLATION } else { - set_ber_options( ld, ber ); + ldap_set_ber_options( ld, ber ); #endif /* STR_TRANSLATION */ } @@ -100,7 +100,7 @@ alloc_ber_with_options( LDAP *ld ) void -set_ber_options( LDAP *ld, BerElement *ber ) +ldap_set_ber_options( LDAP *ld, BerElement *ber ) { ber->ber_options = ld->ld_lberoptions; #ifdef STR_TRANSLATION @@ -114,14 +114,14 @@ set_ber_options( LDAP *ld, BerElement *ber ) int -send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, +ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, BerElement *ber ) { #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) LDAPServer *servers; #endif /* LDAP_REFERRALS || LDAP_DNS */ - Debug( LDAP_DEBUG_TRACE, "send_initial_request\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 ); #if !defined( LDAP_REFERRALS ) && !defined( LDAP_DNS ) if ( ber_flush( &ld->ld_sb, ber, 1 ) != 0 ) { @@ -165,7 +165,7 @@ send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, } #endif /* LDAP_DNS */ - return( send_server_request( ld, ber, ld->ld_msgid, NULL, servers, + return( ldap_send_server_request( ld, ber, ld->ld_msgid, NULL, servers, NULL, 0 )); #endif /* !LDAP_REFERRALS && !LDAP_DNS */ } @@ -174,13 +174,15 @@ send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) int -send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest +ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind ) { LDAPRequest *lr; + int incparent; - Debug( LDAP_DEBUG_TRACE, "send_server_request\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_send_server_request\n", 0, 0, 0 ); + incparent = 0; ld->ld_errno = LDAP_SUCCESS; /* optimistic */ if ( lc == NULL ) { @@ -189,7 +191,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest } else { if (( lc = find_connection( ld, srvlist, 1 )) == NULL ) { - lc = new_connection( ld, &srvlist, 0, 1, bind ); + if ( bind && (parentreq != NULL) ) { + /* Remember the bind in the parent */ + incparent = 1; + ++parentreq->lr_outrefcnt; + } + lc = ldap_new_connection( ld, &srvlist, 0, 1, bind ); } free_servers( srvlist ); } @@ -200,6 +207,10 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest if ( ld->ld_errno == LDAP_SUCCESS ) { ld->ld_errno = LDAP_SERVER_DOWN; } + if ( incparent ) { + /* Forget about the bind */ + --parentreq->lr_outrefcnt; + } return( -1 ); } @@ -207,8 +218,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest if (( lr = (LDAPRequest *)calloc( 1, sizeof( LDAPRequest ))) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; - free_connection( ld, lc, 0, 0 ); + ldap_free_connection( ld, lc, 0, 0 ); ber_free( ber, 1 ); + if ( incparent ) { + /* Forget about the bind */ + --parentreq->lr_outrefcnt; + } return( -1 ); } lr->lr_msgid = msgid; @@ -217,7 +232,10 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest lr->lr_ber = ber; lr->lr_conn = lc; if ( parentreq != NULL ) { /* sub-request */ - ++parentreq->lr_outrefcnt; + if ( !incparent ) { + /* Increment if we didn't do it before the bind */ + ++parentreq->lr_outrefcnt; + } lr->lr_origid = parentreq->lr_origid; lr->lr_parentcnt = parentreq->lr_parentcnt + 1; lr->lr_parent = parentreq; @@ -240,12 +258,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest if ( errno == EWOULDBLOCK ) { /* need to continue write later */ lr->lr_status = LDAP_REQST_WRITING; - mark_select_write( ld, lc->lconn_sb ); + ldap_mark_select_write( ld, lc->lconn_sb ); } else { #else /* notyet */ ld->ld_errno = LDAP_SERVER_DOWN; - free_request( ld, lr ); - free_connection( ld, lc, 0, 0 ); + ldap_free_request( ld, lr ); + ldap_free_connection( ld, lc, 0, 0 ); return( -1 ); #endif /* notyet */ #ifdef notyet @@ -258,7 +276,7 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest } /* sent -- waiting for a response */ - mark_select_read( ld, lc->lconn_sb ); + ldap_mark_select_read( ld, lc->lconn_sb ); } ld->ld_errno = LDAP_SUCCESS; @@ -267,7 +285,7 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest LDAPConn * -new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, +ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, int connect, int bind ) { LDAPConn *lc; @@ -367,7 +385,7 @@ new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, } if ( err != 0 ) { - free_connection( ld, lc, 1, 0 ); + ldap_free_connection( ld, lc, 1, 0 ); lc = NULL; } } @@ -414,19 +432,19 @@ use_connection( LDAP *ld, LDAPConn *lc ) void -free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) +ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) { LDAPConn *tmplc, *prevlc; - Debug( LDAP_DEBUG_TRACE, "free_connection\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_free_connection\n", 0, 0, 0 ); if ( force || --lc->lconn_refcnt <= 0 ) { if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) { - mark_select_clear( ld, lc->lconn_sb ); + ldap_mark_select_clear( ld, lc->lconn_sb ); if ( unbind ) { - send_unbind( ld, lc->lconn_sb ); + ldap_send_unbind( ld, lc->lconn_sb ); } - close_connection( lc->lconn_sb ); + ldap_close_connection( lc->lconn_sb ); if ( lc->lconn_sb->sb_ber.ber_buf != NULL ) { free( lc->lconn_sb->sb_ber.ber_buf ); } @@ -442,6 +460,7 @@ free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) } break; } + prevlc = tmplc; } free_servers( lc->lconn_server ); if ( lc->lconn_krbinstance != NULL ) { @@ -451,11 +470,11 @@ free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) free( (char *)lc->lconn_sb ); } free( lc ); - Debug( LDAP_DEBUG_TRACE, "free_connection: actually freed\n", + Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: actually freed\n", 0, 0, 0 ); } else { lc->lconn_lastused = time( 0 ); - Debug( LDAP_DEBUG_TRACE, "free_connection: refcnt %d\n", + Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: refcnt %d\n", lc->lconn_refcnt, 0, 0 ); } } @@ -463,7 +482,7 @@ free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) #ifdef LDAP_DEBUG void -dump_connection( LDAP *ld, LDAPConn *lconns, int all ) +ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all ) { LDAPConn *lc; @@ -490,7 +509,7 @@ dump_connection( LDAP *ld, LDAPConn *lconns, int all ) void -dump_requests_and_responses( LDAP *ld ) +ldap_dump_requests_and_responses( LDAP *ld ) { LDAPRequest *lr; LDAPMessage *lm, *l; @@ -531,11 +550,11 @@ dump_requests_and_responses( LDAP *ld ) void -free_request( LDAP *ld, LDAPRequest *lr ) +ldap_free_request( LDAP *ld, LDAPRequest *lr ) { LDAPRequest *tmplr, *nextlr; - Debug( LDAP_DEBUG_TRACE, "free_request (origid %d, msgid %d)\n", + Debug( LDAP_DEBUG_TRACE, "ldap_free_request (origid %d, msgid %d)\n", lr->lr_origid, lr->lr_msgid, 0 ); if ( lr->lr_parent != NULL ) { @@ -544,7 +563,7 @@ free_request( LDAP *ld, LDAPRequest *lr ) /* free all referrals (child requests) */ for ( tmplr = lr->lr_refnext; tmplr != NULL; tmplr = nextlr ) { nextlr = tmplr->lr_refnext; - free_request( ld, tmplr ); + ldap_free_request( ld, tmplr ); } } @@ -599,7 +618,7 @@ free_servers( LDAPServer *srvlist ) * XXX merging of errors in this routine needs to be improved */ int -chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) +ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) { int rc, count, len, newdn; #ifdef LDAP_DNS @@ -610,7 +629,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) LDAPServer *srv; BerElement *ber; - Debug( LDAP_DEBUG_TRACE, "chase_referrals\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_chase_referrals\n", 0, 0, 0 ); ld->ld_errno = LDAP_SUCCESS; /* optimistic */ *hadrefp = 0; @@ -681,7 +700,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) } else { Debug( LDAP_DEBUG_TRACE, "ignoring unknown referral <%s>\n", ref, 0, 0 ); - rc = append_referral( ld, &unfollowed, ref ); + rc = ldap_append_referral( ld, &unfollowed, ref ); *hadrefp = 1; continue; } @@ -728,14 +747,14 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) } #endif /* LDAP_DNS */ - if ( srv != NULL && send_server_request( ld, ber, ld->ld_msgid, + if ( srv != NULL && ldap_send_server_request( ld, ber, ld->ld_msgid, lr, srv, NULL, 1 ) >= 0 ) { ++count; } else { Debug( LDAP_DEBUG_ANY, "Unable to chase referral (%s)\n", ldap_err2string( ld->ld_errno ), 0, 0 ); - rc = append_referral( ld, &unfollowed, ref ); + rc = ldap_append_referral( ld, &unfollowed, ref ); } if ( !newdn && refdn != NULL ) { @@ -751,7 +770,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) int -append_referral( LDAP *ld, char **referralsp, char *s ) +ldap_append_referral( LDAP *ld, char **referralsp, char *s ) { int first; @@ -810,7 +829,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp ) return( NULL ); } - if (( ber = alloc_ber_with_options( ld )) == NULLBER ) { + if (( ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( NULL ); } @@ -866,7 +885,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp ) LDAPRequest * -find_request_by_msgid( LDAP *ld, int msgid ) +ldap_find_request_by_msgid( LDAP *ld, int msgid ) { LDAPRequest *lr; @@ -895,7 +914,7 @@ dn2servers( LDAP *ld, char *dn ) /* dn can also be a domain.... */ domain = dn; } - if (( dxs = getdxbyname( domain )) == NULL ) { + if (( dxs = ldap_getdxbyname( domain )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( NULL ); } diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 3f8408df18..fdf8dedf07 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -231,8 +231,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, #else /* !LDAP_REFERRALS */ #ifdef LDAP_DEBUG if ( ldap_debug & LDAP_DEBUG_TRACE ) { - dump_connection( ld, ld->ld_conns, 1 ); - dump_requests_and_responses( ld ); + ldap_dump_connection( ld, ld->ld_conns, 1 ); + ldap_dump_requests_and_responses( ld ); } #endif /* LDAP_DEBUG */ for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { @@ -276,7 +276,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, nextlc = lc->lconn_next; if ( lc->lconn_status == LDAP_CONNST_CONNECTED && - is_read_ready( ld, + ldap_is_read_ready( ld, lc->lconn_sb )) { rc = read1msg( ld, msgid, all, lc->lconn_sb, lc, result ); @@ -326,7 +326,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 ); ber_init( &ber, 0 ); - set_ber_options( ld, &ber ); + ldap_set_ber_options( ld, &ber ); /* get the next message */ if ( (tag = ber_get_next( sb, &len, &ber )) @@ -349,7 +349,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, } #ifdef LDAP_REFERRALS - if (( lr = find_request_by_msgid( ld, id )) == NULL ) { + if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) { Debug( LDAP_DEBUG_ANY, "no request for response with msgid %ld (tossing)\n", id, 0, 0 ); @@ -384,7 +384,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, != LBER_ERROR ) { if ( lderr != LDAP_SUCCESS ) { /* referrals are in error string */ - refer_cnt = chase_referrals( ld, lr, + refer_cnt = ldap_chase_referrals( ld, lr, &lr->lr_res_error, &hadref ); } @@ -455,11 +455,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); } } - free_request( ld, lr ); + ldap_free_request( ld, lr ); } if ( lc != NULL ) { - free_connection( ld, lc, 0, 1 ); + ldap_free_connection( ld, lc, 0, 1 ); } } } @@ -481,7 +481,7 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); #ifndef NO_CACHE if ( ld->ld_cache != NULL ) { - add_result_to_cache( ld, new ); + ldap_add_result_to_cache( ld, new ); } #endif /* NO_CACHE */ @@ -542,7 +542,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); prev->lm_next = l->lm_next; *result = l; ld->ld_errno = LDAP_SUCCESS; +#ifndef ultrix + return( l->lm_msgtype ); +#else return( tag ); +#endif } return( -2 ); /* continue looking */ @@ -557,7 +561,7 @@ build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ) long along; ber_init( ber, 0 ); - set_ber_options( ld, ber ); + ldap_set_ber_options( ld, ber ); if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid, (long)lr->lr_res_msgtype, lr->lr_res_errno, lr->lr_res_matched ? lr->lr_res_matched : "", @@ -587,7 +591,7 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) { parentr->lr_res_errno = lr->lr_res_errno; if ( lr->lr_res_error != NULL ) { - (void)append_referral( ld, &parentr->lr_res_error, + (void)ldap_append_referral( ld, &parentr->lr_res_error, lr->lr_res_error ); } } else if ( lr->lr_res_errno != LDAP_SUCCESS && diff --git a/libraries/libldap/sbind.c b/libraries/libldap/sbind.c index 656c722f15..9421b07fee 100644 --- a/libraries/libldap/sbind.c +++ b/libraries/libldap/sbind.c @@ -61,7 +61,7 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd ) passwd = ""; /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -80,7 +80,7 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd ) #endif /* !NO_CACHE */ /* send the message */ - return( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); } /* diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index 2b73ddd07e..c9f984a511 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -80,17 +80,17 @@ ldap_search( LDAP *ld, char *base, int scope, char *filter, #ifndef NO_CACHE if ( ld->ld_cache != NULL ) { - if ( check_cache( ld, LDAP_REQ_SEARCH, ber ) == 0 ) { + if ( ldap_check_cache( ld, LDAP_REQ_SEARCH, ber ) == 0 ) { ber_free( ber, 1 ); ld->ld_errno = LDAP_SUCCESS; return( ld->ld_msgid ); } - add_request_to_cache( ld, LDAP_REQ_SEARCH, ber ); + ldap_add_request_to_cache( ld, LDAP_REQ_SEARCH, ber ); } #endif /* NO_CACHE */ /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_SEARCH, base, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_SEARCH, base, ber )); } @@ -126,7 +126,7 @@ ldap_build_search_req( LDAP *ld, char *base, int scope, char *filter, */ /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( NULLBER ); } diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index 84f478da80..e9cc1266d2 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -31,6 +31,12 @@ #include "lber.h" #include "ldap.h" +/* including the "internal" defs is legit and nec. since this test routine has + * a-priori knowledge of libldap internal workings. + * hodges@stanford.edu 5-Feb-96 + */ +#include "ldap-int.h" + #if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS ) #define MOD_USE_BVALS #endif /* !PCNFS && !WINSOCK && !MACOS */ diff --git a/libraries/libldap/unbind.c b/libraries/libldap/unbind.c index e7b5c401e6..69231f7db9 100644 --- a/libraries/libldap/unbind.c +++ b/libraries/libldap/unbind.c @@ -55,17 +55,17 @@ ldap_ld_free( LDAP *ld, int close ) /* free LDAP structure and outstanding requests/responses */ for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) { nextlr = lr->lr_next; - free_request( ld, lr ); + ldap_free_request( ld, lr ); } /* free and unbind from all open connections */ while ( ld->ld_conns != NULL ) { - free_connection( ld, ld->ld_conns, 1, close ); + ldap_free_connection( ld, ld->ld_conns, 1, close ); } #else /* LDAP_REFERRALS */ if ( close ) { - err = send_unbind( ld, &ld->ld_sb ); - close_connection( &ld->ld_sb ); + err = ldap_send_unbind( ld, &ld->ld_sb ); + ldap_close_connection( &ld->ld_sb ); } #endif /* LDAP_REFERRALS */ } else { @@ -106,7 +106,7 @@ ldap_ld_free( LDAP *ld, int close ) #ifdef LDAP_REFERRALS if ( ld->ld_selectinfo != NULL ) - free_select_info( ld->ld_selectinfo ); + ldap_free_select_info( ld->ld_selectinfo ); #endif /* LDAP_REFERRALS */ if ( ld->ld_defhost != NULL ) @@ -125,14 +125,14 @@ ldap_unbind_s( LDAP *ld ) int -send_unbind( LDAP *ld, Sockbuf *sb ) +ldap_send_unbind( LDAP *ld, Sockbuf *sb ) { BerElement *ber; - Debug( LDAP_DEBUG_TRACE, "send_unbind\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_send_unbind\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( ld->ld_errno ); } diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index 08b47efd6b..204f2978ff 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -305,10 +305,10 @@ ldap_url_search( LDAP *ld, char *url, int attrsonly ) ber_free( ber, 1 ); } else { #ifdef LDAP_REFERRALS - err = send_server_request( ld, ber, ld->ld_msgid, NULL, srv, + err = ldap_send_server_request( ld, ber, ld->ld_msgid, NULL, srv, NULL, 1 ); #else /* LDAP_REFERRALS */ - err = send_initial_request( ld, LDAP_REQ_SEARCH, + err = ldap_send_initial_request( ld, LDAP_REQ_SEARCH, ludp->lud_dn, ber ); #endif /* LDAP_REFERRALS */ } diff --git a/libraries/liblthread/thread.c b/libraries/liblthread/thread.c index 89a85c70b4..47d878ac76 100644 --- a/libraries/liblthread/thread.c +++ b/libraries/liblthread/thread.c @@ -2,7 +2,157 @@ #include #include "lthread.h" -#if defined( THREAD_SUNOS4_LWP ) +#if defined( THREAD_NEXT_CTHREADS ) + +/*********************************************************************** + * * + * under NEXTSTEP or OPENSTEP use CThreads * + * lukeh@xedoc.com.au * + * * + ***********************************************************************/ + +int +pthread_attr_init( pthread_attr_t *attr ) +{ + *attr = 0; + return( 0 ); +} + +int +pthread_attr_destroy( pthread_attr_t *attr ) +{ + return( 0 ); +} + +int +pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate ) +{ + *detachstate = *attr; + return( 0 ); +} + +int +pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate ) +{ + *attr = detachstate; + return( 0 ); +} + +/* ARGSUSED */ +int +pthread_create( + pthread_t *tid, + pthread_attr_t attr, + VFP func, + void *arg +) +{ + *tid = cthread_fork(func, arg); + return ( *tid == NULL ? -1 : 0 ); +} + +void +pthread_yield() +{ + cthread_yield(); +} + +void +pthread_exit( any_t a ) +{ + cthread_exit( a ); +} + +void +pthread_join( pthread_t tid, int *pStatus ) +{ + int status; + status = (int) cthread_join ( tid ); + if (pStatus != NULL) + { + *pStatus = status; + } +} + +/* ARGSUSED */ +void +pthread_kill( pthread_t tid, int sig ) +{ + return; +} + +/* ARGSUSED */ +int +pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr ) +{ + mutex_init( mp ); + mp->name = NULL; + return ( 0 ); +} + +int +pthread_mutex_destroy( pthread_mutex_t *mp ) +{ + mutex_clear( mp ); + return ( 0 ); +} + +int +pthread_mutex_lock( pthread_mutex_t *mp ) +{ + mutex_lock( mp ); + return ( 0 ); +} + +int +pthread_mutex_unlock( pthread_mutex_t *mp ) +{ + mutex_unlock( mp ); + return ( 0 ); +} + +int +pthread_mutex_trylock( pthread_mutex_t *mp ) +{ + return mutex_try_lock( mp ); +} + +int +pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr ) +{ + condition_init( cv ); + return( 0 ); +} + +int +pthread_cond_destroy( pthread_cond_t *cv ) +{ + condition_clear( cv ); + return( 0 ); +} + +int +pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp ) +{ + condition_wait( cv, mp ); + return( 0 ); +} + +int +pthread_cond_signal( pthread_cond_t *cv ) +{ + condition_signal( cv ); + return( 0 ); +} + +int +pthread_cond_broadcast( pthread_cond_t *cv ) +{ + condition_broadcast( cv ); + return( 0 ); +} + +#elif defined( THREAD_SUNOS4_LWP ) /*********************************************************************** * * diff --git a/libraries/macintosh/kerberos-macos.c b/libraries/macintosh/kerberos-macos.c index ee9c31c6b1..cb973795bb 100644 --- a/libraries/macintosh/kerberos-macos.c +++ b/libraries/macintosh/kerberos-macos.c @@ -29,12 +29,12 @@ static char copyright[] = "@(#) Copyright (c) 1994 Regents of the University of #include "ldap-int.h" /* - * get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. + * ldap_get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. */ /* ARGSUSED */ char * -get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) +ldap_get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) { static short authman_refnum = 0; char *cred, ticket[ MAX_KTXT_LEN ]; diff --git a/libraries/macintosh/macos-ip.c b/libraries/macintosh/macos-ip.c index 3a6a1805c2..011bdf7bf6 100644 --- a/libraries/macintosh/macos-ip.c +++ b/libraries/macintosh/macos-ip.c @@ -19,7 +19,7 @@ static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of #include "ldap-int.h" int -connect_to_host( Sockbuf *sb, char *host, unsigned long address, +ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port, int async ) /* * if host == NULL, connect using address @@ -37,7 +37,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address, struct hostInfo hi; #endif /* SUPPORT_OPENTRANSPORT */ - Debug( LDAP_DEBUG_TRACE, "connect_to_host: %s:%d\n", + Debug( LDAP_DEBUG_TRACE, "ldap_connect_to_host: %s:%d\n", ( host == NULL ) ? "(by address)" : host, ntohs( port ), 0 ); if ( host != NULL && gethostinfobyname( host, &hi ) != noErr ) { @@ -78,7 +78,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address, void -close_connection( Sockbuf *sb ) +ldap_close_connection( Sockbuf *sb ) { tcpclose( (tcpstream *)sb->sb_sd ); } @@ -86,7 +86,7 @@ close_connection( Sockbuf *sb ) #ifdef KERBEROS char * -host_connected_to( Sockbuf *sb ) +ldap_host_connected_to( Sockbuf *sb ) { ip_addr addr; @@ -131,13 +131,13 @@ struct selectinfo { void -mark_select_read( LDAP *ld, Sockbuf *sb ) +ldap_mark_select_read( LDAP *ld, Sockbuf *sb ) { struct selectinfo *sip; struct tcpstreaminfo *tcpsip; short i; - Debug( LDAP_DEBUG_TRACE, "mark_select_read: stream %x\n", (tcpstream *)sb->sb_sd, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_mark_select_read: stream %x\n", (tcpstream *)sb->sb_sd, 0, 0 ); if (( sip = (struct selectinfo *)ld->ld_selectinfo ) == NULL ) { return; @@ -170,12 +170,12 @@ mark_select_read( LDAP *ld, Sockbuf *sb ) void -mark_select_clear( LDAP *ld, Sockbuf *sb ) +ldap_mark_select_clear( LDAP *ld, Sockbuf *sb ) { struct selectinfo *sip; short i; - Debug( LDAP_DEBUG_TRACE, "mark_select_clear: stream %x\n", (tcpstream *)sb->sb_sd, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_mark_select_clear: stream %x\n", (tcpstream *)sb->sb_sd, 0, 0 ); sip = (struct selectinfo *)ld->ld_selectinfo; if ( sip != NULL && sip->si_count > 0 && sip->si_streaminfo != NULL ) { @@ -196,7 +196,7 @@ mark_select_clear( LDAP *ld, Sockbuf *sb ) int -is_read_ready( LDAP *ld, Sockbuf *sb ) +ldap_is_read_ready( LDAP *ld, Sockbuf *sb ) { struct selectinfo *sip; short i; @@ -207,10 +207,10 @@ is_read_ready( LDAP *ld, Sockbuf *sb ) if ( sip->si_streaminfo[ i ].tcpsi_stream == (tcpstream *)sb->sb_sd ) { #ifdef LDAP_DEBUG if ( sip->si_streaminfo[ i ].tcpsi_is_read_ready ) { - Debug( LDAP_DEBUG_TRACE, "is_read_ready: stream %x READY\n", + Debug( LDAP_DEBUG_TRACE, "ldap_is_read_ready: stream %x READY\n", (tcpstream *)sb->sb_sd, 0, 0 ); } else { - Debug( LDAP_DEBUG_TRACE, "is_read_ready: stream %x Not Ready\n", + Debug( LDAP_DEBUG_TRACE, "ldap_is_read_ready: stream %x Not Ready\n", (tcpstream *)sb->sb_sd, 0, 0 ); } #endif /* LDAP_DEBUG */ @@ -219,20 +219,20 @@ is_read_ready( LDAP *ld, Sockbuf *sb ) } } - Debug( LDAP_DEBUG_TRACE, "is_read_ready: stream %x: NOT FOUND\n", (tcpstream *)sb->sb_sd, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_is_read_ready: stream %x: NOT FOUND\n", (tcpstream *)sb->sb_sd, 0, 0 ); return( 0 ); } void * -new_select_info() +ldap_new_select_info() { return( (void *)calloc( 1, sizeof( struct selectinfo ))); } void -free_select_info( void *sip ) +ldap_free_select_info( void *sip ) { if ( sip != NULL ) { free( sip ); diff --git a/libraries/msdos/winsock/include/krb/des.h b/libraries/msdos/winsock/include/krb/des.h index 256f9269f1..6afe20873d 100644 --- a/libraries/msdos/winsock/include/krb/des.h +++ b/libraries/msdos/winsock/include/krb/des.h @@ -1,8 +1,4 @@ /* - * $Source: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/des.h,v $ - * $Author: kurt $ - * $Header: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/des.h,v 1.1.4.1 1998/08/08 23:05:24 kurt Exp $ - * * Copyright 1987, 1988 by the Massachusetts Institute of Technology. * * For copying and distribution information, please see the file diff --git a/libraries/msdos/winsock/include/krb/krb.h b/libraries/msdos/winsock/include/krb/krb.h index 354c9263ab..128255cec9 100644 --- a/libraries/msdos/winsock/include/krb/krb.h +++ b/libraries/msdos/winsock/include/krb/krb.h @@ -1,8 +1,4 @@ /* - * $Source: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/krb.h,v $ - * $Author: kurt $ - * $Header: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/krb.h,v 1.1.4.1 1998/08/08 23:05:24 kurt Exp $ - * * Copyright 1987, 1988 by the Massachusetts Institute of Technology. * * For copying and distribution information, please see the file diff --git a/libraries/msdos/winsock/include/krb/mit/conf-pc.h b/libraries/msdos/winsock/include/krb/mit/conf-pc.h index 51256bbe09..4c779aa730 100644 --- a/libraries/msdos/winsock/include/krb/mit/conf-pc.h +++ b/libraries/msdos/winsock/include/krb/mit/conf-pc.h @@ -1,8 +1,4 @@ /* - * $Source: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/mit/conf-pc.h,v $ - * $Author: kurt $ - * $Header: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/mit/conf-pc.h,v 1.1.4.1 1998/08/08 23:05:25 kurt Exp $ - * * Copyright 1988 by the Massachusetts Institute of Technology. * * For copying and distribution information, please see the file diff --git a/libraries/msdos/winsock/include/krb/mit/conf.h b/libraries/msdos/winsock/include/krb/mit/conf.h index 3196e42e14..cd33f6ebe9 100644 --- a/libraries/msdos/winsock/include/krb/mit/conf.h +++ b/libraries/msdos/winsock/include/krb/mit/conf.h @@ -1,8 +1,4 @@ /* - * $Source: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/mit/conf.h,v $ - * $Author: kurt $ - * $Header: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/mit/conf.h,v 1.1.4.1 1998/08/08 23:05:24 kurt Exp $ - * * Copyright 1988 by the Massachusetts Institute of Technology. * * For copying and distribution information, please see the file diff --git a/libraries/msdos/winsock/include/krb/mit/hesiod.h b/libraries/msdos/winsock/include/krb/mit/hesiod.h index a7fde97708..5bc39e8d36 100644 --- a/libraries/msdos/winsock/include/krb/mit/hesiod.h +++ b/libraries/msdos/winsock/include/krb/mit/hesiod.h @@ -5,11 +5,6 @@ * * Original version by Steve Dyer, IBM/Project Athena. * - * $Author: kurt $ - * $Athena: hesiod.h,v 1.3 88/08/07 21:52:39 treese Locked $ - * $Header: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/mit/hesiod.h,v 1.1.4.1 1998/08/08 23:05:25 kurt Exp $ - * $Source: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/mit/hesiod.h,v $ - * * Vendor History * * Revision 1.6 90/07/20 13:09:16 probe diff --git a/libraries/msdos/winsock/include/krb/mit/osconf.h b/libraries/msdos/winsock/include/krb/mit/osconf.h index 252021c777..ac614b0c6d 100644 --- a/libraries/msdos/winsock/include/krb/mit/osconf.h +++ b/libraries/msdos/winsock/include/krb/mit/osconf.h @@ -1,8 +1,4 @@ /* - * $Source: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/mit/osconf.h,v $ - * $Author: kurt $ - * $Header: /data/CVS-Repository/pkg/ldap/libraries/msdos/winsock/include/krb/mit/osconf.h,v 1.1.4.1 1998/08/08 23:05:25 kurt Exp $ - * * Copyright 1988 by the Massachusetts Institute of Technology. * * For copying and distribution information, please see the file diff --git a/servers/slapd/Make-template b/servers/slapd/Make-template index 5b614b75aa..bdeb881c70 100644 --- a/servers/slapd/Make-template +++ b/servers/slapd/Make-template @@ -232,15 +232,14 @@ init.o: ../../include/ldap.h ../../include/lthread.h detach.o: detach.c strdup.o: strdup.c tempnam.o: tempnam.c -repl.o: repl.c ../../include/proto-lber.h ../../include/proto-ldap.h -repl.o: ../../include/ldif.h +repl.o: repl.c ../../include/proto-lber.h ../../include/lthread.h lock.o: lock.c ../../include/avl.h ../../include/ldap.h ../../include/lthread.h schema.o: schema.c ../../include/proto-lber.h ../../include/proto-ldap.h schema.o: ../../include/ldif.h schemaparse.o: schemaparse.c ../../include/avl.h ../../include/ldap.h schemaparse.o: ../../include/lthread.h -monitor.o: monitor.c ../../include/proto-lber.h ../../include/proto-ldap.h -monitor.o: ../../include/ldif.h +monitor.o: monitor.c ../../include/avl.h ../../include/ldap.h +monitor.o: ../../include/proto-ldap.h ../../include/ldif.h configinfo.o: configinfo.c ../../include/avl.h ../../include/ldap.h configinfo.o: ../../include/lthread.h ../../include/ldapconfig.h diff --git a/servers/slapd/back-ldbm/Make-template b/servers/slapd/back-ldbm/Make-template index f2fe468b1e..bc46d3a589 100644 --- a/servers/slapd/back-ldbm/Make-template +++ b/servers/slapd/back-ldbm/Make-template @@ -89,8 +89,9 @@ dn2id.o: ../../../include/ldif.h ../../../include/ldbm.h id2entry.o: id2entry.c ../../../include/avl.h ../../../include/proto-lber.h id2entry.o: ../../../include/proto-ldap.h ../../../include/ldif.h id2entry.o: ../../../include/ldbm.h -index.o: index.c ../../../include/proto-lber.h ../../../include/proto-ldap.h -index.o: ../../../include/ldif.h ../../../include/ldbm.h +index.o: index.c ../../../include/avl.h ../../../include/proto-lber.h +index.o: ../../../include/proto-ldap.h ../../../include/ldif.h +index.o: ../../../include/ldbm.h id2children.o: id2children.c ../../../include/proto-lber.h id2children.o: ../../../include/proto-ldap.h ../../../include/ldif.h id2children.o: ../../../include/ldbm.h diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index 88fd4030c4..a4cbcd397f 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -10,6 +10,15 @@ #include "krb.h" #endif +#ifdef LDAP_CRYPT +/* change for crypted passwords -- lukeh */ +#ifdef __NeXT__ +extern char *crypt (char *key, char *salt); +#else +#include +#endif +#endif /* LDAP_CRYPT */ + extern Entry *dn2entry(); extern Attribute *attr_find(); @@ -17,6 +26,40 @@ extern Attribute *attr_find(); extern int krbv4_ldap_auth(); #endif +#ifdef LDAP_CRYPT +pthread_mutex_t crypt_mutex; + +static int +crypted_value_find( + struct berval **vals, + struct berval *v, + int syntax, + int normalize, + struct berval *cred +) +{ + int i; + for ( i = 0; vals[i] != NULL; i++ ) { + if ( syntax != SYNTAX_BIN && + strncasecmp( "{CRYPT}", vals[i]->bv_val, (sizeof("{CRYPT}") - 1 ) ) == 0 ) { + char *userpassword = vals[i]->bv_val + sizeof("{CRYPT}") - 1; + pthread_mutex_lock( &crypt_mutex ); + if ( ( !strcmp( userpassword, crypt( cred->bv_val, userpassword ) ) != 0 ) ) { + pthread_mutex_unlock( &crypt_mutex ); + return ( 0 ); + } + pthread_mutex_unlock( &crypt_mutex ); + } else { + if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) { + return( 0 ); + } + } + } + + return( 1 ); +} +#endif /* LDAP_CRYPT */ + int ldbm_back_bind( Backend *be, @@ -81,13 +124,18 @@ ldbm_back_bind( return( 1 ); } - if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 ) { +#ifdef LDAP_CRYPT + if ( crypted_value_find( a->a_vals, cred, a->a_syntax, 0, cred ) != 0 ) +#else + if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 ) +#endif +{ if ( be_isroot_pw( be, dn, cred ) ) { /* front end will send result */ return( 0 ); } send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, - NULL, NULL ); + NULL, NULL ); cache_return_entry( &li->li_cache, e ); return( 1 ); } diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index 60828a2610..ef65444c3d 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -726,12 +726,9 @@ idl_notin( if ( a == NULL ) { return( NULL ); } - if ( b == NULL ) { + if ( b == NULL || ALLIDS( b )) { return( idl_dup( a ) ); } - if ( ALLIDS( b ) ) { - return( NULL ); - } if ( ALLIDS( a ) ) { n = idl_alloc( SLAPD_LDBM_MIN_MAXIDS ); diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index 3d75a091d3..fd13d7ec07 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -3,7 +3,6 @@ #include #include #include -#include #include "slap.h" #include "back-ldbm.h" @@ -130,25 +129,26 @@ index_read( realval = val; tmpval = NULL; if ( prefix != '\0' ) { - int len; + int len = strlen( val ); - if ( (len = strlen( val )) < sizeof(buf) ) { - buf[0] = prefix; - strcpy( &buf[1], val ); + if ( (len + 2) < sizeof(buf) ) { realval = buf; } else { /* value + prefix + null */ tmpval = (char *) ch_malloc( len + 2 ); - tmpval[0] = prefix; - strcat( &tmpval[1], val ); realval = tmpval; } + realval[0] = prefix; + strcpy( &realval[1], val ); } key.dptr = realval; key.dsize = strlen( realval ) + 1; idl = idl_fetch( be, db, key ); + if ( tmpval != NULL ) { + free( tmpval ); + } ldbm_cache_close( be, db ); @@ -181,19 +181,17 @@ add_value( tmpval = NULL; idl = NULL; if ( prefix != '\0' ) { - int len; + int len = strlen( val ); - if ( (len = strlen( val )) < sizeof(buf) ) { - buf[0] = prefix; - strcpy( &buf[1], val ); + if ( (len + 2) < sizeof(buf) ) { realval = buf; } else { /* value + prefix + null */ tmpval = (char *) ch_malloc( len + 2 ); - tmpval[0] = prefix; - strcat( &tmpval[1], val ); realval = tmpval; } + realval[0] = prefix; + strcpy( &realval[1], val ); } key.dptr = realval; diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index b9c5c2f3fa..de8c59a236 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -15,6 +15,10 @@ ldbm_back_init( char *argv[ 4 ]; int i; +#ifdef LDAP_CRYPT + extern pthread_mutex_t crypt_mutex; +#endif /* LDAP_CRYPT */ + /* allocate backend-specific stuff */ li = (struct ldbminfo *) ch_calloc( 1, sizeof(struct ldbminfo) ); @@ -59,6 +63,9 @@ ldbm_back_init( pthread_mutex_init( &li->li_cache.c_mutex, pthread_mutexattr_default ); pthread_mutex_init( &li->li_nextid_mutex, pthread_mutexattr_default ); pthread_mutex_init( &li->li_dbcache_mutex, pthread_mutexattr_default ); +#ifdef LDAP_CRYPT + pthread_mutex_init( &crypt_mutex, pthread_mutexattr_default ); +#endif /* LDAP_CRYPT */ pthread_cond_init( &li->li_dbcache_cv, pthread_condattr_default ); for ( i = 0; i < MAXDBCACHE; i++ ) { pthread_mutex_init( &li->li_dbcache[i].dbc_mutex, diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 6a53be4f11..bad87b1f48 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -377,8 +377,9 @@ subtree_candidates( f->f_or = (Filter *) ch_malloc( sizeof(Filter) ); f->f_or->f_choice = LDAP_FILTER_EQUALITY; f->f_or->f_avtype = strdup( "objectclass" ); - f->f_or->f_avvalue.bv_val = strdup( "referral" ); - f->f_or->f_avvalue.bv_len = strlen( "referral" ); + /* Patch to use normalized uppercase */ + f->f_or->f_avvalue.bv_val = strdup( "REFERRAL" ); + f->f_or->f_avvalue.bv_len = strlen( "REFERRAL" ); f->f_or->f_next = filter; filter = f; diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 863ca497d3..8d35debc81 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -1,3 +1,10 @@ + +/* Revision history + * + * 5-Jun-96 hodges + * Added locking of new_conn_mutex when traversing the c[] array. + */ + #include #include #include @@ -170,6 +177,8 @@ daemon( Debug( LDAP_DEBUG_CONNS, "listening for connections on %d, activity on:", tcps, 0, 0 ); + + pthread_mutex_lock( &new_conn_mutex ); for ( i = 0; i < dtblsize; i++ ) { if ( c[i].c_sb.sb_sd != -1 ) { FD_SET( c[i].c_sb.sb_sd, &readfds ); @@ -182,6 +191,7 @@ daemon( } } Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 ); + pthread_mutex_unlock( &new_conn_mutex ); zero.tv_sec = 0; zero.tv_usec = 0; diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 8d990b361d..50016fe6ba 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -135,6 +135,7 @@ get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ) Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); if ( (err = get_filter_list( conn, ber, &f->f_and, &ftmp )) == 0 ) { + if (ftmp == NULL) ftmp = strdup(""); *fstr = ch_malloc( 4 + strlen( ftmp ) ); sprintf( *fstr, "(&%s)", ftmp ); free( ftmp ); @@ -145,6 +146,7 @@ get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ) Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 ); if ( (err = get_filter_list( conn, ber, &f->f_or, &ftmp )) == 0 ) { + if (ftmp == NULL) ftmp = strdup(""); *fstr = ch_malloc( 4 + strlen( ftmp ) ); sprintf( *fstr, "(|%s)", ftmp ); free( ftmp ); @@ -155,6 +157,7 @@ get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ) Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 ); (void) ber_skip_tag( ber, &len ); if ( (err = get_filter( conn, ber, &f->f_not, &ftmp )) == 0 ) { + if (ftmp == NULL) ftmp = strdup(""); *fstr = ch_malloc( 4 + strlen( ftmp ) ); sprintf( *fstr, "(!%s)", ftmp ); free( ftmp ); diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index 712ff22e2e..4b6807f55a 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -223,11 +223,12 @@ test_approx_filter( w2 = next_word( w2 ) ) { c2 = phonetic( w2 ); if ( strcmp( c1, c2 ) == 0 ) { + free( c2 ); break; } + free( c2 ); } free( c1 ); - free( c2 ); /* * if we stopped because we ran out of words diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index 7dbabc9377..07ead7445d 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -10,8 +10,16 @@ * is provided ``as is'' without express or implied warranty. */ +/* Revision history + * + * 5-Jun-96 jeff.hodges@stanford.edu + * Added locking of new_conn_mutex when traversing the c[] array. + * Added locking of currenttime_mutex to protect call(s) to localtime(). + */ + #include #include +#include #include #include #include "slap.h" @@ -32,13 +40,11 @@ extern time_t currenttime; extern time_t starttime; extern int num_conns; +extern pthread_mutex_t new_conn_mutex; +extern pthread_mutex_t currenttime_mutex; extern char Versionstr[]; -/* - * no mutex protection in here - take our chances! - */ - void monitor_info( Connection *conn, Operation *op ) { @@ -73,6 +79,8 @@ monitor_info( Connection *conn, Operation *op ) nconns = 0; nwritewaiters = 0; nreadwaiters = 0; + + pthread_mutex_lock( &new_conn_mutex ); for ( i = 0; i < dtblsize; i++ ) { if ( c[i].c_sb.sb_sd != -1 ) { nconns++; @@ -82,8 +90,11 @@ monitor_info( Connection *conn, Operation *op ) if ( c[i].c_gettingber ) { nreadwaiters++; } + pthread_mutex_lock( ¤ttime_mutex ); ltm = localtime( &c[i].c_starttime ); strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); + pthread_mutex_unlock( ¤ttime_mutex ); + pthread_mutex_lock( &c[i].c_dnmutex ); sprintf( buf, "%d : %s : %ld : %ld : %s : %s%s", i, buf2, c[i].c_opsinitiated, c[i].c_opscompleted, @@ -96,6 +107,8 @@ monitor_info( Connection *conn, Operation *op ) attr_merge( e, "connection", vals ); } } + pthread_mutex_unlock( &new_conn_mutex ); + sprintf( buf, "%d", nconns ); val.bv_val = buf; val.bv_len = strlen( buf ); @@ -141,14 +154,18 @@ monitor_info( Connection *conn, Operation *op ) val.bv_len = strlen( buf ); attr_merge( e, "bytessent", vals ); + pthread_mutex_lock( ¤ttime_mutex ); ltm = localtime( ¤ttime ); strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + pthread_mutex_unlock( ¤ttime_mutex ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "currenttime", vals ); + pthread_mutex_lock( ¤ttime_mutex ); ltm = localtime( &starttime ); strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + pthread_mutex_unlock( ¤ttime_mutex ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "starttime", vals ); diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index ba16d9b0f1..a5c297fbe3 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -111,14 +111,16 @@ oc_check_allowed( char *type, struct berval **ocl ) /* if we know about the oc */ if ( (oc = oc_find( ocl[i]->bv_val )) != NULL ) { /* does it require the type? */ - for ( j = 0; oc->oc_required[j] != NULL; j++ ) { + for ( j = 0; oc->oc_required != NULL && + oc->oc_required[j] != NULL; j++ ) { if ( strcasecmp( oc->oc_required[j], type ) == 0 ) { return( 0 ); } } /* does it allow the type? */ - for ( j = 0; oc->oc_allowed[j] != NULL; j++ ) { + for ( j = 0; oc->oc_allowed != NULL && + oc->oc_allowed[j] != NULL; j++ ) { if ( strcasecmp( oc->oc_allowed[j], type ) == 0 || strcmp( oc->oc_allowed[j], "*" ) == 0 ) diff --git a/servers/slapd/tools/ldif2id2children.c b/servers/slapd/tools/ldif2id2children.c index 2fb2aaf603..b53ed8cdd3 100644 --- a/servers/slapd/tools/ldif2id2children.c +++ b/servers/slapd/tools/ldif2id2children.c @@ -121,7 +121,7 @@ main( int argc, char **argv ) fprintf( stderr, "No ldbm database found in config file\n" ); exit( 1 ); } - } else if ( dbnum < 1 || dbnum > nbackends ) { + } else if ( dbnum < 0 || dbnum > (nbackends-1) ) { fprintf( stderr, "Database number selected via -n is out of range\n" ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends ); exit( 1 ); diff --git a/servers/slapd/tools/ldif2id2entry.c b/servers/slapd/tools/ldif2id2entry.c index 5c8874c513..be25c22644 100644 --- a/servers/slapd/tools/ldif2id2entry.c +++ b/servers/slapd/tools/ldif2id2entry.c @@ -117,7 +117,7 @@ main( int argc, char **argv ) fprintf( stderr, "No ldbm database found in config file\n" ); exit( 1 ); } - } else if ( dbnum < 1 || dbnum > nbackends ) { + } else if ( dbnum < 0 || dbnum > (nbackends-1) ) { fprintf( stderr, "Database number selected via -n is out of range\n" ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends ); exit( 1 ); diff --git a/servers/slapd/tools/ldif2index.c b/servers/slapd/tools/ldif2index.c index af377f6751..20156d2b7d 100644 --- a/servers/slapd/tools/ldif2index.c +++ b/servers/slapd/tools/ldif2index.c @@ -108,7 +108,7 @@ main( int argc, char **argv ) fprintf( stderr, "No ldbm database found in config file\n" ); exit( 1 ); } - } else if ( dbnum < 1 || dbnum > nbackends ) { + } else if ( dbnum < 0 || dbnum > (nbackends-1) ) { fprintf( stderr, "Database number selected via -n is out of range\n" ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends ); exit( 1 ); diff --git a/servers/slapd/tools/ldif2ldbm.c b/servers/slapd/tools/ldif2ldbm.c index b2caa7b3cc..79e8c25a85 100644 --- a/servers/slapd/tools/ldif2ldbm.c +++ b/servers/slapd/tools/ldif2ldbm.c @@ -135,7 +135,7 @@ main( int argc, char **argv ) fprintf( stderr, "No ldbm database found in config file\n" ); exit( 1 ); } - } else if ( dbnum < 0 || dbnum > nbackends ) { + } else if ( dbnum < 0 || dbnum > (nbackends-1) ) { fprintf( stderr, "Database number selected via -n is out of range\n" ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends ); exit( 1 ); @@ -157,7 +157,7 @@ main( int argc, char **argv ) args[i++] = "-f"; args[i++] = tailorfile; args[i++] = "-n"; - sprintf( buf2, "%d", dbnum ); + sprintf( buf2, "%d", dbnum+1 ); args[i++] = buf2; if ( ldap_debug ) { sprintf( buf3, "%d", ldap_debug ); @@ -179,7 +179,7 @@ main( int argc, char **argv ) args[i++] = "-f"; args[i++] = tailorfile; args[i++] = "-n"; - sprintf( buf2, "%d", dbnum ); + sprintf( buf2, "%d", dbnum+1 ); args[i++] = buf2; if ( ldap_debug ) { sprintf( buf3, "%d", ldap_debug ); @@ -201,7 +201,7 @@ main( int argc, char **argv ) args[i++] = "-f"; args[i++] = tailorfile; args[i++] = "-n"; - sprintf( buf2, "%d", dbnum ); + sprintf( buf2, "%d", dbnum+1 ); args[i++] = buf2; if ( ldap_debug ) { sprintf( buf3, "%d", ldap_debug ); diff --git a/servers/slurpd/re.c b/servers/slurpd/re.c index 28d1d09b58..18043d98f8 100644 --- a/servers/slurpd/re.c +++ b/servers/slurpd/re.c @@ -31,9 +31,9 @@ extern char *str_getline( char **next ); extern void ch_free( char *p ); -#if !(defined(BSD) && (BSD >= 199306)) +#ifndef SYSERRLIST_IN_STDIO extern char *sys_errlist[]; -#endif +#endif /* SYSERRLIST_IN_STDIO /* Forward references */ static Rh *get_repl_hosts( char *, int *, char ** ); diff --git a/servers/slurpd/rq.c b/servers/slurpd/rq.c index 2745d4fe78..ef94cfa935 100644 --- a/servers/slurpd/rq.c +++ b/servers/slurpd/rq.c @@ -44,9 +44,9 @@ extern void Re_dump( Re *re ); extern void Re_dump(); #endif /* NEEDPROTOS */ -#if !(defined(BSD) && (BSD >= 199306)) +#ifndef SYSERRLIST_IN_STDIO extern char *sys_errlist[]; -#endif +#endif /* SYSERRLIST_IN_STDIO /* * Lock the replication queue.