Merged LDAPworldCurrent (P1-10,13,15,16,19-22)

Cleaned up old rcs keyworld subs
This commit is contained in:
Kurt Zeilenga 1998-08-09 04:13:55 +00:00
commit fcbca73f90
62 changed files with 623 additions and 295 deletions

View file

@ -197,6 +197,10 @@ LDAP_DEBUG=-DLDAP_DEBUG
# uncomment this line to enable support for LDAP referrals in libldap # uncomment this line to enable support for LDAP referrals in libldap
LDAP_REFERRALS=-DLDAP_REFERRALS 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. # uncomment this line to use soundex for approximate matches in slapd.
# the default is to use the metaphone algorithm. # the default is to use the metaphone algorithm.
#PHONETIC=-DSOUNDEX #PHONETIC=-DSOUNDEX

View file

@ -21,7 +21,7 @@
# DEFS are included in CFLAGS # DEFS are included in CFLAGS
DEFS = $(PLATFORMCFLAGS) $(LDAP_DEBUG) $(KERBEROS) $(AFSKERBEROS) \ DEFS = $(PLATFORMCFLAGS) $(LDAP_DEBUG) $(KERBEROS) $(AFSKERBEROS) \
$(UOFM) $(UOFA) $(NO_USERINTERFACE) $(CLDAP) $(NO_CACHE) \ $(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) \ $(LIBLDAP_CHARSETS) $(LIBLDAP_DEF_CHARSET) \
$(SLAPD_BACKENDS) $(LDBMBACKEND) $(LDBMINCLUDE) $(PHONETIC) $(SLAPD_BACKENDS) $(LDBMBACKEND) $(LDBMINCLUDE) $(PHONETIC)

View file

@ -14,4 +14,6 @@
CC = cc CC = cc
PLATFORMCFLAGS= -Dfreebsd PLATFORMCFLAGS= -Dfreebsd
# uncomment this line if using for LDAP_CRYPT
PLATFORMLIBS= -lcrypt PLATFORMLIBS= -lcrypt

View file

@ -1,4 +1,4 @@
: run this script through /bin/sh #! /bin/sh
RP500=ETCDIR/rp500 RP500=ETCDIR/rp500

View file

@ -111,8 +111,8 @@ ldapsearch.o: ../../include/ldapconfig.h
ldapmodify.o: ldapmodify.c ../../include/lber.h ../../include/proto-ldap.h ldapmodify.o: ldapmodify.c ../../include/lber.h ../../include/proto-ldap.h
ldapmodify.o: ../../include/ldapconfig.h ldapmodify.o: ../../include/ldapconfig.h
ldapdelete.o: ldapdelete.c ../../include/proto-lber.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: 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 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY

View file

@ -722,3 +722,22 @@ SIG_FN chwinsz()
(void) signal(SIGWINCH, chwinsz); (void) signal(SIGWINCH, chwinsz);
} }
#endif #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 */

View file

@ -226,8 +226,6 @@ FILE *where;
fatal(s) fatal(s)
char *s; char *s;
{ {
void exit();
if (errno != 0) if (errno != 0)
perror(s); perror(s);
#ifdef KERBEROS #ifdef KERBEROS

View file

@ -21,7 +21,7 @@
typedef struct avlnode { typedef struct avlnode {
caddr_t avl_data; caddr_t avl_data;
char avl_bf; signed char avl_bf;
struct avlnode *avl_left; struct avlnode *avl_left;
struct avlnode *avl_right; struct avlnode *avl_right;
} Avlnode; } Avlnode;

View file

@ -295,7 +295,7 @@ typedef struct ldapmsg {
BerElement *lm_ber; /* the ber encoded message contents */ BerElement *lm_ber; /* the ber encoded message contents */
struct ldapmsg *lm_chain; /* for search - next msg in the resp */ struct ldapmsg *lm_chain; /* for search - next msg in the resp */
struct ldapmsg *lm_next; /* next response */ struct ldapmsg *lm_next; /* next response */
unsigned long lm_time; /* used to maintain cache */ unsigned int lm_time; /* used to maintain cache */
} LDAPMessage; } LDAPMessage;
#define NULLMSG ((LDAPMessage *) NULL) #define NULLMSG ((LDAPMessage *) NULL)
@ -318,7 +318,7 @@ typedef struct ldap_server {
typedef struct ldap_conn { typedef struct ldap_conn {
Sockbuf *lconn_sb; Sockbuf *lconn_sb;
int lconn_refcnt; int lconn_refcnt;
unsigned long lconn_lastused; /* time */ unsigned int lconn_lastused; /* time */
int lconn_status; int lconn_status;
#define LDAP_CONNST_NEEDSOCKET 1 #define LDAP_CONNST_NEEDSOCKET 1
#define LDAP_CONNST_CONNECTING 2 #define LDAP_CONNST_CONNECTING 2
@ -569,6 +569,8 @@ extern char *strdup();
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
#if !defined(MACOS) && !defined(DOS) && !defined(_WIN32) && !defined(WINSOCK) #if !defined(MACOS) && !defined(DOS) && !defined(_WIN32) && !defined(WINSOCK)
#include <sys/types.h>
#include <time.h>
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#if defined(WINSOCK) #if defined(WINSOCK)

View file

@ -3,7 +3,40 @@
#ifndef _LTHREAD_H #ifndef _LTHREAD_H
#define _LTHREAD_H #define _LTHREAD_H
#if defined( THREAD_SUNOS4_LWP ) #if defined ( THREAD_NEXT_CTHREADS )
#define _THREAD
#include <mach/cthreads.h>
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 * * thread definitions for sunos4 *

View file

@ -61,9 +61,9 @@
#endif #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 #define USE_WAITPID
#endif #endif

View file

@ -157,6 +157,7 @@ ber_getnint( BerElement *ber, long *num, int len )
{ {
int diff, sign, i; int diff, sign, i;
long netnum; long netnum;
char *p;
/* /*
* The tag and length have already been stripped off. We should * The tag and length have already been stripped off. We should
@ -175,10 +176,11 @@ ber_getnint( BerElement *ber, long *num, int len )
return( -1 ); return( -1 );
/* sign extend if necessary */ /* sign extend if necessary */
sign = ((0x80 << ((len - 1) * 8)) & netnum); p = (char *) &netnum;
sign = (0x80 & *(p+diff) );
if ( sign && len < sizeof(long) ) { if ( sign && len < sizeof(long) ) {
for ( i = sizeof(long) - 1; i > len - 1; i-- ) { for ( i = 0; i < diff; i++ ) {
netnum |= (0xffL << (i * 8)); *(p+i) = 0xff;
} }
} }
*num = LBER_NTOHL( netnum ); *num = LBER_NTOHL( netnum );

View file

@ -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 friendly.o: friendly.c ../../include/lber.h ../../include/proto-ldap.h
cldap.o: cldap.c cldap.o: cldap.c
free.o: free.c ../../include/ldap.h free.o: free.c ../../include/ldap.h
disptmpl.o: disptmpl.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/proto-ldap.h srchpref.o: srchpref.c ../../include/proto-lber.h ../../include/srchpref.h
dsparse.o: dsparse.c ../../include/proto-lber.h ../../include/proto-ldap.h dsparse.o: dsparse.c ../../include/proto-lber.h
tmplout.o: tmplout.c ../../include/proto-lber.h ../../include/proto-ldap.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 getdn.o: getdn.c ../../include/lber.h ../../include/proto-ldap.h
getentry.o: getentry.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 getattr.o: getattr.c ../../include/lber.h ../../include/proto-ldap.h

View file

@ -107,7 +107,7 @@ do_abandon( LDAP *ld, int origid, int msgid )
err = 0; err = 0;
if ( sendabandon ) { if ( sendabandon ) {
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
err = -1; err = -1;
ld->ld_errno = LDAP_NO_MEMORY; ld->ld_errno = LDAP_NO_MEMORY;
} else { } else {
@ -151,10 +151,10 @@ do_abandon( LDAP *ld, int origid, int msgid )
#ifdef LDAP_REFERRALS #ifdef LDAP_REFERRALS
if ( lr != NULL ) { if ( lr != NULL ) {
if ( sendabandon ) { if ( sendabandon ) {
free_connection( ld, lr->lr_conn, 0, 1 ); ldap_free_connection( ld, lr->lr_conn, 0, 1 );
} }
if ( origid == msgid ) { if ( origid == msgid ) {
free_request( ld, lr ); ldap_free_request( ld, lr );
} }
} }
#endif /* LDAP_REFERRALS */ #endif /* LDAP_REFERRALS */

View file

@ -69,7 +69,7 @@ ldap_add( LDAP *ld, char *dn, LDAPMod **attrs )
Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 );
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( -1 ); return( -1 );
} }
@ -103,7 +103,7 @@ ldap_add( LDAP *ld, char *dn, LDAPMod **attrs )
} }
/* send the message */ /* 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 int

View file

@ -214,12 +214,12 @@ uncache_entry_or_req( LDAP *ld,
void 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; LDAPMessage *new;
long len; 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; ld->ld_errno = LDAP_SUCCESS;
if ( ld->ld_cache == NULLLDCACHE || 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) )) if (( new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
!= NULL ) { != 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 ); free( (char *)new );
return; return;
} }
@ -256,12 +256,12 @@ add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
void void
add_result_to_cache( LDAP *ld, LDAPMessage *result ) ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
{ {
LDAPMessage *m, **mp, *req, *new, *prev; LDAPMessage *m, **mp, *req, *new, *prev;
int err, keep; 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 ); result->lm_msgid, result->lm_msgtype, 0 );
if ( ld->ld_cache == NULLLDCACHE || if ( ld->ld_cache == NULLLDCACHE ||
@ -369,14 +369,14 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result )
* will find them. * will find them.
*/ */
int 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; LDAPMessage *m, *new, *prev, *next;
BerElement reqber; BerElement reqber;
int first, hash; int first, hash;
unsigned long validtime; 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 || if ( ld->ld_cache == NULLLDCACHE ||
( ld->ld_cache->lc_enabled == 0 )) { ( ld->ld_cache->lc_enabled == 0 )) {

View file

@ -170,7 +170,7 @@ cldap_open( char *host, int port )
if ( ld->ld_sb.sb_addrs == NULL if ( ld->ld_sb.sb_addrs == NULL
#ifdef LDAP_REFERRALS #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 */ #endif /* LDAP_REFERRALS */
) { ) {
free( ld ); 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", "cldap_result waiting up to %d seconds for a response\n",
tv.tv_sec, 0, 0 ); tv.tv_sec, 0, 0 );
ber_init( &ber, 0 ); ber_init( &ber, 0 );
set_ber_options( ld, &ber ); ldap_set_ber_options( ld, &ber );
if ( cldap_getmsg( ld, &tv, &ber ) == -1 ) { if ( cldap_getmsg( ld, &tv, &ber ) == -1 ) {
ret = ld->ld_errno; ret = ld->ld_errno;
@ -432,7 +432,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
tag != LBER_DEFAULT && rc != LDAP_SUCCESS; tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
tag = ber_next_element( ber, &len, cookie )) { tag = ber_next_element( ber, &len, cookie )) {
if (( ldm = (LDAPMessage *)calloc( 1, sizeof(LDAPMessage))) 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 ) { == NULLBER ) {
rc = LDAP_NO_MEMORY; rc = LDAP_NO_MEMORY;
break; /* return w/error*/ break; /* return w/error*/
@ -506,7 +506,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
#ifndef NO_CACHE #ifndef NO_CACHE
if ( ld->ld_cache != NULL ) { if ( ld->ld_cache != NULL ) {
add_result_to_cache( ld, ldm ); ldap_add_result_to_cache( ld, ldm );
} }
#endif /* NO_CACHE */ #endif /* NO_CACHE */

View file

@ -52,7 +52,7 @@ ldap_compare( LDAP *ld, char *dn, char *attr, char *value )
Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 );
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( -1 ); return( -1 );
} }
@ -65,17 +65,17 @@ ldap_compare( LDAP *ld, char *dn, char *attr, char *value )
#ifndef NO_CACHE #ifndef NO_CACHE
if ( ld->ld_cache != NULL ) { 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 ); ber_free( ber, 1 );
ld->ld_errno = LDAP_SUCCESS; ld->ld_errno = LDAP_SUCCESS;
return( ld->ld_msgid ); 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 */ #endif /* NO_CACHE */
/* send the message */ /* 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 int

View file

@ -51,7 +51,7 @@ ldap_delete( LDAP *ld, char *dn )
Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 );
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( -1 ); return( -1 );
} }
@ -63,7 +63,7 @@ ldap_delete( LDAP *ld, char *dn )
} }
/* send the message */ /* send the message */
return ( send_initial_request( ld, LDAP_REQ_DELETE, dn, ber )); return ( ldap_send_initial_request( ld, LDAP_REQ_DELETE, dn, ber ));
} }

View file

@ -36,7 +36,7 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 ); 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 ); return( NULL );
} }

View file

@ -3,7 +3,7 @@
* Copyright (c) 1995 Regents of the University of Michigan. * Copyright (c) 1995 Regents of the University of Michigan.
* All rights reserved. * 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 <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -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. * array.
*/ */
char ** char **
getdxbyname( char *domain ) ldap_getdxbyname( char *domain )
{ {
unsigned char buf[ PACKETSZ ]; unsigned char buf[ PACKETSZ ];
char **dxs; char **dxs;
int rc; 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 )); memset( buf, 0, sizeof( buf ));

View file

@ -52,7 +52,7 @@ ldap_kerberos_bind1( LDAP *ld, char *dn )
BerElement *ber; BerElement *ber;
char *cred; char *cred;
int rc, credlen; int rc, credlen;
char *get_kerberosv4_credentials(); char *ldap_get_kerberosv4_credentials();
#ifdef STR_TRANSLATION #ifdef STR_TRANSLATION
int str_translation_on; int str_translation_on;
#endif /* STR_TRANSLATION */ #endif /* STR_TRANSLATION */
@ -75,13 +75,13 @@ ldap_kerberos_bind1( LDAP *ld, char *dn )
if ( dn == NULL ) if ( dn == NULL )
dn = ""; dn = "";
if ( (cred = get_kerberosv4_credentials( ld, dn, "ldapserver", if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "ldapserver",
&credlen )) == NULL ) { &credlen )) == NULL ) {
return( -1 ); /* ld_errno should already be set */ return( -1 ); /* ld_errno should already be set */
} }
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
free( cred ); free( cred );
return( -1 ); return( -1 );
} }
@ -119,7 +119,7 @@ ldap_kerberos_bind1( LDAP *ld, char *dn )
#endif /* !NO_CACHE */ #endif /* !NO_CACHE */
/* send the message */ /* 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 int
@ -159,7 +159,7 @@ ldap_kerberos_bind2( LDAP *ld, char *dn )
BerElement *ber; BerElement *ber;
char *cred; char *cred;
int rc, credlen; int rc, credlen;
char *get_kerberosv4_credentials(); char *ldap_get_kerberosv4_credentials();
#ifdef STR_TRANSLATION #ifdef STR_TRANSLATION
int str_translation_on; int str_translation_on;
#endif /* STR_TRANSLATION */ #endif /* STR_TRANSLATION */
@ -169,13 +169,13 @@ ldap_kerberos_bind2( LDAP *ld, char *dn )
if ( dn == NULL ) if ( dn == NULL )
dn = ""; dn = "";
if ( (cred = get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen )) if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen ))
== NULL ) { == NULL ) {
return( -1 ); /* ld_errno should already be set */ return( -1 ); /* ld_errno should already be set */
} }
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
free( cred ); free( cred );
return( -1 ); return( -1 );
} }
@ -207,7 +207,7 @@ ldap_kerberos_bind2( LDAP *ld, char *dn )
} }
/* send the message */ /* 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 */ /* synchronous bind to DSA using kerberos */
@ -249,19 +249,19 @@ ldap_kerberos_bind_s( LDAP *ld, char *dn )
#ifndef AUTHMAN #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 * The dn of the entry to which to bind is supplied. It's assumed the
* user already has a tgt. * user already has a tgt.
*/ */
char * 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; KTEXT_ST ktxt;
int err; int err;
char realm[REALM_SZ], *cred, *krbinstance; 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 ) { if ( (err = krb_get_tf_realm( tkt_string(), realm )) != KSUCCESS ) {
#ifndef NO_USERINTERFACE #ifndef NO_USERINTERFACE

View file

@ -27,14 +27,14 @@
* in cache.c * in cache.c
*/ */
#ifdef NEEDPROTOS #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 ); BerElement *request );
void add_result_to_cache( LDAP *ld, LDAPMessage *result ); void ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result );
int check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ); int ldap_check_cache( LDAP *ld, unsigned long msgtype, BerElement *request );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
void add_request_to_cache(); void ldap_add_request_to_cache();
void add_result_to_cache(); void ldap_add_result_to_cache();
int check_cache(); int ldap_check_cache();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
@ -43,10 +43,10 @@ int check_cache();
* in kerberos.c * in kerberos.c
*/ */
#ifdef NEEDPROTOS #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 ); int *len );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
char *get_kerberosv4_credentials(); char *ldap_get_kerberosv4_credentials();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
#endif /* KERBEROS */ #endif /* KERBEROS */
@ -67,17 +67,17 @@ int open_ldap_connection();
* in os-ip.c * in os-ip.c
*/ */
#ifdef NEEDPROTOS #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 ); int async );
void close_connection( Sockbuf *sb ); void ldap_close_connection( Sockbuf *sb );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
int connect_to_host(); int ldap_connect_to_host();
void close_connection(); void ldap_close_connection();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
#ifdef KERBEROS #ifdef KERBEROS
#ifdef NEEDPROTOS #ifdef NEEDPROTOS
char *host_connected_to( Sockbuf *sb ); char *ldap_host_connected_to( Sockbuf *sb );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
char *host_connected_to(); char *host_connected_to();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
@ -86,22 +86,22 @@ char *host_connected_to();
#ifdef LDAP_REFERRALS #ifdef LDAP_REFERRALS
#ifdef NEEDPROTOS #ifdef NEEDPROTOS
int do_ldap_select( LDAP *ld, struct timeval *timeout ); int do_ldap_select( LDAP *ld, struct timeval *timeout );
void *new_select_info( void ); void *ldap_new_select_info( void );
void free_select_info( void *sip ); void ldap_free_select_info( void *sip );
void mark_select_write( LDAP *ld, Sockbuf *sb ); void ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
void mark_select_read( LDAP *ld, Sockbuf *sb ); void ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
void mark_select_clear( LDAP *ld, Sockbuf *sb ); void ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
int is_read_ready( LDAP *ld, Sockbuf *sb ); int ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
int is_write_ready( LDAP *ld, Sockbuf *sb ); int ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
int do_ldap_select(); int do_ldap_select();
void *new_select_info(); void *ldap_new_select_info();
void free_select_info(); void ldap_free_select_info();
void mark_select_write(); void ldap_mark_select_write();
void mark_select_read(); void ldap_mark_select_read();
void mark_select_clear(); void ldap_mark_select_clear();
int is_read_ready(); int ldap_is_read_ready();
int is_write_ready(); int ldap_is_write_ready();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
#endif /* LDAP_REFERRALS */ #endif /* LDAP_REFERRALS */
@ -110,46 +110,46 @@ int is_write_ready();
* in request.c * in request.c
*/ */
#ifdef NEEDPROTOS #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 ); char *dn, BerElement *ber );
BerElement *alloc_ber_with_options( LDAP *ld ); BerElement *ldap_alloc_ber_with_options( LDAP *ld );
void set_ber_options( LDAP *ld, BerElement *ber ); void ldap_set_ber_options( LDAP *ld, BerElement *ber );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
int send_initial_request(); int ldap_send_initial_request();
BerElement *alloc_ber_with_options(); BerElement *ldap_alloc_ber_with_options();
void set_ber_options(); void ldap_set_ber_options();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
#if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS )
#ifdef NEEDPROTOS #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, LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
int bind ); 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 ); int connect, int bind );
LDAPRequest *find_request_by_msgid( LDAP *ld, int msgid ); LDAPRequest *ldap_find_request_by_msgid( LDAP *ld, int msgid );
void free_request( LDAP *ld, LDAPRequest *lr ); void ldap_free_request( LDAP *ld, LDAPRequest *lr );
void free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ); void ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
void dump_connection( LDAP *ld, LDAPConn *lconns, int all ); void ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
void dump_requests_and_responses( LDAP *ld ); void ldap_dump_requests_and_responses( LDAP *ld );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
int send_server_request(); int ldap_send_server_request();
LDAPConn *new_connection(); LDAPConn *ldap_new_connection();
LDAPRequest *find_request_by_msgid(); LDAPRequest *ldap_find_request_by_msgid();
void free_request(); void ldap_free_request();
void free_connection(); void ldap_free_connection();
void dump_connection(); void ldap_dump_connection();
void dump_requests_and_responses(); void ldap_dump_requests_and_responses();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
#endif /* LDAP_REFERRALS || LDAP_DNS */ #endif /* LDAP_REFERRALS || LDAP_DNS */
#ifdef LDAP_REFERRALS #ifdef LDAP_REFERRALS
#ifdef NEEDPROTOS #ifdef NEEDPROTOS
int chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ); int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp );
int append_referral( LDAP *ld, char **referralsp, char *s ); int ldap_append_referral( LDAP *ld, char **referralsp, char *s );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
int chase_referrals(); int ldap_chase_referrals();
int append_referral(); int ldap_append_referral();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
#endif /* LDAP_REFERRALS */ #endif /* LDAP_REFERRALS */
@ -170,10 +170,10 @@ BerElement *ldap_build_search_req();
*/ */
#ifdef NEEDPROTOS #ifdef NEEDPROTOS
int ldap_ld_free( LDAP *ld, int close ); 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 */ #else /* NEEDPROTOS */
int ldap_ld_free(); int ldap_ld_free();
int send_unbind(); int ldap_send_unbind();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
@ -182,8 +182,31 @@ int send_unbind();
* in getdxbyname.c * in getdxbyname.c
*/ */
#ifdef NEEDPROTOS #ifdef NEEDPROTOS
char **getdxbyname( char *domain ); char **ldap_getdxbyname( char *domain );
#else /* NEEDPROTOS */ #else /* NEEDPROTOS */
char **getdxbyname(); char **ldap_getdxbyname();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
#endif /* LDAP_DNS */ #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 */

View file

@ -24,28 +24,30 @@
# #
"finger and ud and go500 and go500gw subtree and web500gw subtree and rp500 and rcpt500 and ufn last" "finger and ud and go500 and go500gw subtree and web500gw subtree and rp500 and rcpt500 and ufn last"
"^$" "" "(objectclass=*)" "default filter"
"=" " " "%v" "arbitrary 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)" "email address"
"(mail=%v*)" "start of email address" "(mail=%v*)" "start of email address"
"^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial" "^.[\. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
".*[. _].$" ". _" "(cn=%v1-*)" "last initial" ".*[. _].$" ". _" "(cn=%v1-*)" "last initial"
"[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact" "[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
"(|(sn~=%v1-)(cn~=%v1-))" "approximate" "(|(sn~=%v1-)(cn~=%v1-))" "approximate"
".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact" ".*" ". " "(|(cn=%v1)(sn=%v1)(ou=%v1))" "exact"
"(|(cn~=%v1)(sn~=%v1))" "approximate" "(|(cn~=%v1)(sn~=%v1)(ou~=%v1))" "approximate"
"go500gw onelevel and web500gw onelevel and ufn first and ufn intermediate" "go500gw onelevel and web500gw onelevel and ufn first and ufn intermediate"
"^$" "" "(!(objectclass=dSA))" "default filter"
"=" " " "%v" "arbitrary filter" "=" " " "%v" "arbitrary filter"
"^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact" "^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact2"
"(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate" "(|(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))" "exact"
"(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate" "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate"

View file

@ -69,7 +69,7 @@ ldap_modify( LDAP *ld, char *dn, LDAPMod **mods )
Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 );
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( -1 ); return( -1 );
} }
@ -105,7 +105,7 @@ ldap_modify( LDAP *ld, char *dn, LDAPMod **mods )
} }
/* send the message */ /* 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 int

View file

@ -53,7 +53,7 @@ ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 );
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( -1 ); return( -1 );
} }
@ -65,7 +65,7 @@ ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
} }
/* send the message */ /* 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 int

View file

@ -81,7 +81,7 @@ ldap_open( char *host, int port )
} }
srv->lsrv_port = ld->ld_defport; 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 ); if ( ld->ld_defhost != NULL ) free( srv->lsrv_host );
free( (char *)srv ); free( (char *)srv );
ldap_ld_free( ld, 0 ); ldap_ld_free( ld, 0 );
@ -126,7 +126,7 @@ ldap_init( char *defhost, int defport )
} }
#ifdef LDAP_REFERRALS #ifdef LDAP_REFERRALS
if (( ld->ld_selectinfo = new_select_info()) == NULL ) { if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) {
free( (char*)ld ); free( (char*)ld );
return( NULL ); return( NULL );
} }
@ -136,7 +136,7 @@ ldap_init( char *defhost, int defport )
if ( defhost != NULL && if ( defhost != NULL &&
( ld->ld_defhost = strdup( defhost )) == NULL ) { ( ld->ld_defhost = strdup( defhost )) == NULL ) {
#ifdef LDAP_REFERRALS #ifdef LDAP_REFERRALS
free_select_info( ld->ld_selectinfo ); ldap_free_select_info( ld->ld_selectinfo );
#endif /* LDAP_REFERRALS */ #endif /* LDAP_REFERRALS */
free( (char*)ld ); free( (char*)ld );
return( NULL ); return( NULL );
@ -148,6 +148,10 @@ ldap_init( char *defhost, int defport )
ld->ld_lberoptions = LBER_USE_DER; ld->ld_lberoptions = LBER_USE_DER;
ld->ld_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT; 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 ) #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS; ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS;
#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET #if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
@ -197,13 +201,13 @@ open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport,
port = defport; port = defport;
} }
if (( rc = connect_to_host( sb, curhost, 0L, if (( rc = ldap_connect_to_host( sb, curhost, 0L,
port, async )) != -1 ) { port, async )) != -1 ) {
break; break;
} }
} }
} else { } else {
rc = connect_to_host( sb, NULL, htonl( INADDR_LOOPBACK ), rc = ldap_connect_to_host( sb, NULL, htonl( INADDR_LOOPBACK ),
defport, async ); defport, async );
} }
@ -213,7 +217,7 @@ open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport,
if ( krbinstancep != NULL ) { if ( krbinstancep != NULL ) {
#ifdef KERBEROS #ifdef KERBEROS
if (( *krbinstancep = host_connected_to( sb )) != NULL && if (( *krbinstancep = ldap_host_connected_to( sb )) != NULL &&
( p = strchr( *krbinstancep, '.' )) != NULL ) { ( p = strchr( *krbinstancep, '.' )) != NULL ) {
*p = '\0'; *p = '\0';
} }

View file

@ -64,9 +64,10 @@ static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of
#endif /* DOS */ #endif /* DOS */
#endif /* MACOS */ #endif /* MACOS */
#include "ldap-int.h"
int 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 ) int port, int async )
/* /*
* if host == NULL, connect using address * if host == NULL, connect using address
@ -85,7 +86,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address,
#endif /* LDAP_REFERRALS */ #endif /* LDAP_REFERRALS */
#endif /* notyet */ #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 ); ( host == NULL ) ? "(by address)" : host, ntohs( port ), 0 );
connected = use_hp = 0; connected = use_hp = 0;
@ -174,7 +175,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address,
void void
close_connection( Sockbuf *sb ) ldap_close_connection( Sockbuf *sb )
{ {
tcp_close( sb->sb_sd ); tcp_close( sb->sb_sd );
} }
@ -182,7 +183,7 @@ close_connection( Sockbuf *sb )
#ifdef KERBEROS #ifdef KERBEROS
char * char *
host_connected_to( Sockbuf *sb ) ldap_host_connected_to( Sockbuf *sb )
{ {
struct hostent *hp; struct hostent *hp;
char *p; char *p;
@ -223,7 +224,7 @@ struct selectinfo {
void void
mark_select_write( LDAP *ld, Sockbuf *sb ) ldap_mark_select_write( LDAP *ld, Sockbuf *sb )
{ {
struct selectinfo *sip; struct selectinfo *sip;
@ -236,7 +237,7 @@ mark_select_write( LDAP *ld, Sockbuf *sb )
void void
mark_select_read( LDAP *ld, Sockbuf *sb ) ldap_mark_select_read( LDAP *ld, Sockbuf *sb )
{ {
struct selectinfo *sip; struct selectinfo *sip;
@ -249,7 +250,7 @@ mark_select_read( LDAP *ld, Sockbuf *sb )
void void
mark_select_clear( LDAP *ld, Sockbuf *sb ) ldap_mark_select_clear( LDAP *ld, Sockbuf *sb )
{ {
struct selectinfo *sip; struct selectinfo *sip;
@ -261,7 +262,7 @@ mark_select_clear( LDAP *ld, Sockbuf *sb )
int int
is_write_ready( LDAP *ld, Sockbuf *sb ) ldap_is_write_ready( LDAP *ld, Sockbuf *sb )
{ {
struct selectinfo *sip; struct selectinfo *sip;
@ -272,7 +273,7 @@ is_write_ready( LDAP *ld, Sockbuf *sb )
int int
is_read_ready( LDAP *ld, Sockbuf *sb ) ldap_is_read_ready( LDAP *ld, Sockbuf *sb )
{ {
struct selectinfo *sip; struct selectinfo *sip;
@ -283,7 +284,7 @@ is_read_ready( LDAP *ld, Sockbuf *sb )
void * void *
new_select_info() ldap_new_select_info()
{ {
struct selectinfo *sip; struct selectinfo *sip;
@ -298,7 +299,7 @@ new_select_info()
void void
free_select_info( void *sip ) ldap_free_select_info( void *sip )
{ {
free( sip ); free( sip );
} }

View file

@ -83,7 +83,7 @@ static BerElement *re_encode_request();
BerElement * BerElement *
alloc_ber_with_options( LDAP *ld ) ldap_alloc_ber_with_options( LDAP *ld )
{ {
BerElement *ber; BerElement *ber;
@ -91,7 +91,7 @@ alloc_ber_with_options( LDAP *ld )
ld->ld_errno = LDAP_NO_MEMORY; ld->ld_errno = LDAP_NO_MEMORY;
#ifdef STR_TRANSLATION #ifdef STR_TRANSLATION
} else { } else {
set_ber_options( ld, ber ); ldap_set_ber_options( ld, ber );
#endif /* STR_TRANSLATION */ #endif /* STR_TRANSLATION */
} }
@ -100,7 +100,7 @@ alloc_ber_with_options( LDAP *ld )
void void
set_ber_options( LDAP *ld, BerElement *ber ) ldap_set_ber_options( LDAP *ld, BerElement *ber )
{ {
ber->ber_options = ld->ld_lberoptions; ber->ber_options = ld->ld_lberoptions;
#ifdef STR_TRANSLATION #ifdef STR_TRANSLATION
@ -114,14 +114,14 @@ set_ber_options( LDAP *ld, BerElement *ber )
int int
send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn,
BerElement *ber ) BerElement *ber )
{ {
#if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS )
LDAPServer *servers; LDAPServer *servers;
#endif /* LDAP_REFERRALS || LDAP_DNS */ #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 !defined( LDAP_REFERRALS ) && !defined( LDAP_DNS )
if ( ber_flush( &ld->ld_sb, ber, 1 ) != 0 ) { 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 */ #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 )); NULL, 0 ));
#endif /* !LDAP_REFERRALS && !LDAP_DNS */ #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 ) #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS )
int 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 ) *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind )
{ {
LDAPRequest *lr; 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 */ ld->ld_errno = LDAP_SUCCESS; /* optimistic */
if ( lc == NULL ) { if ( lc == NULL ) {
@ -189,7 +191,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
} else { } else {
if (( lc = find_connection( ld, srvlist, 1 )) == if (( lc = find_connection( ld, srvlist, 1 )) ==
NULL ) { 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 ); free_servers( srvlist );
} }
@ -200,6 +207,10 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
if ( ld->ld_errno == LDAP_SUCCESS ) { if ( ld->ld_errno == LDAP_SUCCESS ) {
ld->ld_errno = LDAP_SERVER_DOWN; ld->ld_errno = LDAP_SERVER_DOWN;
} }
if ( incparent ) {
/* Forget about the bind */
--parentreq->lr_outrefcnt;
}
return( -1 ); return( -1 );
} }
@ -207,8 +218,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
if (( lr = (LDAPRequest *)calloc( 1, sizeof( LDAPRequest ))) == if (( lr = (LDAPRequest *)calloc( 1, sizeof( LDAPRequest ))) ==
NULL ) { NULL ) {
ld->ld_errno = LDAP_NO_MEMORY; ld->ld_errno = LDAP_NO_MEMORY;
free_connection( ld, lc, 0, 0 ); ldap_free_connection( ld, lc, 0, 0 );
ber_free( ber, 1 ); ber_free( ber, 1 );
if ( incparent ) {
/* Forget about the bind */
--parentreq->lr_outrefcnt;
}
return( -1 ); return( -1 );
} }
lr->lr_msgid = msgid; lr->lr_msgid = msgid;
@ -217,7 +232,10 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
lr->lr_ber = ber; lr->lr_ber = ber;
lr->lr_conn = lc; lr->lr_conn = lc;
if ( parentreq != NULL ) { /* sub-request */ if ( parentreq != NULL ) { /* sub-request */
if ( !incparent ) {
/* Increment if we didn't do it before the bind */
++parentreq->lr_outrefcnt; ++parentreq->lr_outrefcnt;
}
lr->lr_origid = parentreq->lr_origid; lr->lr_origid = parentreq->lr_origid;
lr->lr_parentcnt = parentreq->lr_parentcnt + 1; lr->lr_parentcnt = parentreq->lr_parentcnt + 1;
lr->lr_parent = parentreq; lr->lr_parent = parentreq;
@ -240,12 +258,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
if ( errno == EWOULDBLOCK ) { if ( errno == EWOULDBLOCK ) {
/* need to continue write later */ /* need to continue write later */
lr->lr_status = LDAP_REQST_WRITING; lr->lr_status = LDAP_REQST_WRITING;
mark_select_write( ld, lc->lconn_sb ); ldap_mark_select_write( ld, lc->lconn_sb );
} else { } else {
#else /* notyet */ #else /* notyet */
ld->ld_errno = LDAP_SERVER_DOWN; ld->ld_errno = LDAP_SERVER_DOWN;
free_request( ld, lr ); ldap_free_request( ld, lr );
free_connection( ld, lc, 0, 0 ); ldap_free_connection( ld, lc, 0, 0 );
return( -1 ); return( -1 );
#endif /* notyet */ #endif /* notyet */
#ifdef notyet #ifdef notyet
@ -258,7 +276,7 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
} }
/* sent -- waiting for a response */ /* 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; ld->ld_errno = LDAP_SUCCESS;
@ -267,7 +285,7 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
LDAPConn * LDAPConn *
new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
int connect, int bind ) int connect, int bind )
{ {
LDAPConn *lc; LDAPConn *lc;
@ -367,7 +385,7 @@ new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
} }
if ( err != 0 ) { if ( err != 0 ) {
free_connection( ld, lc, 1, 0 ); ldap_free_connection( ld, lc, 1, 0 );
lc = NULL; lc = NULL;
} }
} }
@ -414,19 +432,19 @@ use_connection( LDAP *ld, LDAPConn *lc )
void 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; 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 ( force || --lc->lconn_refcnt <= 0 ) {
if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) { if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) {
mark_select_clear( ld, lc->lconn_sb ); ldap_mark_select_clear( ld, lc->lconn_sb );
if ( unbind ) { 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 ) { if ( lc->lconn_sb->sb_ber.ber_buf != NULL ) {
free( lc->lconn_sb->sb_ber.ber_buf ); free( lc->lconn_sb->sb_ber.ber_buf );
} }
@ -442,6 +460,7 @@ free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
} }
break; break;
} }
prevlc = tmplc;
} }
free_servers( lc->lconn_server ); free_servers( lc->lconn_server );
if ( lc->lconn_krbinstance != NULL ) { 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( (char *)lc->lconn_sb );
} }
free( lc ); free( lc );
Debug( LDAP_DEBUG_TRACE, "free_connection: actually freed\n", Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: actually freed\n",
0, 0, 0 ); 0, 0, 0 );
} else { } else {
lc->lconn_lastused = time( 0 ); 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 ); lc->lconn_refcnt, 0, 0 );
} }
} }
@ -463,7 +482,7 @@ free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
#ifdef LDAP_DEBUG #ifdef LDAP_DEBUG
void void
dump_connection( LDAP *ld, LDAPConn *lconns, int all ) ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all )
{ {
LDAPConn *lc; LDAPConn *lc;
@ -490,7 +509,7 @@ dump_connection( LDAP *ld, LDAPConn *lconns, int all )
void void
dump_requests_and_responses( LDAP *ld ) ldap_dump_requests_and_responses( LDAP *ld )
{ {
LDAPRequest *lr; LDAPRequest *lr;
LDAPMessage *lm, *l; LDAPMessage *lm, *l;
@ -531,11 +550,11 @@ dump_requests_and_responses( LDAP *ld )
void void
free_request( LDAP *ld, LDAPRequest *lr ) ldap_free_request( LDAP *ld, LDAPRequest *lr )
{ {
LDAPRequest *tmplr, *nextlr; 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 ); lr->lr_origid, lr->lr_msgid, 0 );
if ( lr->lr_parent != NULL ) { if ( lr->lr_parent != NULL ) {
@ -544,7 +563,7 @@ free_request( LDAP *ld, LDAPRequest *lr )
/* free all referrals (child requests) */ /* free all referrals (child requests) */
for ( tmplr = lr->lr_refnext; tmplr != NULL; tmplr = nextlr ) { for ( tmplr = lr->lr_refnext; tmplr != NULL; tmplr = nextlr ) {
nextlr = tmplr->lr_refnext; 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 * XXX merging of errors in this routine needs to be improved
*/ */
int 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; int rc, count, len, newdn;
#ifdef LDAP_DNS #ifdef LDAP_DNS
@ -610,7 +629,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
LDAPServer *srv; LDAPServer *srv;
BerElement *ber; 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 */ ld->ld_errno = LDAP_SUCCESS; /* optimistic */
*hadrefp = 0; *hadrefp = 0;
@ -681,7 +700,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
} else { } else {
Debug( LDAP_DEBUG_TRACE, Debug( LDAP_DEBUG_TRACE,
"ignoring unknown referral <%s>\n", ref, 0, 0 ); "ignoring unknown referral <%s>\n", ref, 0, 0 );
rc = append_referral( ld, &unfollowed, ref ); rc = ldap_append_referral( ld, &unfollowed, ref );
*hadrefp = 1; *hadrefp = 1;
continue; continue;
} }
@ -728,14 +747,14 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
} }
#endif /* LDAP_DNS */ #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 ) { lr, srv, NULL, 1 ) >= 0 ) {
++count; ++count;
} else { } else {
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"Unable to chase referral (%s)\n", "Unable to chase referral (%s)\n",
ldap_err2string( ld->ld_errno ), 0, 0 ); ldap_err2string( ld->ld_errno ), 0, 0 );
rc = append_referral( ld, &unfollowed, ref ); rc = ldap_append_referral( ld, &unfollowed, ref );
} }
if ( !newdn && refdn != NULL ) { if ( !newdn && refdn != NULL ) {
@ -751,7 +770,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
int int
append_referral( LDAP *ld, char **referralsp, char *s ) ldap_append_referral( LDAP *ld, char **referralsp, char *s )
{ {
int first; int first;
@ -810,7 +829,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp )
return( NULL ); return( NULL );
} }
if (( ber = alloc_ber_with_options( ld )) == NULLBER ) { if (( ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( NULL ); return( NULL );
} }
@ -866,7 +885,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp )
LDAPRequest * LDAPRequest *
find_request_by_msgid( LDAP *ld, int msgid ) ldap_find_request_by_msgid( LDAP *ld, int msgid )
{ {
LDAPRequest *lr; LDAPRequest *lr;
@ -895,7 +914,7 @@ dn2servers( LDAP *ld, char *dn ) /* dn can also be a domain.... */
domain = dn; domain = dn;
} }
if (( dxs = getdxbyname( domain )) == NULL ) { if (( dxs = ldap_getdxbyname( domain )) == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY; ld->ld_errno = LDAP_NO_MEMORY;
return( NULL ); return( NULL );
} }

View file

@ -231,8 +231,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
#else /* !LDAP_REFERRALS */ #else /* !LDAP_REFERRALS */
#ifdef LDAP_DEBUG #ifdef LDAP_DEBUG
if ( ldap_debug & LDAP_DEBUG_TRACE ) { if ( ldap_debug & LDAP_DEBUG_TRACE ) {
dump_connection( ld, ld->ld_conns, 1 ); ldap_dump_connection( ld, ld->ld_conns, 1 );
dump_requests_and_responses( ld ); ldap_dump_requests_and_responses( ld );
} }
#endif /* LDAP_DEBUG */ #endif /* LDAP_DEBUG */
for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { 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; nextlc = lc->lconn_next;
if ( lc->lconn_status == if ( lc->lconn_status ==
LDAP_CONNST_CONNECTED && LDAP_CONNST_CONNECTED &&
is_read_ready( ld, ldap_is_read_ready( ld,
lc->lconn_sb )) { lc->lconn_sb )) {
rc = read1msg( ld, msgid, all, rc = read1msg( ld, msgid, all,
lc->lconn_sb, lc, result ); 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 ); Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 );
ber_init( &ber, 0 ); ber_init( &ber, 0 );
set_ber_options( ld, &ber ); ldap_set_ber_options( ld, &ber );
/* get the next message */ /* get the next message */
if ( (tag = ber_get_next( sb, &len, &ber )) if ( (tag = ber_get_next( sb, &len, &ber ))
@ -349,7 +349,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
} }
#ifdef LDAP_REFERRALS #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, Debug( LDAP_DEBUG_ANY,
"no request for response with msgid %ld (tossing)\n", "no request for response with msgid %ld (tossing)\n",
id, 0, 0 ); id, 0, 0 );
@ -384,7 +384,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
!= LBER_ERROR ) { != LBER_ERROR ) {
if ( lderr != LDAP_SUCCESS ) { if ( lderr != LDAP_SUCCESS ) {
/* referrals are in error string */ /* referrals are in error string */
refer_cnt = chase_referrals( ld, lr, refer_cnt = ldap_chase_referrals( ld, lr,
&lr->lr_res_error, &hadref ); &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 ) { 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 #ifndef NO_CACHE
if ( ld->ld_cache != NULL ) { if ( ld->ld_cache != NULL ) {
add_result_to_cache( ld, new ); ldap_add_result_to_cache( ld, new );
} }
#endif /* NO_CACHE */ #endif /* NO_CACHE */
@ -542,7 +542,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
prev->lm_next = l->lm_next; prev->lm_next = l->lm_next;
*result = l; *result = l;
ld->ld_errno = LDAP_SUCCESS; ld->ld_errno = LDAP_SUCCESS;
#ifndef ultrix
return( l->lm_msgtype );
#else
return( tag ); return( tag );
#endif
} }
return( -2 ); /* continue looking */ return( -2 ); /* continue looking */
@ -557,7 +561,7 @@ build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr )
long along; long along;
ber_init( ber, 0 ); ber_init( ber, 0 );
set_ber_options( ld, ber ); ldap_set_ber_options( ld, ber );
if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid, if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid,
(long)lr->lr_res_msgtype, lr->lr_res_errno, (long)lr->lr_res_msgtype, lr->lr_res_errno,
lr->lr_res_matched ? lr->lr_res_matched : "", 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 ) { if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) {
parentr->lr_res_errno = lr->lr_res_errno; parentr->lr_res_errno = lr->lr_res_errno;
if ( lr->lr_res_error != NULL ) { 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 ); lr->lr_res_error );
} }
} else if ( lr->lr_res_errno != LDAP_SUCCESS && } else if ( lr->lr_res_errno != LDAP_SUCCESS &&

View file

@ -61,7 +61,7 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd )
passwd = ""; passwd = "";
/* create a message to send */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( -1 ); return( -1 );
} }
@ -80,7 +80,7 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd )
#endif /* !NO_CACHE */ #endif /* !NO_CACHE */
/* send the message */ /* send the message */
return( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); return( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber ));
} }
/* /*

View file

@ -80,17 +80,17 @@ ldap_search( LDAP *ld, char *base, int scope, char *filter,
#ifndef NO_CACHE #ifndef NO_CACHE
if ( ld->ld_cache != NULL ) { 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 ); ber_free( ber, 1 );
ld->ld_errno = LDAP_SUCCESS; ld->ld_errno = LDAP_SUCCESS;
return( ld->ld_msgid ); 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 */ #endif /* NO_CACHE */
/* send the message */ /* 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 */ /* create a message to send */
if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( NULLBER ); return( NULLBER );
} }

View file

@ -31,6 +31,12 @@
#include "lber.h" #include "lber.h"
#include "ldap.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 ) #if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS )
#define MOD_USE_BVALS #define MOD_USE_BVALS
#endif /* !PCNFS && !WINSOCK && !MACOS */ #endif /* !PCNFS && !WINSOCK && !MACOS */

View file

@ -55,17 +55,17 @@ ldap_ld_free( LDAP *ld, int close )
/* free LDAP structure and outstanding requests/responses */ /* free LDAP structure and outstanding requests/responses */
for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) { for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) {
nextlr = lr->lr_next; nextlr = lr->lr_next;
free_request( ld, lr ); ldap_free_request( ld, lr );
} }
/* free and unbind from all open connections */ /* free and unbind from all open connections */
while ( ld->ld_conns != NULL ) { 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 */ #else /* LDAP_REFERRALS */
if ( close ) { if ( close ) {
err = send_unbind( ld, &ld->ld_sb ); err = ldap_send_unbind( ld, &ld->ld_sb );
close_connection( &ld->ld_sb ); ldap_close_connection( &ld->ld_sb );
} }
#endif /* LDAP_REFERRALS */ #endif /* LDAP_REFERRALS */
} else { } else {
@ -106,7 +106,7 @@ ldap_ld_free( LDAP *ld, int close )
#ifdef LDAP_REFERRALS #ifdef LDAP_REFERRALS
if ( ld->ld_selectinfo != NULL ) if ( ld->ld_selectinfo != NULL )
free_select_info( ld->ld_selectinfo ); ldap_free_select_info( ld->ld_selectinfo );
#endif /* LDAP_REFERRALS */ #endif /* LDAP_REFERRALS */
if ( ld->ld_defhost != NULL ) if ( ld->ld_defhost != NULL )
@ -125,14 +125,14 @@ ldap_unbind_s( LDAP *ld )
int int
send_unbind( LDAP *ld, Sockbuf *sb ) ldap_send_unbind( LDAP *ld, Sockbuf *sb )
{ {
BerElement *ber; 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 */ /* 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 ); return( ld->ld_errno );
} }

View file

@ -305,10 +305,10 @@ ldap_url_search( LDAP *ld, char *url, int attrsonly )
ber_free( ber, 1 ); ber_free( ber, 1 );
} else { } else {
#ifdef LDAP_REFERRALS #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 ); NULL, 1 );
#else /* LDAP_REFERRALS */ #else /* LDAP_REFERRALS */
err = send_initial_request( ld, LDAP_REQ_SEARCH, err = ldap_send_initial_request( ld, LDAP_REQ_SEARCH,
ludp->lud_dn, ber ); ludp->lud_dn, ber );
#endif /* LDAP_REFERRALS */ #endif /* LDAP_REFERRALS */
} }

View file

@ -2,7 +2,157 @@
#include <stdio.h> #include <stdio.h>
#include "lthread.h" #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 )
/*********************************************************************** /***********************************************************************
* * * *

View file

@ -29,12 +29,12 @@ static char copyright[] = "@(#) Copyright (c) 1994 Regents of the University of
#include "ldap-int.h" #include "ldap-int.h"
/* /*
* get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. * ldap_get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap.
*/ */
/* ARGSUSED */ /* ARGSUSED */
char * 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; static short authman_refnum = 0;
char *cred, ticket[ MAX_KTXT_LEN ]; char *cred, ticket[ MAX_KTXT_LEN ];

View file

@ -19,7 +19,7 @@ static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of
#include "ldap-int.h" #include "ldap-int.h"
int 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 ) int port, int async )
/* /*
* if host == NULL, connect using address * if host == NULL, connect using address
@ -37,7 +37,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address,
struct hostInfo hi; struct hostInfo hi;
#endif /* SUPPORT_OPENTRANSPORT */ #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 ); ( host == NULL ) ? "(by address)" : host, ntohs( port ), 0 );
if ( host != NULL && gethostinfobyname( host, &hi ) != noErr ) { if ( host != NULL && gethostinfobyname( host, &hi ) != noErr ) {
@ -78,7 +78,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address,
void void
close_connection( Sockbuf *sb ) ldap_close_connection( Sockbuf *sb )
{ {
tcpclose( (tcpstream *)sb->sb_sd ); tcpclose( (tcpstream *)sb->sb_sd );
} }
@ -86,7 +86,7 @@ close_connection( Sockbuf *sb )
#ifdef KERBEROS #ifdef KERBEROS
char * char *
host_connected_to( Sockbuf *sb ) ldap_host_connected_to( Sockbuf *sb )
{ {
ip_addr addr; ip_addr addr;
@ -131,13 +131,13 @@ struct selectinfo {
void void
mark_select_read( LDAP *ld, Sockbuf *sb ) ldap_mark_select_read( LDAP *ld, Sockbuf *sb )
{ {
struct selectinfo *sip; struct selectinfo *sip;
struct tcpstreaminfo *tcpsip; struct tcpstreaminfo *tcpsip;
short i; 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 ) { if (( sip = (struct selectinfo *)ld->ld_selectinfo ) == NULL ) {
return; return;
@ -170,12 +170,12 @@ mark_select_read( LDAP *ld, Sockbuf *sb )
void void
mark_select_clear( LDAP *ld, Sockbuf *sb ) ldap_mark_select_clear( LDAP *ld, Sockbuf *sb )
{ {
struct selectinfo *sip; struct selectinfo *sip;
short i; 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; sip = (struct selectinfo *)ld->ld_selectinfo;
if ( sip != NULL && sip->si_count > 0 && sip->si_streaminfo != NULL ) { if ( sip != NULL && sip->si_count > 0 && sip->si_streaminfo != NULL ) {
@ -196,7 +196,7 @@ mark_select_clear( LDAP *ld, Sockbuf *sb )
int int
is_read_ready( LDAP *ld, Sockbuf *sb ) ldap_is_read_ready( LDAP *ld, Sockbuf *sb )
{ {
struct selectinfo *sip; struct selectinfo *sip;
short i; short i;
@ -207,10 +207,10 @@ is_read_ready( LDAP *ld, Sockbuf *sb )
if ( sip->si_streaminfo[ i ].tcpsi_stream == (tcpstream *)sb->sb_sd ) { if ( sip->si_streaminfo[ i ].tcpsi_stream == (tcpstream *)sb->sb_sd ) {
#ifdef LDAP_DEBUG #ifdef LDAP_DEBUG
if ( sip->si_streaminfo[ i ].tcpsi_is_read_ready ) { 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 ); (tcpstream *)sb->sb_sd, 0, 0 );
} else { } 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 ); (tcpstream *)sb->sb_sd, 0, 0 );
} }
#endif /* LDAP_DEBUG */ #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 ); return( 0 );
} }
void * void *
new_select_info() ldap_new_select_info()
{ {
return( (void *)calloc( 1, sizeof( struct selectinfo ))); return( (void *)calloc( 1, sizeof( struct selectinfo )));
} }
void void
free_select_info( void *sip ) ldap_free_select_info( void *sip )
{ {
if ( sip != NULL ) { if ( sip != NULL ) {
free( sip ); free( sip );

View file

@ -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. * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
* *
* For copying and distribution information, please see the file * For copying and distribution information, please see the file

View file

@ -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. * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
* *
* For copying and distribution information, please see the file * For copying and distribution information, please see the file

View file

@ -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. * Copyright 1988 by the Massachusetts Institute of Technology.
* *
* For copying and distribution information, please see the file * For copying and distribution information, please see the file

View file

@ -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. * Copyright 1988 by the Massachusetts Institute of Technology.
* *
* For copying and distribution information, please see the file * For copying and distribution information, please see the file

View file

@ -5,11 +5,6 @@
* *
* Original version by Steve Dyer, IBM/Project Athena. * 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 * Vendor History
* *
* Revision 1.6 90/07/20 13:09:16 probe * Revision 1.6 90/07/20 13:09:16 probe

View file

@ -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. * Copyright 1988 by the Massachusetts Institute of Technology.
* *
* For copying and distribution information, please see the file * For copying and distribution information, please see the file

View file

@ -232,15 +232,14 @@ init.o: ../../include/ldap.h ../../include/lthread.h
detach.o: detach.c detach.o: detach.c
strdup.o: strdup.c strdup.o: strdup.c
tempnam.o: tempnam.c tempnam.o: tempnam.c
repl.o: repl.c ../../include/proto-lber.h ../../include/proto-ldap.h repl.o: repl.c ../../include/proto-lber.h ../../include/lthread.h
repl.o: ../../include/ldif.h
lock.o: lock.c ../../include/avl.h ../../include/ldap.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: schema.c ../../include/proto-lber.h ../../include/proto-ldap.h
schema.o: ../../include/ldif.h schema.o: ../../include/ldif.h
schemaparse.o: schemaparse.c ../../include/avl.h ../../include/ldap.h schemaparse.o: schemaparse.c ../../include/avl.h ../../include/ldap.h
schemaparse.o: ../../include/lthread.h schemaparse.o: ../../include/lthread.h
monitor.o: monitor.c ../../include/proto-lber.h ../../include/proto-ldap.h monitor.o: monitor.c ../../include/avl.h ../../include/ldap.h
monitor.o: ../../include/ldif.h monitor.o: ../../include/proto-ldap.h ../../include/ldif.h
configinfo.o: configinfo.c ../../include/avl.h ../../include/ldap.h configinfo.o: configinfo.c ../../include/avl.h ../../include/ldap.h
configinfo.o: ../../include/lthread.h ../../include/ldapconfig.h configinfo.o: ../../include/lthread.h ../../include/ldapconfig.h

View file

@ -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: id2entry.c ../../../include/avl.h ../../../include/proto-lber.h
id2entry.o: ../../../include/proto-ldap.h ../../../include/ldif.h id2entry.o: ../../../include/proto-ldap.h ../../../include/ldif.h
id2entry.o: ../../../include/ldbm.h id2entry.o: ../../../include/ldbm.h
index.o: index.c ../../../include/proto-lber.h ../../../include/proto-ldap.h index.o: index.c ../../../include/avl.h ../../../include/proto-lber.h
index.o: ../../../include/ldif.h ../../../include/ldbm.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: id2children.c ../../../include/proto-lber.h
id2children.o: ../../../include/proto-ldap.h ../../../include/ldif.h id2children.o: ../../../include/proto-ldap.h ../../../include/ldif.h
id2children.o: ../../../include/ldbm.h id2children.o: ../../../include/ldbm.h

View file

@ -10,6 +10,15 @@
#include "krb.h" #include "krb.h"
#endif #endif
#ifdef LDAP_CRYPT
/* change for crypted passwords -- lukeh */
#ifdef __NeXT__
extern char *crypt (char *key, char *salt);
#else
#include <unistd.h>
#endif
#endif /* LDAP_CRYPT */
extern Entry *dn2entry(); extern Entry *dn2entry();
extern Attribute *attr_find(); extern Attribute *attr_find();
@ -17,6 +26,40 @@ extern Attribute *attr_find();
extern int krbv4_ldap_auth(); extern int krbv4_ldap_auth();
#endif #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 int
ldbm_back_bind( ldbm_back_bind(
Backend *be, Backend *be,
@ -81,7 +124,12 @@ ldbm_back_bind(
return( 1 ); 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 ) ) { if ( be_isroot_pw( be, dn, cred ) ) {
/* front end will send result */ /* front end will send result */
return( 0 ); return( 0 );

View file

@ -726,12 +726,9 @@ idl_notin(
if ( a == NULL ) { if ( a == NULL ) {
return( NULL ); return( NULL );
} }
if ( b == NULL ) { if ( b == NULL || ALLIDS( b )) {
return( idl_dup( a ) ); return( idl_dup( a ) );
} }
if ( ALLIDS( b ) ) {
return( NULL );
}
if ( ALLIDS( a ) ) { if ( ALLIDS( a ) ) {
n = idl_alloc( SLAPD_LDBM_MIN_MAXIDS ); n = idl_alloc( SLAPD_LDBM_MIN_MAXIDS );

View file

@ -3,7 +3,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h>
#include "slap.h" #include "slap.h"
#include "back-ldbm.h" #include "back-ldbm.h"
@ -130,25 +129,26 @@ index_read(
realval = val; realval = val;
tmpval = NULL; tmpval = NULL;
if ( prefix != '\0' ) { if ( prefix != '\0' ) {
int len; int len = strlen( val );
if ( (len = strlen( val )) < sizeof(buf) ) { if ( (len + 2) < sizeof(buf) ) {
buf[0] = prefix;
strcpy( &buf[1], val );
realval = buf; realval = buf;
} else { } else {
/* value + prefix + null */ /* value + prefix + null */
tmpval = (char *) ch_malloc( len + 2 ); tmpval = (char *) ch_malloc( len + 2 );
tmpval[0] = prefix;
strcat( &tmpval[1], val );
realval = tmpval; realval = tmpval;
} }
realval[0] = prefix;
strcpy( &realval[1], val );
} }
key.dptr = realval; key.dptr = realval;
key.dsize = strlen( realval ) + 1; key.dsize = strlen( realval ) + 1;
idl = idl_fetch( be, db, key ); idl = idl_fetch( be, db, key );
if ( tmpval != NULL ) {
free( tmpval );
}
ldbm_cache_close( be, db ); ldbm_cache_close( be, db );
@ -181,19 +181,17 @@ add_value(
tmpval = NULL; tmpval = NULL;
idl = NULL; idl = NULL;
if ( prefix != '\0' ) { if ( prefix != '\0' ) {
int len; int len = strlen( val );
if ( (len = strlen( val )) < sizeof(buf) ) { if ( (len + 2) < sizeof(buf) ) {
buf[0] = prefix;
strcpy( &buf[1], val );
realval = buf; realval = buf;
} else { } else {
/* value + prefix + null */ /* value + prefix + null */
tmpval = (char *) ch_malloc( len + 2 ); tmpval = (char *) ch_malloc( len + 2 );
tmpval[0] = prefix;
strcat( &tmpval[1], val );
realval = tmpval; realval = tmpval;
} }
realval[0] = prefix;
strcpy( &realval[1], val );
} }
key.dptr = realval; key.dptr = realval;

View file

@ -15,6 +15,10 @@ ldbm_back_init(
char *argv[ 4 ]; char *argv[ 4 ];
int i; int i;
#ifdef LDAP_CRYPT
extern pthread_mutex_t crypt_mutex;
#endif /* LDAP_CRYPT */
/* allocate backend-specific stuff */ /* allocate backend-specific stuff */
li = (struct ldbminfo *) ch_calloc( 1, sizeof(struct ldbminfo) ); 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_cache.c_mutex, pthread_mutexattr_default );
pthread_mutex_init( &li->li_nextid_mutex, pthread_mutexattr_default ); pthread_mutex_init( &li->li_nextid_mutex, pthread_mutexattr_default );
pthread_mutex_init( &li->li_dbcache_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 ); pthread_cond_init( &li->li_dbcache_cv, pthread_condattr_default );
for ( i = 0; i < MAXDBCACHE; i++ ) { for ( i = 0; i < MAXDBCACHE; i++ ) {
pthread_mutex_init( &li->li_dbcache[i].dbc_mutex, pthread_mutex_init( &li->li_dbcache[i].dbc_mutex,

View file

@ -377,8 +377,9 @@ subtree_candidates(
f->f_or = (Filter *) ch_malloc( sizeof(Filter) ); f->f_or = (Filter *) ch_malloc( sizeof(Filter) );
f->f_or->f_choice = LDAP_FILTER_EQUALITY; f->f_or->f_choice = LDAP_FILTER_EQUALITY;
f->f_or->f_avtype = strdup( "objectclass" ); f->f_or->f_avtype = strdup( "objectclass" );
f->f_or->f_avvalue.bv_val = strdup( "referral" ); /* Patch to use normalized uppercase */
f->f_or->f_avvalue.bv_len = strlen( "referral" ); f->f_or->f_avvalue.bv_val = strdup( "REFERRAL" );
f->f_or->f_avvalue.bv_len = strlen( "REFERRAL" );
f->f_or->f_next = filter; f->f_or->f_next = filter;
filter = f; filter = f;

View file

@ -1,3 +1,10 @@
/* Revision history
*
* 5-Jun-96 hodges
* Added locking of new_conn_mutex when traversing the c[] array.
*/
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
@ -170,6 +177,8 @@ daemon(
Debug( LDAP_DEBUG_CONNS, Debug( LDAP_DEBUG_CONNS,
"listening for connections on %d, activity on:", "listening for connections on %d, activity on:",
tcps, 0, 0 ); tcps, 0, 0 );
pthread_mutex_lock( &new_conn_mutex );
for ( i = 0; i < dtblsize; i++ ) { for ( i = 0; i < dtblsize; i++ ) {
if ( c[i].c_sb.sb_sd != -1 ) { if ( c[i].c_sb.sb_sd != -1 ) {
FD_SET( c[i].c_sb.sb_sd, &readfds ); FD_SET( c[i].c_sb.sb_sd, &readfds );
@ -182,6 +191,7 @@ daemon(
} }
} }
Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 ); Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
pthread_mutex_unlock( &new_conn_mutex );
zero.tv_sec = 0; zero.tv_sec = 0;
zero.tv_usec = 0; zero.tv_usec = 0;

View file

@ -135,6 +135,7 @@ get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr )
Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 );
if ( (err = get_filter_list( conn, ber, &f->f_and, &ftmp )) if ( (err = get_filter_list( conn, ber, &f->f_and, &ftmp ))
== 0 ) { == 0 ) {
if (ftmp == NULL) ftmp = strdup("");
*fstr = ch_malloc( 4 + strlen( ftmp ) ); *fstr = ch_malloc( 4 + strlen( ftmp ) );
sprintf( *fstr, "(&%s)", ftmp ); sprintf( *fstr, "(&%s)", ftmp );
free( 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 ); Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 );
if ( (err = get_filter_list( conn, ber, &f->f_or, &ftmp )) if ( (err = get_filter_list( conn, ber, &f->f_or, &ftmp ))
== 0 ) { == 0 ) {
if (ftmp == NULL) ftmp = strdup("");
*fstr = ch_malloc( 4 + strlen( ftmp ) ); *fstr = ch_malloc( 4 + strlen( ftmp ) );
sprintf( *fstr, "(|%s)", ftmp ); sprintf( *fstr, "(|%s)", ftmp );
free( 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 ); Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 );
(void) ber_skip_tag( ber, &len ); (void) ber_skip_tag( ber, &len );
if ( (err = get_filter( conn, ber, &f->f_not, &ftmp )) == 0 ) { if ( (err = get_filter( conn, ber, &f->f_not, &ftmp )) == 0 ) {
if (ftmp == NULL) ftmp = strdup("");
*fstr = ch_malloc( 4 + strlen( ftmp ) ); *fstr = ch_malloc( 4 + strlen( ftmp ) );
sprintf( *fstr, "(!%s)", ftmp ); sprintf( *fstr, "(!%s)", ftmp );
free( ftmp ); free( ftmp );

View file

@ -223,11 +223,12 @@ test_approx_filter(
w2 = next_word( w2 ) ) { w2 = next_word( w2 ) ) {
c2 = phonetic( w2 ); c2 = phonetic( w2 );
if ( strcmp( c1, c2 ) == 0 ) { if ( strcmp( c1, c2 ) == 0 ) {
free( c2 );
break; break;
} }
free( c2 );
} }
free( c1 ); free( c1 );
free( c2 );
/* /*
* if we stopped because we ran out of words * if we stopped because we ran out of words

View file

@ -10,8 +10,16 @@
* is provided ``as is'' without express or implied warranty. * 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 <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include "slap.h" #include "slap.h"
@ -32,13 +40,11 @@ extern time_t currenttime;
extern time_t starttime; extern time_t starttime;
extern int num_conns; extern int num_conns;
extern pthread_mutex_t new_conn_mutex;
extern pthread_mutex_t currenttime_mutex;
extern char Versionstr[]; extern char Versionstr[];
/*
* no mutex protection in here - take our chances!
*/
void void
monitor_info( Connection *conn, Operation *op ) monitor_info( Connection *conn, Operation *op )
{ {
@ -73,6 +79,8 @@ monitor_info( Connection *conn, Operation *op )
nconns = 0; nconns = 0;
nwritewaiters = 0; nwritewaiters = 0;
nreadwaiters = 0; nreadwaiters = 0;
pthread_mutex_lock( &new_conn_mutex );
for ( i = 0; i < dtblsize; i++ ) { for ( i = 0; i < dtblsize; i++ ) {
if ( c[i].c_sb.sb_sd != -1 ) { if ( c[i].c_sb.sb_sd != -1 ) {
nconns++; nconns++;
@ -82,8 +90,11 @@ monitor_info( Connection *conn, Operation *op )
if ( c[i].c_gettingber ) { if ( c[i].c_gettingber ) {
nreadwaiters++; nreadwaiters++;
} }
pthread_mutex_lock( &currenttime_mutex );
ltm = localtime( &c[i].c_starttime ); ltm = localtime( &c[i].c_starttime );
strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm );
pthread_mutex_unlock( &currenttime_mutex );
pthread_mutex_lock( &c[i].c_dnmutex ); pthread_mutex_lock( &c[i].c_dnmutex );
sprintf( buf, "%d : %s : %ld : %ld : %s : %s%s", i, sprintf( buf, "%d : %s : %ld : %ld : %s : %s%s", i,
buf2, c[i].c_opsinitiated, c[i].c_opscompleted, buf2, c[i].c_opsinitiated, c[i].c_opscompleted,
@ -96,6 +107,8 @@ monitor_info( Connection *conn, Operation *op )
attr_merge( e, "connection", vals ); attr_merge( e, "connection", vals );
} }
} }
pthread_mutex_unlock( &new_conn_mutex );
sprintf( buf, "%d", nconns ); sprintf( buf, "%d", nconns );
val.bv_val = buf; val.bv_val = buf;
val.bv_len = strlen( buf ); val.bv_len = strlen( buf );
@ -141,14 +154,18 @@ monitor_info( Connection *conn, Operation *op )
val.bv_len = strlen( buf ); val.bv_len = strlen( buf );
attr_merge( e, "bytessent", vals ); attr_merge( e, "bytessent", vals );
pthread_mutex_lock( &currenttime_mutex );
ltm = localtime( &currenttime ); ltm = localtime( &currenttime );
strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
pthread_mutex_unlock( &currenttime_mutex );
val.bv_val = buf; val.bv_val = buf;
val.bv_len = strlen( buf ); val.bv_len = strlen( buf );
attr_merge( e, "currenttime", vals ); attr_merge( e, "currenttime", vals );
pthread_mutex_lock( &currenttime_mutex );
ltm = localtime( &starttime ); ltm = localtime( &starttime );
strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
pthread_mutex_unlock( &currenttime_mutex );
val.bv_val = buf; val.bv_val = buf;
val.bv_len = strlen( buf ); val.bv_len = strlen( buf );
attr_merge( e, "starttime", vals ); attr_merge( e, "starttime", vals );

View file

@ -111,14 +111,16 @@ oc_check_allowed( char *type, struct berval **ocl )
/* if we know about the oc */ /* if we know about the oc */
if ( (oc = oc_find( ocl[i]->bv_val )) != NULL ) { if ( (oc = oc_find( ocl[i]->bv_val )) != NULL ) {
/* does it require the type? */ /* 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 ) if ( strcasecmp( oc->oc_required[j], type )
== 0 ) { == 0 ) {
return( 0 ); return( 0 );
} }
} }
/* does it allow the type? */ /* 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 ) if ( strcasecmp( oc->oc_allowed[j], type )
== 0 || strcmp( oc->oc_allowed[j], "*" ) == 0 || strcmp( oc->oc_allowed[j], "*" )
== 0 ) == 0 )

View file

@ -121,7 +121,7 @@ main( int argc, char **argv )
fprintf( stderr, "No ldbm database found in config file\n" ); fprintf( stderr, "No ldbm database found in config file\n" );
exit( 1 ); 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, "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 ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
exit( 1 ); exit( 1 );

View file

@ -117,7 +117,7 @@ main( int argc, char **argv )
fprintf( stderr, "No ldbm database found in config file\n" ); fprintf( stderr, "No ldbm database found in config file\n" );
exit( 1 ); 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, "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 ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
exit( 1 ); exit( 1 );

View file

@ -108,7 +108,7 @@ main( int argc, char **argv )
fprintf( stderr, "No ldbm database found in config file\n" ); fprintf( stderr, "No ldbm database found in config file\n" );
exit( 1 ); 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, "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 ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
exit( 1 ); exit( 1 );

View file

@ -135,7 +135,7 @@ main( int argc, char **argv )
fprintf( stderr, "No ldbm database found in config file\n" ); fprintf( stderr, "No ldbm database found in config file\n" );
exit( 1 ); 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, "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 ); fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
exit( 1 ); exit( 1 );
@ -157,7 +157,7 @@ main( int argc, char **argv )
args[i++] = "-f"; args[i++] = "-f";
args[i++] = tailorfile; args[i++] = tailorfile;
args[i++] = "-n"; args[i++] = "-n";
sprintf( buf2, "%d", dbnum ); sprintf( buf2, "%d", dbnum+1 );
args[i++] = buf2; args[i++] = buf2;
if ( ldap_debug ) { if ( ldap_debug ) {
sprintf( buf3, "%d", ldap_debug ); sprintf( buf3, "%d", ldap_debug );
@ -179,7 +179,7 @@ main( int argc, char **argv )
args[i++] = "-f"; args[i++] = "-f";
args[i++] = tailorfile; args[i++] = tailorfile;
args[i++] = "-n"; args[i++] = "-n";
sprintf( buf2, "%d", dbnum ); sprintf( buf2, "%d", dbnum+1 );
args[i++] = buf2; args[i++] = buf2;
if ( ldap_debug ) { if ( ldap_debug ) {
sprintf( buf3, "%d", ldap_debug ); sprintf( buf3, "%d", ldap_debug );
@ -201,7 +201,7 @@ main( int argc, char **argv )
args[i++] = "-f"; args[i++] = "-f";
args[i++] = tailorfile; args[i++] = tailorfile;
args[i++] = "-n"; args[i++] = "-n";
sprintf( buf2, "%d", dbnum ); sprintf( buf2, "%d", dbnum+1 );
args[i++] = buf2; args[i++] = buf2;
if ( ldap_debug ) { if ( ldap_debug ) {
sprintf( buf3, "%d", ldap_debug ); sprintf( buf3, "%d", ldap_debug );

View file

@ -31,9 +31,9 @@
extern char *str_getline( char **next ); extern char *str_getline( char **next );
extern void ch_free( char *p ); extern void ch_free( char *p );
#if !(defined(BSD) && (BSD >= 199306)) #ifndef SYSERRLIST_IN_STDIO
extern char *sys_errlist[]; extern char *sys_errlist[];
#endif #endif /* SYSERRLIST_IN_STDIO
/* Forward references */ /* Forward references */
static Rh *get_repl_hosts( char *, int *, char ** ); static Rh *get_repl_hosts( char *, int *, char ** );

View file

@ -44,9 +44,9 @@ extern void Re_dump( Re *re );
extern void Re_dump(); extern void Re_dump();
#endif /* NEEDPROTOS */ #endif /* NEEDPROTOS */
#if !(defined(BSD) && (BSD >= 199306)) #ifndef SYSERRLIST_IN_STDIO
extern char *sys_errlist[]; extern char *sys_errlist[];
#endif #endif /* SYSERRLIST_IN_STDIO
/* /*
* Lock the replication queue. * Lock the replication queue.