mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-18 18:18:06 -05:00
More changes from -devel.
This commit is contained in:
parent
6f0bc8c997
commit
0c3899577f
32 changed files with 1253 additions and 617 deletions
137
include/lber.h
137
include/lber.h
|
|
@ -13,13 +13,9 @@
|
|||
#ifndef _LBER_H
|
||||
#define _LBER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <ldap_cdefs.h>
|
||||
|
||||
#if !defined( NEEDPROTOS ) && defined(__STDC__)
|
||||
#define NEEDPROTOS 1
|
||||
#endif
|
||||
LDAP_BEGIN_DECL
|
||||
|
||||
/* BER classes and mask */
|
||||
#define LBER_CLASS_UNIVERSAL 0x00
|
||||
|
|
@ -58,12 +54,9 @@ extern "C" {
|
|||
#define OLD_LBER_SEQUENCE 0x10L /* w/o constructed bit - broken */
|
||||
#define OLD_LBER_SET 0x11L /* w/o constructed bit - broken */
|
||||
|
||||
#ifdef NEEDPROTOS
|
||||
typedef int (*BERTranslateProc)( char **bufp, unsigned long *buflenp,
|
||||
int free_input );
|
||||
#else /* NEEDPROTOS */
|
||||
typedef int (*BERTranslateProc)();
|
||||
#endif /* NEEDPROTOS */
|
||||
typedef int (*BERTranslateProc) LDAP_P(( char **bufp,
|
||||
unsigned long *buflenp,
|
||||
int free_input ));
|
||||
|
||||
typedef struct berelement {
|
||||
char *ber_buf;
|
||||
|
|
@ -123,62 +116,80 @@ struct berval {
|
|||
char *bv_val;
|
||||
};
|
||||
|
||||
#ifndef NEEDPROTOS
|
||||
extern BerElement *ber_alloc();
|
||||
extern BerElement *der_alloc();
|
||||
extern BerElement *ber_alloc_t();
|
||||
extern BerElement *ber_dup();
|
||||
#ifdef LDAP_DEBUG
|
||||
extern int lber_debug;
|
||||
extern void ber_bvfree();
|
||||
extern void ber_bvecfree();
|
||||
extern struct berval *ber_bvdup();
|
||||
extern void ber_dump();
|
||||
extern void ber_sos_dump();
|
||||
extern void lber_bprint();
|
||||
extern void ber_reset();
|
||||
extern void ber_init();
|
||||
#else /* NEEDPROTOS */
|
||||
#if defined(WINSOCK)
|
||||
#include "proto-lb.h"
|
||||
#else
|
||||
#include "proto-lber.h"
|
||||
#endif
|
||||
#endif /* NEEDPROTOS */
|
||||
|
||||
#if !defined(__alpha) || defined(VMS)
|
||||
|
||||
#define LBER_HTONL( l ) htonl( l )
|
||||
#define LBER_NTOHL( l ) ntohl( l )
|
||||
|
||||
#else /* __alpha */
|
||||
/*
|
||||
* htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
|
||||
* lower-order 32-bits of a (64-bit) long, so we define correct versions
|
||||
* here.
|
||||
*/
|
||||
#define LBER_HTONL( l ) (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
|
||||
| htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
|
||||
|
||||
#define LBER_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
|
||||
| ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
|
||||
#endif /* __alpha */
|
||||
|
||||
|
||||
/*
|
||||
* SAFEMEMCPY is an overlap-safe copy from s to d of n bytes
|
||||
* in bprint.c:
|
||||
*/
|
||||
#ifdef MACOS
|
||||
#define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n )
|
||||
#else /* MACOS */
|
||||
#ifdef sunos4
|
||||
#define SAFEMEMCPY( d, s, n ) bcopy( s, d, n )
|
||||
#else /* sunos4 */
|
||||
#define SAFEMEMCPY( d, s, n ) memmove( d, s, n )
|
||||
#endif /* sunos4 */
|
||||
#endif /* MACOS */
|
||||
LDAP_F void lber_bprint LDAP_P(( char *data, int len ));
|
||||
|
||||
/*
|
||||
* in decode.c:
|
||||
*/
|
||||
LDAP_F unsigned long ber_get_tag LDAP_P(( BerElement *ber ));
|
||||
LDAP_F unsigned long ber_skip_tag LDAP_P(( BerElement *ber, unsigned long *len ));
|
||||
LDAP_F unsigned long ber_peek_tag LDAP_P(( BerElement *ber, unsigned long *len ));
|
||||
LDAP_F unsigned long ber_get_int LDAP_P(( BerElement *ber, long *num ));
|
||||
LDAP_F unsigned long ber_get_stringb LDAP_P(( BerElement *ber, char *buf,
|
||||
unsigned long *len ));
|
||||
LDAP_F unsigned long ber_get_stringa LDAP_P(( BerElement *ber, char **buf ));
|
||||
LDAP_F unsigned long ber_get_stringal LDAP_P(( BerElement *ber, struct berval **bv ));
|
||||
LDAP_F unsigned long ber_get_bitstringa LDAP_P(( BerElement *ber, char **buf,
|
||||
unsigned long *len ));
|
||||
LDAP_F unsigned long ber_get_null LDAP_P(( BerElement *ber ));
|
||||
LDAP_F unsigned long ber_get_boolean LDAP_P(( BerElement *ber, int *boolval ));
|
||||
LDAP_F unsigned long ber_first_element LDAP_P(( BerElement *ber, unsigned long *len,
|
||||
char **last ));
|
||||
LDAP_F unsigned long ber_next_element LDAP_P(( BerElement *ber, unsigned long *len,
|
||||
char *last ));
|
||||
LDAP_F unsigned long ber_scanf LDAP_P(( BerElement *ber, char *fmt, ... ));
|
||||
LDAP_F void ber_bvfree LDAP_P(( struct berval *bv ));
|
||||
LDAP_F void ber_bvecfree LDAP_P(( struct berval **bv ));
|
||||
LDAP_F struct berval *ber_bvdup LDAP_P(( struct berval *bv ));
|
||||
LDAP_F void ber_set_string_translators LDAP_P(( BerElement *ber,
|
||||
BERTranslateProc encode_proc, BERTranslateProc decode_proc ));
|
||||
|
||||
/*
|
||||
* in encode.c
|
||||
*/
|
||||
LDAP_F int ber_put_enum LDAP_P(( BerElement *ber, long num, unsigned long tag ));
|
||||
LDAP_F int ber_put_int LDAP_P(( BerElement *ber, long num, unsigned long tag ));
|
||||
LDAP_F int ber_put_ostring LDAP_P(( BerElement *ber, char *str, unsigned long len,
|
||||
unsigned long tag ));
|
||||
LDAP_F int ber_put_string LDAP_P(( BerElement *ber, char *str, unsigned long tag ));
|
||||
LDAP_F int ber_put_bitstring LDAP_P(( BerElement *ber, char *str,
|
||||
unsigned long bitlen, unsigned long tag ));
|
||||
LDAP_F int ber_put_null LDAP_P(( BerElement *ber, unsigned long tag ));
|
||||
LDAP_F int ber_put_boolean LDAP_P(( BerElement *ber, int boolval,
|
||||
unsigned long tag ));
|
||||
LDAP_F int ber_start_seq LDAP_P(( BerElement *ber, unsigned long tag ));
|
||||
LDAP_F int ber_start_set LDAP_P(( BerElement *ber, unsigned long tag ));
|
||||
LDAP_F int ber_put_seq LDAP_P(( BerElement *ber ));
|
||||
LDAP_F int ber_put_set LDAP_P(( BerElement *ber ));
|
||||
LDAP_F int ber_printf LDAP_P(( BerElement *ber, char *fmt, ... ));
|
||||
|
||||
/*
|
||||
* in io.c:
|
||||
*/
|
||||
|
||||
LDAP_F long ber_read LDAP_P(( BerElement *ber, char *buf, unsigned long len ));
|
||||
LDAP_F long ber_write LDAP_P(( BerElement *ber, char *buf, unsigned long len,
|
||||
int nosos ));
|
||||
LDAP_F void ber_free LDAP_P(( BerElement *ber, int freebuf ));
|
||||
LDAP_F int ber_flush LDAP_P(( Sockbuf *sb, BerElement *ber, int freeit ));
|
||||
LDAP_F BerElement *ber_alloc LDAP_P(( void ));
|
||||
LDAP_F BerElement *der_alloc LDAP_P(( void ));
|
||||
LDAP_F BerElement *ber_alloc_t LDAP_P(( int options ));
|
||||
LDAP_F BerElement *ber_dup LDAP_P(( BerElement *ber ));
|
||||
LDAP_F void ber_dump LDAP_P(( BerElement *ber, int inout ));
|
||||
LDAP_F void ber_sos_dump LDAP_P(( Seqorset *sos ));
|
||||
LDAP_F unsigned long ber_get_next LDAP_P(( Sockbuf *sb, unsigned long *len,
|
||||
BerElement *ber ));
|
||||
LDAP_F void ber_init LDAP_P(( BerElement *ber, int options ));
|
||||
LDAP_F void ber_reset LDAP_P(( BerElement *ber, int was_writing ));
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _LBER_H */
|
||||
|
|
|
|||
|
|
@ -5,30 +5,21 @@
|
|||
* cldap.c - synchronous, retrying interface to the cldap protocol
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the University of Michigan.\nAll rights reserved.\n";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifdef MACOS
|
||||
#include <stdlib.h>
|
||||
#include "macos.h"
|
||||
#else /* MACOS */
|
||||
#ifdef DOS
|
||||
#include "msdos.h"
|
||||
#else /* DOS */
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#endif /* DOS */
|
||||
#endif /* MACOS */
|
||||
|
||||
#include <ac/errno.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
|
|
@ -37,10 +28,6 @@ static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the Universi
|
|||
#define DEF_CLDAP_TIMEOUT 3
|
||||
#define DEF_CLDAP_TRIES 4
|
||||
|
||||
#ifndef INADDR_LOOPBACK
|
||||
#define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
|
||||
#endif
|
||||
|
||||
|
||||
struct cldap_retinfo {
|
||||
int cri_maxtries;
|
||||
|
|
@ -49,17 +36,14 @@ struct cldap_retinfo {
|
|||
long cri_timeout;
|
||||
};
|
||||
|
||||
#ifdef NEEDPROTOS
|
||||
static int add_addr( LDAP *ld, struct sockaddr *sap );
|
||||
static int cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
|
||||
struct cldap_retinfo *crip, char *base );
|
||||
static int cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
||||
LDAPMessage **res, char *base );
|
||||
#else /* NEEDPROTOS */
|
||||
static int add_addr();
|
||||
static int cldap_result();
|
||||
static int cldap_parsemsg();
|
||||
#endif /* NEEDPROTOS */
|
||||
static int add_addr LDAP_P((
|
||||
LDAP *ld, struct sockaddr *sap ));
|
||||
static int cldap_result LDAP_P((
|
||||
LDAP *ld, int msgid, LDAPMessage **res,
|
||||
struct cldap_retinfo *crip, char *base ));
|
||||
static int cldap_parsemsg LDAP_P((
|
||||
LDAP *ld, int msgid, BerElement *ber,
|
||||
LDAPMessage **res, char *base ));
|
||||
|
||||
/*
|
||||
* cldap_open - initialize and connect to an ldap server. A magic cookie to
|
||||
|
|
@ -127,7 +111,7 @@ cldap_open( char *host, int port )
|
|||
}
|
||||
}
|
||||
|
||||
if ( (address = inet_addr( host )) == -1 ) {
|
||||
if ( (address = inet_addr( host )) == -1UL ) {
|
||||
if ( (hp = gethostbyname( host )) == NULL ) {
|
||||
errno = EHOSTUNREACH;
|
||||
continue;
|
||||
|
|
@ -170,7 +154,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 );
|
||||
|
|
@ -240,7 +224,7 @@ cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
|
|||
attrsonly )) == -1 ) {
|
||||
return( ld->ld_errno );
|
||||
}
|
||||
#ifndef NO_CACHE
|
||||
#ifndef LDAP_NOCACHE
|
||||
if ( ld->ld_cache != NULL && ld->ld_responses != NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "cldap_search_s res from cache\n",
|
||||
0, 0, 0 );
|
||||
|
|
@ -248,7 +232,7 @@ cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
|
|||
ld->ld_responses = ld->ld_responses->lm_next;
|
||||
return( ldap_result2error( ld, *res, 0 ));
|
||||
}
|
||||
#endif /* NO_CACHE */
|
||||
#endif /* LDAP_NOCACHE */
|
||||
ret = cldap_result( ld, msgid, res, &cri, base );
|
||||
} while (ret == -1);
|
||||
|
||||
|
|
@ -316,7 +300,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 +416,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*/
|
||||
|
|
@ -504,11 +488,11 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
|||
}
|
||||
#endif /* LDAP_DEBUG */
|
||||
|
||||
#ifndef NO_CACHE
|
||||
#ifndef LDAP_NOCACHE
|
||||
if ( ld->ld_cache != NULL ) {
|
||||
add_result_to_cache( ld, ldm );
|
||||
ldap_add_result_to_cache( ld, ldm );
|
||||
}
|
||||
#endif /* NO_CACHE */
|
||||
#endif /* LDAP_NOCACHE */
|
||||
|
||||
if ( chain == NULL ) {
|
||||
chain = ldm;
|
||||
|
|
@ -534,4 +518,4 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
|||
*res = chain;
|
||||
return(( *res == NULLMSG ) ? rc : ldap_result2error( ld, *res, 0 ));
|
||||
}
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
|
|
|
|||
|
|
@ -5,68 +5,33 @@
|
|||
* os-ip.c -- platform-specific TCP & UDP related code
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
|
||||
#endif
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <ac/errno.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
#include <ac/unistd.h>
|
||||
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#include "msdos.h"
|
||||
#else /* _WIN32 */
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#endif /* _WIN32 */
|
||||
#ifdef _AIX
|
||||
#include <sys/select.h>
|
||||
#endif /* _AIX */
|
||||
#ifdef VMS
|
||||
#include "ucx_select.h"
|
||||
#endif /* VMS */
|
||||
#include "portable.h"
|
||||
#endif /* HAVE_IO_H */
|
||||
|
||||
#if defined( HAVE_SYS_FILIO_H )
|
||||
#include <sys/filio.h>
|
||||
#elif defined( HAVE_SYS_IOCTL_H )
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
|
||||
#ifdef LDAP_REFERRALS
|
||||
#ifdef USE_SYSCONF
|
||||
#include <unistd.h>
|
||||
#endif /* USE_SYSCONF */
|
||||
#ifdef notyet
|
||||
#ifdef NEED_FILIO
|
||||
#include <sys/filio.h>
|
||||
#else /* NEED_FILIO */
|
||||
#include <sys/ioctl.h>
|
||||
#endif /* NEED_FILIO */
|
||||
#endif /* notyet */
|
||||
#endif /* LDAP_REFERRALS */
|
||||
|
||||
#ifdef MACOS
|
||||
#define tcp_close( s ) tcpclose( s )
|
||||
#else /* MACOS */
|
||||
#ifdef DOS
|
||||
#ifdef PCNFS
|
||||
#define tcp_close( s ) close( s )
|
||||
#endif /* PCNFS */
|
||||
#ifdef NCSA
|
||||
#define tcp_close( s ) netclose( s ); netshut()
|
||||
#endif /* NCSA */
|
||||
#ifdef WINSOCK
|
||||
#define tcp_close( s ) closesocket( s ); WSACleanup();
|
||||
#endif /* WINSOCK */
|
||||
#else /* DOS */
|
||||
#define tcp_close( s ) close( s )
|
||||
#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
|
||||
|
|
@ -76,23 +41,28 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address,
|
|||
* XXX async is not used yet!
|
||||
*/
|
||||
{
|
||||
int rc, i, s, connected, use_hp;
|
||||
int rc, i, s = 0;
|
||||
int connected, use_hp;
|
||||
struct sockaddr_in sin;
|
||||
struct hostent *hp;
|
||||
struct hostent *hp = NULL;
|
||||
#ifdef notyet
|
||||
#ifdef LDAP_REFERRALS
|
||||
int status; /* for ioctl call */
|
||||
#endif /* LDAP_REFERRALS */
|
||||
#endif /* notyet */
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "connect_to_host: %s:%d\n",
|
||||
( host == NULL ) ? "(by address)" : host, ntohs( port ), 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "ldap_connect_to_host: %s:%d\n",
|
||||
( host == NULL ) ? "(by address)" : host, (int) ntohs( (short) port ), 0 );
|
||||
|
||||
connected = use_hp = 0;
|
||||
|
||||
if ( host != NULL && ( address = inet_addr( host )) == -1 ) {
|
||||
if ( host != NULL && ( address = inet_addr( host )) == -1UL ) {
|
||||
if ( (hp = gethostbyname( host )) == NULL ) {
|
||||
#ifdef HAVE_WINSOCK
|
||||
errno = WSAGetLastError();
|
||||
#else
|
||||
errno = EHOSTUNREACH; /* not exactly right, but... */
|
||||
#endif
|
||||
return( -1 );
|
||||
}
|
||||
use_hp = 1;
|
||||
|
|
@ -125,6 +95,9 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address,
|
|||
rc = 0;
|
||||
break;
|
||||
} else {
|
||||
#ifdef HAVE_WINSOCK
|
||||
errno = WSAGetLastError();
|
||||
#endif
|
||||
#ifdef notyet
|
||||
#ifdef LDAP_REFERRALS
|
||||
#ifdef EAGAIN
|
||||
|
|
@ -145,7 +118,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address,
|
|||
perror( (char *)inet_ntoa( sin.sin_addr ));
|
||||
}
|
||||
#endif
|
||||
close( s );
|
||||
tcp_close( s );
|
||||
if ( !use_hp ) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -166,7 +139,7 @@ connect_to_host( Sockbuf *sb, char *host, unsigned long address,
|
|||
#endif /* notyet */
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "sd %d connected to: %s\n",
|
||||
s, inet_ntoa( sin.sin_addr ), 0 );
|
||||
s, (char *) inet_ntoa( sin.sin_addr ), 0 );
|
||||
}
|
||||
|
||||
return( rc );
|
||||
|
|
@ -174,15 +147,15 @@ 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 );
|
||||
}
|
||||
|
||||
|
||||
#ifdef KERBEROS
|
||||
#ifdef HAVE_KERBEROS
|
||||
char *
|
||||
host_connected_to( Sockbuf *sb )
|
||||
ldap_host_connected_to( Sockbuf *sb )
|
||||
{
|
||||
struct hostent *hp;
|
||||
char *p;
|
||||
|
|
@ -209,7 +182,7 @@ host_connected_to( Sockbuf *sb )
|
|||
|
||||
return( NULL );
|
||||
}
|
||||
#endif /* KERBEROS */
|
||||
#endif /* HAVE_KERBEROS */
|
||||
|
||||
|
||||
#ifdef LDAP_REFERRALS
|
||||
|
|
@ -223,45 +196,45 @@ struct selectinfo {
|
|||
|
||||
|
||||
void
|
||||
mark_select_write( LDAP *ld, Sockbuf *sb )
|
||||
ldap_mark_select_write( LDAP *ld, Sockbuf *sb )
|
||||
{
|
||||
struct selectinfo *sip;
|
||||
|
||||
sip = (struct selectinfo *)ld->ld_selectinfo;
|
||||
|
||||
if ( !FD_ISSET( sb->sb_sd, &sip->si_writefds )) {
|
||||
FD_SET( sb->sb_sd, &sip->si_writefds );
|
||||
FD_SET( (u_int) sb->sb_sd, &sip->si_writefds );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mark_select_read( LDAP *ld, Sockbuf *sb )
|
||||
ldap_mark_select_read( LDAP *ld, Sockbuf *sb )
|
||||
{
|
||||
struct selectinfo *sip;
|
||||
|
||||
sip = (struct selectinfo *)ld->ld_selectinfo;
|
||||
|
||||
if ( !FD_ISSET( sb->sb_sd, &sip->si_readfds )) {
|
||||
FD_SET( sb->sb_sd, &sip->si_readfds );
|
||||
FD_SET( (u_int) sb->sb_sd, &sip->si_readfds );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mark_select_clear( LDAP *ld, Sockbuf *sb )
|
||||
ldap_mark_select_clear( LDAP *ld, Sockbuf *sb )
|
||||
{
|
||||
struct selectinfo *sip;
|
||||
|
||||
sip = (struct selectinfo *)ld->ld_selectinfo;
|
||||
|
||||
FD_CLR( sb->sb_sd, &sip->si_writefds );
|
||||
FD_CLR( sb->sb_sd, &sip->si_readfds );
|
||||
FD_CLR( (u_int) sb->sb_sd, &sip->si_writefds );
|
||||
FD_CLR( (u_int) sb->sb_sd, &sip->si_readfds );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
is_write_ready( LDAP *ld, Sockbuf *sb )
|
||||
ldap_is_write_ready( LDAP *ld, Sockbuf *sb )
|
||||
{
|
||||
struct selectinfo *sip;
|
||||
|
||||
|
|
@ -272,7 +245,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 +256,7 @@ is_read_ready( LDAP *ld, Sockbuf *sb )
|
|||
|
||||
|
||||
void *
|
||||
new_select_info()
|
||||
ldap_new_select_info()
|
||||
{
|
||||
struct selectinfo *sip;
|
||||
|
||||
|
|
@ -298,7 +271,7 @@ new_select_info()
|
|||
|
||||
|
||||
void
|
||||
free_select_info( void *sip )
|
||||
ldap_free_select_info( void *sip )
|
||||
{
|
||||
free( sip );
|
||||
}
|
||||
|
|
@ -313,11 +286,17 @@ do_ldap_select( LDAP *ld, struct timeval *timeout )
|
|||
Debug( LDAP_DEBUG_TRACE, "do_ldap_select\n", 0, 0, 0 );
|
||||
|
||||
if ( tblsize == 0 ) {
|
||||
#ifdef USE_SYSCONF
|
||||
#if defined( HAVE_SYSCONF )
|
||||
tblsize = sysconf( _SC_OPEN_MAX );
|
||||
#else /* USE_SYSCONF */
|
||||
#elif defined( HAVE_GETDTABLESIZE )
|
||||
tblsize = getdtablesize();
|
||||
#endif /* USE_SYSCONF */
|
||||
#endif /* !USE_SYSCONF */
|
||||
|
||||
#ifdef FD_SETSIZE
|
||||
if( tblsize > FD_SETSIZE ) {
|
||||
tblsize = FD_SETSIZE;
|
||||
}
|
||||
#endif /* FD_SETSIZE*/
|
||||
}
|
||||
|
||||
sip = (struct selectinfo *)ld->ld_selectinfo;
|
||||
|
|
|
|||
|
|
@ -10,19 +10,24 @@
|
|||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include <quipu/commonarg.h>
|
||||
#include <quipu/attrvalue.h>
|
||||
#include <quipu/ds_error.h>
|
||||
#include <quipu/abandon.h>
|
||||
#include <quipu/dap2.h>
|
||||
#include <quipu/dua.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "common.h"
|
||||
|
||||
int
|
||||
do_abandon(
|
||||
struct conn *dsaconn,
|
||||
BerElement *ber,
|
||||
|
|
|
|||
|
|
@ -10,27 +10,32 @@
|
|||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ac/errno.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
|
||||
#include <quipu/commonarg.h>
|
||||
#include <quipu/ds_error.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
|
||||
#if ISODEPACKAGE == IC
|
||||
#include <ll/isoaddrs.h>
|
||||
#else
|
||||
#include <isoaddrs.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#ifdef SVR4
|
||||
#if !defined(_AIX) && !defined(__osf__)
|
||||
#include <sys/filio.h>
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_FILIO_H
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
#ifdef __hpux
|
||||
|
|
@ -215,7 +220,8 @@ conn_add( struct conn *new )
|
|||
conns = new;
|
||||
}
|
||||
|
||||
static psap_cmp( struct PSAPaddr *a, struct PSAPaddr *b )
|
||||
static int
|
||||
psap_cmp( struct PSAPaddr *a, struct PSAPaddr *b )
|
||||
{
|
||||
return( bcmp( (char *) a, (char *) b, sizeof(struct PSAPaddr) ) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,21 @@
|
|||
* donated by Eric Rosenquist and BNR
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <ac/ctype.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
|
||||
#include <quipu/commonarg.h>
|
||||
#include <quipu/attrvalue.h>
|
||||
#include <quipu/ds_error.h>
|
||||
#include <quipu/ds_search.h>
|
||||
#include <quipu/dap2.h>
|
||||
#include <quipu/dua.h>
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "common.h"
|
||||
|
|
@ -306,9 +309,9 @@ void certif_init()
|
|||
{
|
||||
extern short ldap_certif_syntax;
|
||||
sntx_table *syntax_table;
|
||||
extern sntx_table *get_syntax_table();
|
||||
extern sntx_table *get_syntax_table( short int sntx );
|
||||
|
||||
if (syntax_table = get_syntax_table(ldap_certif_syntax)) {
|
||||
if ((syntax_table = get_syntax_table(ldap_certif_syntax)) != NULL) {
|
||||
syntax_table->s_print = (void *) ldap_certif_print;
|
||||
syntax_table->s_parse = (void *) ldap_str2cert;
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "common.h"
|
||||
#include "lutil.h" /* Get lutil_detach() */
|
||||
|
||||
#ifdef HAVE_TCPD
|
||||
#include <tcpd.h>
|
||||
|
|
@ -48,11 +49,11 @@ int deny_severity = LOG_NOTICE;
|
|||
#endif /* TCP_WRAPPERS */
|
||||
|
||||
void log_and_exit();
|
||||
static set_socket();
|
||||
static do_queries();
|
||||
static int set_socket();
|
||||
static void do_queries();
|
||||
static RETSIGTYPE wait4child();
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
static udp_init();
|
||||
static int udp_init();
|
||||
#endif
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
|
|
@ -83,8 +84,8 @@ int RunFromInetd = 0;
|
|||
|
||||
extern char Versionstr[];
|
||||
|
||||
static usage( name )
|
||||
char *name;
|
||||
static void
|
||||
usage( char *name )
|
||||
{
|
||||
fprintf( stderr, "usage: %s [-d debuglvl] [-p port] [-l] [-c dsa] [-r referraltimeout]", name );
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
|
|
@ -99,6 +100,7 @@ char *name;
|
|||
fprintf( stderr, "\n" );
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
|
|
@ -305,7 +307,7 @@ char **argv;
|
|||
(void) get_syntaxes();
|
||||
if (RunFromInetd) {
|
||||
len = sizeof( socktype );
|
||||
getsockopt( ns, SOL_SOCKET, SO_TYPE, &socktype, &len );
|
||||
getsockopt( ns, SOL_SOCKET, SO_TYPE, (char *)&socktype, &len );
|
||||
if ( socktype == SOCK_DGRAM ) {
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
Debug( LDAP_DEBUG_ARGS,
|
||||
|
|
@ -488,14 +490,14 @@ char **argv;
|
|||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
static
|
||||
static void
|
||||
do_queries(
|
||||
int clientsock,
|
||||
int udp /* is this a UDP (CLDAP) request? */
|
||||
)
|
||||
{
|
||||
fd_set readfds;
|
||||
int rc, i;
|
||||
int rc;
|
||||
struct timeval timeout;
|
||||
Sockbuf sb;
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
|
|
@ -544,6 +546,7 @@ do_queries(
|
|||
|
||||
#ifdef LDAP_DEBUG
|
||||
if ( ldap_debug & LDAP_DEBUG_CONNS ) {
|
||||
int i;
|
||||
Debug( LDAP_DEBUG_CONNS, "FDLIST:", 0, 0, 0 );
|
||||
for ( i = 0; i < dtblsize; i++ ) {
|
||||
if ( FD_ISSET( i, &readfds ) ) {
|
||||
|
|
@ -602,7 +605,8 @@ do_queries(
|
|||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
static set_socket(
|
||||
static int
|
||||
set_socket(
|
||||
int port,
|
||||
int udp /* UDP port? */
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,13 +10,16 @@
|
|||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
|
||||
#include <quipu/commonarg.h>
|
||||
#include <quipu/ds_error.h>
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "common.h"
|
||||
|
|
@ -49,7 +52,7 @@ struct msg *add_msg(
|
|||
new->m_conn->c_refcnt++;
|
||||
new->m_next = NULL;
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
new->m_cldap = udp;
|
||||
new->m_searchbase = NULLDN;
|
||||
|
||||
|
|
@ -93,8 +96,8 @@ del_msg( struct msg *m )
|
|||
}
|
||||
|
||||
if ( cur == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "delmsg: cannot find msg %x\n", m,
|
||||
0, 0 );
|
||||
Debug( LDAP_DEBUG_ANY, "delmsg: cannot find msg %lx\n",
|
||||
(unsigned long) m, 0, 0 );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
|
@ -106,11 +109,11 @@ del_msg( struct msg *m )
|
|||
conn_free( cur->m_conn );
|
||||
modlist_free( cur->m_mods );
|
||||
ber_free( cur->m_ber, 1 );
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( cur->m_searchbase != NULLDN ) {
|
||||
dn_free( cur->m_searchbase );
|
||||
}
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
free( (char *) cur );
|
||||
|
||||
return( 0 );
|
||||
|
|
@ -146,7 +149,7 @@ send_msg(
|
|||
}
|
||||
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
struct msg *
|
||||
get_cldap_msg(
|
||||
int msgid,
|
||||
|
|
@ -169,4 +172,4 @@ get_cldap_msg(
|
|||
|
||||
return( tmp );
|
||||
}
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
|
|
|
|||
|
|
@ -10,25 +10,22 @@
|
|||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <ac/signal.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/syslog.h>
|
||||
#include <ac/time.h>
|
||||
#include <ac/wait.h>
|
||||
|
||||
#include <quipu/commonarg.h>
|
||||
#include <quipu/ds_error.h>
|
||||
#include <quipu/dap2.h>
|
||||
#include <quipu/dua.h>
|
||||
#ifdef __hpux
|
||||
#include <syslog.h>
|
||||
#else
|
||||
#include <sys/syslog.h>
|
||||
#endif
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "common.h"
|
||||
|
|
@ -74,7 +71,7 @@ client_request(
|
|||
static int bound;
|
||||
extern char *bound_dn, *bound_pw;
|
||||
struct PSAPaddr *psap_cpy();
|
||||
#ifdef COMPAT
|
||||
#ifdef LDAP_COMPAT
|
||||
extern int ldap_compat;
|
||||
#endif
|
||||
|
||||
|
|
@ -92,7 +89,7 @@ client_request(
|
|||
log_and_exit( 1 );
|
||||
}
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( udp && dosyslog ) {
|
||||
syslog( LOG_INFO, "UDP request from unknown (%s)",
|
||||
inet_ntoa( ((struct sockaddr_in *)
|
||||
|
|
@ -105,7 +102,7 @@ client_request(
|
|||
trace_ber( tag, len, ber.ber_buf, stderr, 1, 1 );
|
||||
#endif
|
||||
|
||||
#ifdef COMPAT
|
||||
#ifdef LDAP_COMPAT
|
||||
/*
|
||||
* This tag should be a normal SEQUENCE tag. In release 2.0 this
|
||||
* tag is 0x10. In the new stuff this is 0x30. To distinguish
|
||||
|
|
@ -137,8 +134,8 @@ client_request(
|
|||
ttag = ber_skip_tag( &tber, &tlen );
|
||||
ttag = ber_peek_tag( &tber, &tlen );
|
||||
|
||||
Debug( LDAP_DEBUG_ANY, "checking for 3.0 tag 0x%x\n",
|
||||
ttag, 0, 0 );
|
||||
Debug( LDAP_DEBUG_ANY, "checking for 3.0 tag 0x%lx\n",
|
||||
ttag, 0, 0 );
|
||||
if ( ttag == LBER_SEQUENCE ) {
|
||||
Debug( LDAP_DEBUG_ANY, "version 3.0 detected\n",
|
||||
0, 0, 0 );
|
||||
|
|
@ -159,7 +156,7 @@ client_request(
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( udp ) {
|
||||
char *logdn = NULL;
|
||||
|
||||
|
|
@ -172,16 +169,16 @@ client_request(
|
|||
free( logdn );
|
||||
}
|
||||
}
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 )
|
||||
tag = ber_skip_tag( &ber, &len );
|
||||
else
|
||||
#endif
|
||||
tag = ber_peek_tag( &ber, &len );
|
||||
if ( !udp && bound == 0 && tag != LDAP_REQ_BIND
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
&& tag != OLD_LDAP_REQ_BIND
|
||||
#endif
|
||||
) {
|
||||
|
|
@ -191,7 +188,7 @@ client_request(
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if (udp && tag != LDAP_REQ_SEARCH && tag != LDAP_REQ_ABANDON ) {
|
||||
send_ldap_result( clientsb, tag, msgid, LDAP_OPERATIONS_ERROR,
|
||||
NULL, "Only search is supported over UDP/CLDAP" );
|
||||
|
|
@ -216,7 +213,7 @@ client_request(
|
|||
copyofber = ber_dup( &ber );
|
||||
|
||||
m = add_msg( msgid, tag, copyofber, dsaconn, udp,
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
(struct sockaddr *)clientsb->sb_fromaddr );
|
||||
#else
|
||||
NULL );
|
||||
|
|
@ -257,17 +254,17 @@ do_request(
|
|||
Debug( LDAP_DEBUG_TRACE, "do_request\n", 0, 0, 0 );
|
||||
|
||||
switch ( m->m_msgtype ) {
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_BIND:
|
||||
#endif
|
||||
case LDAP_REQ_BIND:
|
||||
resp_required = do_bind( clientsb, m, ber, bound );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_UNBIND:
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
case LDAP_REQ_UNBIND_30:
|
||||
#endif
|
||||
case LDAP_REQ_UNBIND:
|
||||
|
|
@ -275,55 +272,55 @@ do_request(
|
|||
log_and_exit( 0 );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_ADD:
|
||||
#endif
|
||||
case LDAP_REQ_ADD:
|
||||
resp_required = do_add( clientsb, m, ber );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_DELETE:
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
case LDAP_REQ_DELETE_30:
|
||||
#endif
|
||||
case LDAP_REQ_DELETE:
|
||||
resp_required = do_delete( clientsb, m, ber );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_MODRDN:
|
||||
#endif
|
||||
case LDAP_REQ_MODRDN:
|
||||
resp_required = do_modrdn( clientsb, m, ber );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_MODIFY:
|
||||
#endif
|
||||
case LDAP_REQ_MODIFY:
|
||||
resp_required = do_modify( clientsb, m, ber );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_COMPARE:
|
||||
#endif
|
||||
case LDAP_REQ_COMPARE:
|
||||
resp_required = do_compare( clientsb, m, ber );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_SEARCH:
|
||||
#endif
|
||||
case LDAP_REQ_SEARCH:
|
||||
resp_required = do_search( clientsb, m, ber );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_REQ_ABANDON:
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
case LDAP_REQ_ABANDON_30:
|
||||
#endif
|
||||
case LDAP_REQ_ABANDON:
|
||||
|
|
|
|||
|
|
@ -10,25 +10,29 @@
|
|||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
|
||||
#include <quipu/commonarg.h>
|
||||
#include <quipu/attrvalue.h>
|
||||
#include <quipu/ds_error.h>
|
||||
#include <quipu/ds_search.h>
|
||||
#include <quipu/dap2.h>
|
||||
#include <quipu/dua.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "common.h"
|
||||
|
||||
static get_filter();
|
||||
static get_filter_list();
|
||||
static get_substring_filter();
|
||||
static int get_filter();
|
||||
static int get_filter_list();
|
||||
static int get_substring_filter();
|
||||
|
||||
#ifdef COMPAT
|
||||
#ifdef LDAP_COMPAT
|
||||
extern int version;
|
||||
extern int ldap_compat;
|
||||
#define SEARCHRESTAG (ldap_compat == 20 ? OLD_LDAP_RES_SEARCH_RESULT : LDAP_RES_SEARCH_RESULT)
|
||||
|
|
@ -182,11 +186,11 @@ do_search(
|
|||
|
||||
rc = initiate_dap_operation( OP_SEARCH, m, &sa );
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( m->m_cldap )
|
||||
m->m_searchbase = sa.sra_baseobject;
|
||||
else
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
dn_free( sa.sra_baseobject );
|
||||
|
||||
filter_free( sa.sra_filter );
|
||||
|
|
@ -201,7 +205,8 @@ do_search(
|
|||
return( 1 );
|
||||
}
|
||||
|
||||
static get_filter( BerElement *ber, Filter *filt )
|
||||
static int
|
||||
get_filter( BerElement *ber, Filter *filt )
|
||||
{
|
||||
unsigned long tag, len;
|
||||
int err;
|
||||
|
|
@ -240,14 +245,14 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
|
||||
err = 0;
|
||||
switch (tag = ber_peek_tag( ber, &len )) {
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_EQUALITY:
|
||||
#endif
|
||||
case LDAP_FILTER_EQUALITY:
|
||||
Debug( LDAP_DEBUG_ARGS, "EQUALITY\n", 0, 0, 0 );
|
||||
f->flt_type = FILTER_ITEM;
|
||||
f->FUITEM.fi_type = FILTERITEM_EQUALITY;
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 )
|
||||
(void) ber_skip_tag( ber, &len );
|
||||
#endif
|
||||
|
|
@ -258,7 +263,7 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
}
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_SUBSTRINGS:
|
||||
#endif
|
||||
case LDAP_FILTER_SUBSTRINGS:
|
||||
|
|
@ -266,14 +271,14 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
err = get_substring_filter( ber, f );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_GE:
|
||||
#endif
|
||||
case LDAP_FILTER_GE:
|
||||
Debug( LDAP_DEBUG_ARGS, "GE\n", 0, 0, 0 );
|
||||
f->flt_type = FILTER_ITEM;
|
||||
f->FUITEM.fi_type = FILTERITEM_GREATEROREQUAL;
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 )
|
||||
(void) ber_skip_tag( ber, &len );
|
||||
#endif
|
||||
|
|
@ -283,14 +288,14 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
}
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_LE:
|
||||
#endif
|
||||
case LDAP_FILTER_LE:
|
||||
Debug( LDAP_DEBUG_ARGS, "LE\n", 0, 0, 0 );
|
||||
f->flt_type = FILTER_ITEM;
|
||||
f->FUITEM.fi_type = FILTERITEM_LESSOREQUAL;
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 )
|
||||
(void) ber_skip_tag( ber, &len );
|
||||
#endif
|
||||
|
|
@ -301,10 +306,10 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
}
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_PRESENT:
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
case LDAP_FILTER_PRESENT_30:
|
||||
#endif
|
||||
case LDAP_FILTER_PRESENT:
|
||||
|
|
@ -312,7 +317,7 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
f->flt_type = FILTER_ITEM;
|
||||
f->FUITEM.fi_type = FILTERITEM_PRESENT;
|
||||
len = sizeof(typestr);
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 )
|
||||
(void) ber_skip_tag( ber, &len );
|
||||
#endif
|
||||
|
|
@ -323,14 +328,14 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
return( LDAP_UNDEFINED_TYPE );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_APPROX:
|
||||
#endif
|
||||
case LDAP_FILTER_APPROX:
|
||||
Debug( LDAP_DEBUG_ARGS, "APPROX\n", 0, 0, 0 );
|
||||
f->flt_type = FILTER_ITEM;
|
||||
f->FUITEM.fi_type = FILTERITEM_APPROX;
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 )
|
||||
(void) ber_skip_tag( ber, &len );
|
||||
#endif
|
||||
|
|
@ -341,7 +346,7 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
}
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_AND:
|
||||
#endif
|
||||
case LDAP_FILTER_AND:
|
||||
|
|
@ -350,7 +355,7 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
err = get_filter_list( ber, f );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_OR:
|
||||
#endif
|
||||
case LDAP_FILTER_OR:
|
||||
|
|
@ -359,7 +364,7 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
err = get_filter_list( ber, f );
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_FILTER_NOT:
|
||||
#endif
|
||||
case LDAP_FILTER_NOT:
|
||||
|
|
@ -370,7 +375,7 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
break;
|
||||
|
||||
default:
|
||||
Debug( LDAP_DEBUG_ANY, "unknown filter type %d\n", tag, 0, 0 );
|
||||
Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n", tag, 0, 0 );
|
||||
free( f );
|
||||
return( LDAP_PROTOCOL_ERROR );
|
||||
break;
|
||||
|
|
@ -380,7 +385,8 @@ static get_filter( BerElement *ber, Filter *filt )
|
|||
return( err );
|
||||
}
|
||||
|
||||
static get_filter_list( BerElement *ber, Filter f )
|
||||
static int
|
||||
get_filter_list( BerElement *ber, Filter f )
|
||||
{
|
||||
Filter new, tail;
|
||||
int err;
|
||||
|
|
@ -389,7 +395,7 @@ static get_filter_list( BerElement *ber, Filter f )
|
|||
|
||||
Debug( LDAP_DEBUG_TRACE, "get_filter_list\n", 0, 0, 0 );
|
||||
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 )
|
||||
(void) ber_skip_tag( ber, &len );
|
||||
#endif
|
||||
|
|
@ -411,7 +417,8 @@ static get_filter_list( BerElement *ber, Filter f )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
static get_substring_filter( BerElement *ber, Filter f )
|
||||
static int
|
||||
get_substring_filter( BerElement *ber, Filter f )
|
||||
{
|
||||
unsigned long tag, len;
|
||||
char typestr[64];
|
||||
|
|
@ -422,7 +429,7 @@ static get_substring_filter( BerElement *ber, Filter f )
|
|||
|
||||
Debug( LDAP_DEBUG_TRACE, "get_substring_filter\n", 0, 0, 0 );
|
||||
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 )
|
||||
(void) ber_skip_tag( ber, &len );
|
||||
#endif
|
||||
|
|
@ -444,7 +451,7 @@ static get_substring_filter( BerElement *ber, Filter f )
|
|||
tag = ber_next_element( ber, &len, last ) ) {
|
||||
AV_Sequence avs, any_end;
|
||||
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 ) {
|
||||
if ( ber_scanf( ber, "{a}", &valstr ) == LBER_ERROR ) {
|
||||
return( LDAP_PROTOCOL_ERROR );
|
||||
|
|
@ -466,10 +473,10 @@ static get_substring_filter( BerElement *ber, Filter f )
|
|||
return( LDAP_OPERATIONS_ERROR );
|
||||
|
||||
switch ( tag ) {
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_SUBSTRING_INITIAL:
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
case LDAP_SUBSTRING_INITIAL_30:
|
||||
#endif
|
||||
case LDAP_SUBSTRING_INITIAL:
|
||||
|
|
@ -482,10 +489,10 @@ static get_substring_filter( BerElement *ber, Filter f )
|
|||
f->FUITEM.UNSUB.fi_sub_initial = avs;
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_SUBSTRING_ANY:
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
case LDAP_SUBSTRING_ANY_30:
|
||||
#endif
|
||||
case LDAP_SUBSTRING_ANY:
|
||||
|
|
@ -500,10 +507,10 @@ static get_substring_filter( BerElement *ber, Filter f )
|
|||
any_end = avs;
|
||||
break;
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
case OLD_LDAP_SUBSTRING_FINAL:
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
case LDAP_SUBSTRING_FINAL_30:
|
||||
#endif
|
||||
case LDAP_SUBSTRING_FINAL:
|
||||
|
|
@ -546,7 +553,7 @@ search_result(
|
|||
correlate_search_results( sr );
|
||||
}
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( m->m_cldap ) {
|
||||
if ((ber = der_alloc()) == NULLBER ) {
|
||||
send_ldap_msgresult( sb, SEARCHRESTAG, m,
|
||||
|
|
@ -565,9 +572,9 @@ search_result(
|
|||
for ( e = sr->CSR_entries; e != NULLENTRYINFO; e = e->ent_next ) {
|
||||
Debug( LDAP_DEBUG_ARGS, "\tentry:\n", 0, 0, 0 );
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( !m->m_cldap )
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
|
||||
if ( (ber = der_alloc()) == NULLBER ) {
|
||||
send_ldap_msgresult( sb, SEARCHRESTAG, m,
|
||||
|
|
@ -575,7 +582,7 @@ search_result(
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
if ( version == 1 ) {
|
||||
if ( ber_printf( ber, "t{it{", OLD_LBER_SEQUENCE,
|
||||
m->m_msgid, OLD_LDAP_RES_SEARCH_ENTRY ) == -1 ) {
|
||||
|
|
@ -585,7 +592,7 @@ search_result(
|
|||
}
|
||||
} else
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 ) {
|
||||
if ( ber_printf( ber, "{it{{", m->m_msgid,
|
||||
LDAP_RES_SEARCH_ENTRY ) == -1 ) {
|
||||
|
|
@ -595,11 +602,11 @@ search_result(
|
|||
}
|
||||
} else
|
||||
#endif
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( m->m_cldap )
|
||||
rc = ber_printf( ber, "t{", LDAP_RES_SEARCH_ENTRY );
|
||||
else
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
rc = ber_printf( ber, "{it{", m->m_msgid,
|
||||
LDAP_RES_SEARCH_ENTRY );
|
||||
|
||||
|
|
@ -609,10 +616,10 @@ search_result(
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( m->m_cldap )
|
||||
rc = encode_dn( ber, e->ent_dn, m->m_searchbase );
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
else
|
||||
rc = encode_dn( ber, e->ent_dn, NULLDN );
|
||||
|
||||
|
|
@ -628,7 +635,7 @@ search_result(
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
if ( version == 1 ) {
|
||||
if ( ber_printf( ber, "}}" ) == -1 ) {
|
||||
send_ldap_msgresult( sb, SEARCHRESTAG, m,
|
||||
|
|
@ -638,7 +645,7 @@ search_result(
|
|||
}
|
||||
} else
|
||||
#endif
|
||||
#ifdef COMPAT30
|
||||
#ifdef LDAP_COMPAT30
|
||||
if ( ldap_compat == 30 ) {
|
||||
if ( ber_printf( ber, "}}}" ) == -1 ) {
|
||||
send_ldap_msgresult( sb, SEARCHRESTAG, m,
|
||||
|
|
@ -648,11 +655,11 @@ search_result(
|
|||
}
|
||||
} else
|
||||
#endif
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( m->m_cldap )
|
||||
rc = ber_printf( ber, "}" );
|
||||
else
|
||||
#endif /* CLDAP */
|
||||
#endif /* LDAP_CONNECTIONLESS */
|
||||
rc = ber_printf( ber, "}}" );
|
||||
|
||||
if ( rc == -1 ) {
|
||||
|
|
@ -667,7 +674,7 @@ search_result(
|
|||
ber->ber_buf, stderr, 0, 0 );
|
||||
#endif
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( !m->m_cldap )
|
||||
#endif
|
||||
(void) ber_flush( sb, ber, 1 );
|
||||
|
|
@ -688,7 +695,7 @@ search_result(
|
|||
|
||||
Debug( LDAP_DEBUG_ARGS, "\tresult:\n", 0, 0, 0 );
|
||||
|
||||
#ifdef CLDAP
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( m->m_cldap ) {
|
||||
if ( ber_printf( ber, "t{ess}}}", SEARCHRESTAG, rc, "", "" )
|
||||
== -1 ) {
|
||||
|
|
|
|||
|
|
@ -10,17 +10,21 @@
|
|||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <ac/ctype.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
|
||||
#include <quipu/commonarg.h>
|
||||
#include <quipu/attrvalue.h>
|
||||
#include <quipu/ds_error.h>
|
||||
#include <quipu/ds_search.h>
|
||||
#include <quipu/dap2.h>
|
||||
#include <quipu/dua.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "common.h"
|
||||
|
|
@ -52,7 +56,8 @@ short ldap_dLSubmitPermission_syntax;
|
|||
static void de_t61( char *s, int t61mark );
|
||||
static int syntax_is_string( short syntax );
|
||||
|
||||
static get_one_syntax( char *attrib, int required )
|
||||
static int
|
||||
get_one_syntax( char *attrib, int required )
|
||||
{
|
||||
oid_table_attr *p, *name2attr();
|
||||
|
||||
|
|
@ -332,7 +337,8 @@ encode_dn(
|
|||
return( rc );
|
||||
}
|
||||
|
||||
static put_jpeg_value( BerElement *ber, AttributeValue av )
|
||||
static int
|
||||
put_jpeg_value( BerElement *ber, AttributeValue av )
|
||||
{
|
||||
PE pe;
|
||||
int len;
|
||||
|
|
@ -375,7 +381,8 @@ static put_jpeg_value( BerElement *ber, AttributeValue av )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
static put_audio_value( BerElement *ber, AttributeValue av )
|
||||
static int
|
||||
put_audio_value( BerElement *ber, AttributeValue av )
|
||||
{
|
||||
struct qbuf *qb, *p;
|
||||
int rc, len;
|
||||
|
|
@ -412,7 +419,8 @@ static put_audio_value( BerElement *ber, AttributeValue av )
|
|||
return( rc );
|
||||
}
|
||||
|
||||
static put_photo_value( BerElement *ber, AttributeValue av )
|
||||
static int
|
||||
put_photo_value( BerElement *ber, AttributeValue av )
|
||||
{
|
||||
PE pe;
|
||||
PS ps;
|
||||
|
|
@ -474,7 +482,8 @@ static put_photo_value( BerElement *ber, AttributeValue av )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
static put_values(
|
||||
static int
|
||||
put_values(
|
||||
BerElement *ber,
|
||||
PS ps,
|
||||
short syntax,
|
||||
|
|
@ -544,7 +553,7 @@ int
|
|||
encode_attrs( BerElement *ber, Attr_Sequence as )
|
||||
{
|
||||
PS ps;
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
extern int ldap_compat;
|
||||
#endif
|
||||
|
||||
|
|
@ -555,7 +564,7 @@ encode_attrs( BerElement *ber, Attr_Sequence as )
|
|||
if ( str_setup( ps, NULLCP, 0, 0 ) == NOTOK )
|
||||
return( -1 );
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
if ( ber_printf( ber, "t{", ldap_compat == 20 ? OLD_LBER_SEQUENCE :
|
||||
LBER_SEQUENCE ) == -1 ) {
|
||||
#else
|
||||
|
|
@ -570,7 +579,7 @@ encode_attrs( BerElement *ber, Attr_Sequence as )
|
|||
AttrT_print( ps, as->attr_type, EDBOUT );
|
||||
*ps->ps_ptr = '\0';
|
||||
|
||||
#ifdef COMPAT20
|
||||
#ifdef LDAP_COMPAT20
|
||||
if ( ber_printf( ber, "t{st[", ldap_compat == 20 ?
|
||||
OLD_LBER_SEQUENCE : LBER_SEQUENCE, ps->ps_base,
|
||||
ldap_compat == 20 ? OLD_LBER_SET : LBER_SET ) == -1 ) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
/* abandon.c - ldbm backend abandon routine */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
int
|
||||
ldbm_back_abandon()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
235
servers/slapd/back-ldbm/alias.c
Normal file
235
servers/slapd/back-ldbm/alias.c
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* Copyright (c) 1998 Will Ballantyne, ITSD, Government of BC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to ITSD, Government of BC. The name of ITSD
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ac/socket.h> /* Get struct sockaddr for slap.h */
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
/*
|
||||
* given an alias object, dereference it to its end point.
|
||||
* entry returned has reader lock
|
||||
*/
|
||||
Entry *derefAlias_r ( Backend *be,
|
||||
Connection *conn,
|
||||
Operation *op,
|
||||
Entry *e)
|
||||
{
|
||||
Attribute *a;
|
||||
int depth;
|
||||
char **pastAliases;
|
||||
char *matched;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= checking for alias for dn %s\n", e->e_dn, 0, 0 );
|
||||
|
||||
/*
|
||||
* try to deref fully, up to a maximum depth. If the max depth exceeded
|
||||
* then send an error
|
||||
*/
|
||||
for ( depth = 0;
|
||||
( ( a = attr_find( e->e_attrs, "aliasedobjectname" ) ) != NULL) &&
|
||||
( depth < be->be_maxDerefDepth );
|
||||
++depth)
|
||||
{
|
||||
|
||||
/*
|
||||
* make sure there is a defined aliasedobjectname.
|
||||
* can only have one value so just use first value (0) in the attr list.
|
||||
*/
|
||||
if (a->a_vals[0] && a->a_vals[0]->bv_val) {
|
||||
char *newDN, *oldDN;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= %s is an alias for %s\n",
|
||||
e->e_dn, a->a_vals[0]->bv_val, 0 );
|
||||
newDN = strdup (a->a_vals[0]->bv_val);
|
||||
oldDN = strdup (e->e_dn);
|
||||
|
||||
/*
|
||||
* ok, so what happens if there is an alias in the DN of a dereferenced
|
||||
* alias object?
|
||||
*/
|
||||
if ( (e = dn2entry_r( be, newDN, &matched )) == NULL ) {
|
||||
|
||||
/* could not deref return error */
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"<= %s is a dangling alias to %s\n",
|
||||
oldDN, newDN, 0 );
|
||||
send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, "",
|
||||
"Dangling Alias" );
|
||||
|
||||
if(matched != NULL) free(matched);
|
||||
}
|
||||
free (newDN);
|
||||
free (oldDN);
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* there was an aliasedobjectname defined but no data.
|
||||
* this can't happen, right?
|
||||
*/
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"<= %s has no data in aliasedobjectname attribute\n",
|
||||
e->e_dn, 0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, "",
|
||||
"Alias missing aliasedobjectname" );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* warn if we pulled out due to exceeding the maximum deref depth
|
||||
*/
|
||||
if ( depth >= be->be_maxDerefDepth ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"<= %s exceeded maximum deref depth %d\n",
|
||||
e->e_dn, be->be_maxDerefDepth, 0 );
|
||||
send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, "",
|
||||
"Maximum alias dereference depth exceeded" );
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/*
|
||||
* given a DN fully deref it and return the real DN or original DN if it fails
|
||||
*/
|
||||
char *derefDN ( Backend *be,
|
||||
Connection *conn,
|
||||
Operation *op,
|
||||
char *dn
|
||||
)
|
||||
{
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
char *matched;
|
||||
char *newDN;
|
||||
int depth;
|
||||
Entry *eMatched;
|
||||
Entry *eDeref;
|
||||
Entry *eNew;
|
||||
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"<= dereferencing dn %s\n",
|
||||
dn, 0, 0 );
|
||||
|
||||
newDN = strdup ( dn );
|
||||
|
||||
/* while we don't have a matched dn, deref the DN */
|
||||
for ( depth = 0;
|
||||
( (eMatched = dn2entry_r( be, newDN, &matched )) == NULL) &&
|
||||
(depth < be->be_maxDerefDepth);
|
||||
++depth ) {
|
||||
|
||||
/* free reader lock */
|
||||
cache_return_entry_r(&li->li_cache, eMatched);
|
||||
|
||||
if (*matched) {
|
||||
char *submatch;
|
||||
|
||||
/*
|
||||
* make sure there actually is an entry for the matched part
|
||||
*/
|
||||
if ( (eMatched = dn2entry_r( be, matched, &submatch )) != NULL) {
|
||||
char *remainder; /* part before the aliased part */
|
||||
int rlen = strlen(newDN) - strlen(matched);
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= matched %s\n", matched, 0, 0 );
|
||||
|
||||
remainder = ch_malloc (rlen + 1);
|
||||
strncpy ( remainder, newDN, rlen );
|
||||
remainder[rlen] = '\0';
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= remainder %s\n", remainder, 0, 0 );
|
||||
|
||||
if ((eNew = derefAlias_r( be, conn, op, eMatched )) == NULL) {
|
||||
free (matched);
|
||||
free (newDN);
|
||||
free (remainder);
|
||||
break; /* no associated entry, dont deref */
|
||||
}
|
||||
else {
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= l&g we have %s vs %s \n", matched, eNew->e_dn, 0 );
|
||||
|
||||
if (!strcasecmp (matched, eNew->e_dn)) {
|
||||
/* newDN same as old so not an alias, no need to go further */
|
||||
free (newDN);
|
||||
free (matched);
|
||||
free (remainder);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* we have dereferenced the aliased part so put
|
||||
* the new dn together
|
||||
*/
|
||||
free (newDN);
|
||||
free (matched);
|
||||
|
||||
newDN = ch_malloc (strlen(eMatched->e_dn) + rlen + 1);
|
||||
strcpy (newDN, remainder);
|
||||
strcat (newDN, eMatched->e_dn);
|
||||
Debug( LDAP_DEBUG_TRACE, "<= expanded to %s\n", newDN, 0, 0 );
|
||||
|
||||
free (remainder);
|
||||
|
||||
/* free reader lock */
|
||||
cache_return_entry_r(&li->li_cache, eNew);
|
||||
}
|
||||
/* free reader lock */
|
||||
cache_return_entry_r(&li->li_cache, eMatched);
|
||||
}
|
||||
else {
|
||||
if(submatch != NULL) free(submatch);
|
||||
break; /* there was no entry for the matched part */
|
||||
}
|
||||
}
|
||||
else {
|
||||
break; /* there was no matched part */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* the final part of the DN might be an alias
|
||||
* so try to dereference it.
|
||||
*/
|
||||
if ( (eNew = dn2entry_r( be, newDN, &matched )) != NULL) {
|
||||
if ((eDeref = derefAlias_r( be, conn, op, eNew )) != NULL) {
|
||||
free (newDN);
|
||||
newDN = strdup (eDeref->e_dn);
|
||||
/* free reader lock */
|
||||
cache_return_entry_r(&li->li_cache, eDeref);
|
||||
}
|
||||
/* free reader lock */
|
||||
cache_return_entry_r(&li->li_cache, eNew);
|
||||
}
|
||||
|
||||
/*
|
||||
* warn if we exceeded the max depth as the resulting DN may not be dereferenced
|
||||
*/
|
||||
if (depth >= be->be_maxDerefDepth) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"<= max deref depth exceeded in derefDN for %s, result %s\n",
|
||||
dn, newDN, 0 );
|
||||
send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, "",
|
||||
"Maximum alias dereference depth exceeded for base" );
|
||||
}
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= returning deref DN of %s\n", newDN, 0, 0 );
|
||||
|
||||
free(matched);
|
||||
|
||||
return newDN;
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
/* cache.c - routines to maintain an in-core cache of entries */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
#include "slap.h"
|
||||
|
||||
#include "back-ldbm.h"
|
||||
|
||||
static int cache_delete_entry_internal();
|
||||
|
|
@ -52,7 +55,7 @@ cache_set_state( struct cache *cache, Entry *e, int state )
|
|||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cache_return_entry( struct cache *cache, Entry *e )
|
||||
{
|
||||
/* set cache mutex */
|
||||
|
|
@ -66,6 +69,28 @@ cache_return_entry( struct cache *cache, Entry *e )
|
|||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
}
|
||||
|
||||
static void
|
||||
cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
|
||||
{
|
||||
Debug( LDAP_DEBUG_TRACE, "====> cache_return_entry_%s\n",
|
||||
rw ? "w" : "r", 0, 0);
|
||||
entry_rdwr_unlock(e, rw);;
|
||||
cache_return_entry(cache, e);
|
||||
}
|
||||
|
||||
void
|
||||
cache_return_entry_r( struct cache *cache, Entry *e )
|
||||
{
|
||||
cache_return_entry_rw(cache, e, 0);
|
||||
}
|
||||
|
||||
void
|
||||
cache_return_entry_w( struct cache *cache, Entry *e )
|
||||
{
|
||||
cache_return_entry_rw(cache, e, 1);
|
||||
}
|
||||
|
||||
|
||||
#define LRU_DELETE( cache, e ) { \
|
||||
if ( e->e_lruprev != NULL ) { \
|
||||
e->e_lruprev->e_lrunext = e->e_lrunext; \
|
||||
|
|
@ -110,11 +135,12 @@ cache_add_entry_lock(
|
|||
/* set cache mutex */
|
||||
pthread_mutex_lock( &cache->c_mutex );
|
||||
|
||||
if ( avl_insert( &cache->c_dntree, e, cache_entrydn_cmp, avl_dup_error )
|
||||
!= 0 ) {
|
||||
if ( avl_insert( &cache->c_dntree, (caddr_t) e,
|
||||
cache_entrydn_cmp, avl_dup_error ) != 0 )
|
||||
{
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"entry %20s id %d already in dn cache\n", e->e_dn,
|
||||
e->e_id, 0 );
|
||||
"====> cache_add_entry lock: entry %20s id %d already in dn cache\n",
|
||||
e->e_dn, e->e_id, 0 );
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
|
@ -122,15 +148,18 @@ cache_add_entry_lock(
|
|||
}
|
||||
|
||||
/* id tree */
|
||||
if ( avl_insert( &cache->c_idtree, e, cache_entryid_cmp, avl_dup_error )
|
||||
!= 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "entry %20s id %d already in id cache\n",
|
||||
if ( avl_insert( &cache->c_idtree, (caddr_t) e,
|
||||
cache_entryid_cmp, avl_dup_error ) != 0 )
|
||||
{
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"====> entry %20s id %d already in id cache\n",
|
||||
e->e_dn, e->e_id, 0 );
|
||||
|
||||
/* delete from dn tree inserted above */
|
||||
if ( avl_delete( &cache->c_dntree, e, cache_entrydn_cmp )
|
||||
== NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "can't delete from dn cache\n",
|
||||
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
|
||||
cache_entrydn_cmp ) == NULL )
|
||||
{
|
||||
Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
|
||||
0, 0, 0 );
|
||||
}
|
||||
|
||||
|
|
@ -168,6 +197,11 @@ cache_add_entry_lock(
|
|||
== 0 && cache->c_cursize > cache->c_maxsize ) {
|
||||
e = cache->c_lrutail;
|
||||
|
||||
/* XXX check for writer lock - should also check no readers pending */
|
||||
#ifdef LDAP_DEBUG
|
||||
assert(pthread_rdwr_wchk_np(&e->e_rdwr));
|
||||
#endif
|
||||
|
||||
/* delete from cache and lru q */
|
||||
rc = cache_delete_entry_internal( cache, e );
|
||||
|
||||
|
|
@ -181,44 +215,85 @@ cache_add_entry_lock(
|
|||
}
|
||||
|
||||
/*
|
||||
* cache_find_entry_dn - find an entry in the cache, given dn
|
||||
* cache_find_entry_dn2id - find an entry in the cache, given dn
|
||||
*/
|
||||
|
||||
Entry *
|
||||
cache_find_entry_dn(
|
||||
ID
|
||||
cache_find_entry_dn2id(
|
||||
Backend *be,
|
||||
struct cache *cache,
|
||||
char *dn
|
||||
)
|
||||
{
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
Entry e, *ep;
|
||||
ID id;
|
||||
|
||||
/* set cache mutex */
|
||||
pthread_mutex_lock( &cache->c_mutex );
|
||||
|
||||
e.e_dn = dn;
|
||||
if ( (ep = (Entry *) avl_find( cache->c_dntree, &e, cache_entrydn_cmp ))
|
||||
!= NULL ) {
|
||||
|
||||
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
|
||||
cache_entrydn_cmp )) != NULL )
|
||||
{
|
||||
Debug(LDAP_DEBUG_TRACE, "====> cache_find_entry_dn2id: found dn: %s\n",
|
||||
dn, 0, 0);
|
||||
|
||||
/*
|
||||
* entry is deleted or not fully created yet
|
||||
*/
|
||||
if ( ep->e_state == ENTRY_STATE_DELETED ||
|
||||
ep->e_state == ENTRY_STATE_CREATING )
|
||||
ep->e_state == ENTRY_STATE_CREATING )
|
||||
{
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
return( NULL );
|
||||
return( NOID );
|
||||
}
|
||||
|
||||
/* XXX is this safe without writer lock? */
|
||||
ep->e_refcnt++;
|
||||
|
||||
/* lru */
|
||||
LRU_DELETE( cache, ep );
|
||||
LRU_ADD( cache, ep );
|
||||
|
||||
/* acquire reader lock */
|
||||
entry_rdwr_lock(ep, 0);
|
||||
|
||||
/* re-check */
|
||||
if ( ep->e_state == ENTRY_STATE_DELETED ||
|
||||
ep->e_state == ENTRY_STATE_CREATING )
|
||||
{
|
||||
/* XXX check that is is required */
|
||||
ep->e_refcnt--;
|
||||
|
||||
/* free reader lock */
|
||||
entry_rdwr_unlock(ep, 0);
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
return( NOID );
|
||||
}
|
||||
|
||||
/* save id */
|
||||
id = ep->e_id;
|
||||
|
||||
/* free reader lock */
|
||||
entry_rdwr_unlock(ep, 0);
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
cache_return_entry( &li->li_cache, ep );
|
||||
|
||||
return( id );
|
||||
}
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
return( ep );
|
||||
return( NOID );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -227,8 +302,9 @@ cache_find_entry_dn(
|
|||
|
||||
Entry *
|
||||
cache_find_entry_id(
|
||||
struct cache *cache,
|
||||
ID id
|
||||
struct cache *cache,
|
||||
ID id,
|
||||
int rw
|
||||
)
|
||||
{
|
||||
Entry e;
|
||||
|
|
@ -238,29 +314,64 @@ cache_find_entry_id(
|
|||
pthread_mutex_lock( &cache->c_mutex );
|
||||
|
||||
e.e_id = id;
|
||||
if ( (ep = (Entry *) avl_find( cache->c_idtree, &e, cache_entryid_cmp ))
|
||||
!= NULL ) {
|
||||
|
||||
if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
|
||||
cache_entryid_cmp )) != NULL )
|
||||
{
|
||||
Debug(LDAP_DEBUG_TRACE,
|
||||
"====> cache_find_entry_dn2id: found id: %ld rw: %d\n",
|
||||
id, rw, 0);
|
||||
|
||||
/*
|
||||
* entry is deleted or not fully created yet
|
||||
*/
|
||||
if ( ep->e_state == ENTRY_STATE_DELETED ||
|
||||
ep->e_state == ENTRY_STATE_CREATING )
|
||||
ep->e_state == ENTRY_STATE_CREATING )
|
||||
{
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
return( NULL );
|
||||
}
|
||||
/* XXX is this safe without writer lock? */
|
||||
ep->e_refcnt++;
|
||||
|
||||
/* lru */
|
||||
LRU_DELETE( cache, ep );
|
||||
LRU_ADD( cache, ep );
|
||||
|
||||
/* acquire reader lock */
|
||||
entry_rdwr_lock(ep, 0);
|
||||
|
||||
/* re-check */
|
||||
if ( ep->e_state == ENTRY_STATE_DELETED ||
|
||||
ep->e_state == ENTRY_STATE_CREATING ) {
|
||||
|
||||
/* XXX check that is is required */
|
||||
ep->e_refcnt--;
|
||||
|
||||
/* free reader lock */
|
||||
entry_rdwr_unlock(ep, 0);
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if ( rw ) {
|
||||
entry_rdwr_unlock(ep, 0);
|
||||
entry_rdwr_lock(ep, 1);
|
||||
}
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
return( ep );
|
||||
}
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
return( ep );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -282,6 +393,13 @@ cache_delete_entry(
|
|||
{
|
||||
int rc;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "====> cache_delete_entry:\n", 0, 0, 0 );
|
||||
|
||||
/* XXX check for writer lock - should also check no readers pending */
|
||||
#ifdef LDAP_DEBUG
|
||||
assert(pthread_rdwr_wchk_np(&e->e_rdwr));
|
||||
#endif
|
||||
|
||||
/* set cache mutex */
|
||||
pthread_mutex_lock( &cache->c_mutex );
|
||||
|
||||
|
|
@ -299,12 +417,16 @@ cache_delete_entry_internal(
|
|||
)
|
||||
{
|
||||
/* dn tree */
|
||||
if ( avl_delete( &cache->c_dntree, e, cache_entrydn_cmp ) == NULL ) {
|
||||
if ( avl_delete( &cache->c_dntree, (caddr_t) e, cache_entrydn_cmp )
|
||||
== NULL )
|
||||
{
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* id tree */
|
||||
if ( avl_delete( &cache->c_idtree, e, cache_entryid_cmp ) == NULL ) {
|
||||
if ( avl_delete( &cache->c_idtree, (caddr_t) e, cache_entryid_cmp )
|
||||
== NULL )
|
||||
{
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
|
@ -340,3 +462,4 @@ lru_print( struct cache *cache )
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
/* compare.c - ldbm backend compare routine */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
|
||||
int
|
||||
|
|
@ -23,33 +26,36 @@ ldbm_back_compare(
|
|||
char *matched;
|
||||
Entry *e;
|
||||
Attribute *a;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
|
||||
/* get entry with reader lock */
|
||||
if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* check for deleted */
|
||||
if ( ! access_allowed( be, conn, op, e, ava->ava_type, &ava->ava_value,
|
||||
op->o_dn, ACL_COMPARE ) ) {
|
||||
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) {
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 ) {
|
||||
if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 )
|
||||
send_ldap_result( conn, op, LDAP_COMPARE_TRUE, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 0 );
|
||||
}
|
||||
else
|
||||
send_ldap_result( conn, op, LDAP_COMPARE_FALSE, "", "" );
|
||||
|
||||
send_ldap_result( conn, op, LDAP_COMPARE_FALSE, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 0 );
|
||||
rc = 0;
|
||||
|
||||
return_results:;
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
return( rc );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
/* id2children.c - routines to deal with the id2children index */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
|
||||
|
|
@ -18,11 +21,17 @@ id2children_add(
|
|||
)
|
||||
{
|
||||
struct dbcache *db;
|
||||
Datum key, data;
|
||||
Datum key;
|
||||
int len, rc;
|
||||
IDList *idl;
|
||||
char buf[20];
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
Datum data;
|
||||
memset( &key, 0, sizeof( key ) );
|
||||
memset( &data, 0, sizeof( data ) );
|
||||
#endif
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %d, %d )\n", p ? p->e_id
|
||||
: 0, e->e_id, 0 );
|
||||
|
||||
|
|
@ -34,7 +43,7 @@ id2children_add(
|
|||
return( -1 );
|
||||
}
|
||||
|
||||
sprintf( buf, "%c%d", EQ_PREFIX, p ? p->e_id : 0 );
|
||||
sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
|
||||
key.dptr = buf;
|
||||
key.dsize = strlen( buf ) + 1;
|
||||
|
||||
|
|
@ -63,6 +72,10 @@ has_children(
|
|||
IDList *idl;
|
||||
char buf[20];
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &key, 0, sizeof( key ) );
|
||||
#endif
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> has_children( %d )\n", p->e_id , 0, 0 );
|
||||
|
||||
if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
|
||||
|
|
@ -73,7 +86,7 @@ has_children(
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
sprintf( buf, "%c%d", EQ_PREFIX, p->e_id );
|
||||
sprintf( buf, "%c%ld", EQ_PREFIX, p->e_id );
|
||||
key.dptr = buf;
|
||||
key.dsize = strlen( buf ) + 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
/* id2entry.c - routines to deal with the id2entry index */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
|
||||
|
|
@ -10,7 +13,6 @@ extern struct dbcache *ldbm_cache_open();
|
|||
extern Datum ldbm_cache_fetch();
|
||||
extern char *dn_parent();
|
||||
extern Entry *str2entry();
|
||||
extern Entry *cache_find_entry_id();
|
||||
extern char *entry2str();
|
||||
extern pthread_mutex_t entry2str_mutex;
|
||||
|
||||
|
|
@ -20,7 +22,12 @@ id2entry_add( Backend *be, Entry *e )
|
|||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
struct dbcache *db;
|
||||
Datum key, data;
|
||||
int len, rc;
|
||||
int len, rc, flags;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &key, 0, sizeof( key ) );
|
||||
memset( &data, 0, sizeof( data ) );
|
||||
#endif
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %d, \"%s\" )\n", e->e_id,
|
||||
e->e_dn, 0 );
|
||||
|
|
@ -39,8 +46,10 @@ id2entry_add( Backend *be, Entry *e )
|
|||
data.dptr = entry2str( e, &len, 1 );
|
||||
data.dsize = len + 1;
|
||||
|
||||
/* store it - LDBM_SYNC ensures id2entry is always consistent */
|
||||
rc = ldbm_cache_store( db, key, data, LDBM_REPLACE|LDBM_SYNC );
|
||||
/* store it */
|
||||
flags = LDBM_REPLACE;
|
||||
if ( li->li_flush_wrt ) flags |= LDBM_SYNC;
|
||||
rc = ldbm_cache_store( db, key, data, flags );
|
||||
|
||||
pthread_mutex_unlock( &entry2str_mutex );
|
||||
|
||||
|
|
@ -48,6 +57,8 @@ id2entry_add( Backend *be, Entry *e )
|
|||
(void) cache_add_entry_lock( &li->li_cache, e, 0 );
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_add %d\n", rc, 0, 0 );
|
||||
|
||||
/* XXX should entries be born locked, i.e. apply writer lock here? */
|
||||
return( rc );
|
||||
}
|
||||
|
||||
|
|
@ -62,8 +73,22 @@ id2entry_delete( Backend *be, Entry *e )
|
|||
Debug( LDAP_DEBUG_TRACE, "=> id2entry_delete( %d, \"%s\" )\n", e->e_id,
|
||||
e->e_dn, 0 );
|
||||
|
||||
/* XXX - check for writer lock - should also check no reader pending */
|
||||
#ifdef LDAP_DEBUG
|
||||
assert(pthread_rdwr_wchk_np(&e->e_rdwr));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &key, 0, sizeof( key ) );
|
||||
#endif
|
||||
|
||||
/* XXX - check for writer lock - should also check no reader pending */
|
||||
Debug (LDAP_DEBUG_TRACE,
|
||||
"rdwr_Xchk: readers_reading: %d writer_writing: %d\n",
|
||||
e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0);
|
||||
|
||||
if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT ))
|
||||
== NULL ) {
|
||||
== NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "Could not open/create id2entry%s\n",
|
||||
LDBM_SUFFIX, 0, 0 );
|
||||
return( -1 );
|
||||
|
|
@ -85,24 +110,31 @@ id2entry_delete( Backend *be, Entry *e )
|
|||
return( rc );
|
||||
}
|
||||
|
||||
/* XXX returns entry with reader/writer lock */
|
||||
Entry *
|
||||
id2entry( Backend *be, ID id )
|
||||
id2entry( Backend *be, ID id, int rw )
|
||||
{
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
struct dbcache *db;
|
||||
Datum key, data;
|
||||
Entry *e;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> id2entry( %ld )\n", id, 0, 0 );
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &key, 0, sizeof( key ) );
|
||||
memset( &data, 0, sizeof( data ) );
|
||||
#endif
|
||||
|
||||
if ( (e = cache_find_entry_id( &li->li_cache, id )) != NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry 0x%x (cache)\n", e, 0,
|
||||
0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> id2entry_%s( %ld )\n",
|
||||
rw ? "w" : "r", id, 0 );
|
||||
|
||||
if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s 0x%x (cache)\n",
|
||||
rw ? "w" : "r", e, 0 );
|
||||
return( e );
|
||||
}
|
||||
|
||||
if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT ))
|
||||
== NULL ) {
|
||||
== NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "Could not open id2entry%s\n",
|
||||
LDBM_SUFFIX, 0, 0 );
|
||||
return( NULL );
|
||||
|
|
@ -114,20 +146,47 @@ id2entry( Backend *be, ID id )
|
|||
data = ldbm_cache_fetch( db, key );
|
||||
|
||||
if ( data.dptr == NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry( %ld ) not found\n", id,
|
||||
0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) not found\n",
|
||||
rw ? "w" : "r", id, 0 );
|
||||
ldbm_cache_close( be, db );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if ( (e = str2entry( data.dptr )) != NULL ) {
|
||||
e->e_id = id;
|
||||
(void) cache_add_entry_lock( &li->li_cache, e, 0 );
|
||||
}
|
||||
e = str2entry( data.dptr );
|
||||
|
||||
ldbm_datum_free( db->dbc_db, data );
|
||||
ldbm_cache_close( be, db );
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry( %ld ) 0x%x (disk)\n", id, e, 0 );
|
||||
if ( e == NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (failed)\n",
|
||||
rw ? "w" : "r", id, 0 );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* acquire required reader/writer lock */
|
||||
if (entry_rdwr_lock(e, rw)) {
|
||||
/* XXX set DELETE flag?? */
|
||||
entry_free(e);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
e->e_id = id;
|
||||
(void) cache_add_entry_lock( &li->li_cache, e, 0 );
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (disk)\n",
|
||||
rw ? "w" : "r", id, 0 );
|
||||
return( e );
|
||||
}
|
||||
|
||||
Entry *
|
||||
id2entry_r( Backend *be, ID id )
|
||||
{
|
||||
return( id2entry( be, id, 0 ) );
|
||||
}
|
||||
|
||||
Entry *
|
||||
id2entry_2( Backend *be, ID id )
|
||||
{
|
||||
return( id2entry( be, id, 1 ) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
/* idl.c - ldap id list handling routines */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/string.h>
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "ldapconfig.h"
|
||||
#include "back-ldbm.h"
|
||||
|
|
@ -51,11 +55,14 @@ idl_fetch_one(
|
|||
Datum key
|
||||
)
|
||||
{
|
||||
Datum data, k2;
|
||||
Datum data;
|
||||
IDList *idl;
|
||||
IDList **tmp;
|
||||
char *kstr;
|
||||
int i, nids;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
Datum k2;
|
||||
memset( &k2, 0, sizeof( k2 ) );
|
||||
memset( &data, 0, sizeof( data ) );
|
||||
#endif
|
||||
|
||||
/* Debug( LDAP_DEBUG_TRACE, "=> idl_fetch_one\n", 0, 0, 0 ); */
|
||||
|
||||
|
|
@ -79,6 +86,11 @@ idl_fetch(
|
|||
char *kstr;
|
||||
int i, nids;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &k2, 0, sizeof( k2 ) );
|
||||
memset( &data, 0, sizeof( data ) );
|
||||
#endif
|
||||
|
||||
/* Debug( LDAP_DEBUG_TRACE, "=> idl_fetch\n", 0, 0, 0 ); */
|
||||
|
||||
data = ldbm_cache_fetch( db, key );
|
||||
|
|
@ -117,7 +129,7 @@ idl_fetch(
|
|||
kstr = (char *) ch_malloc( key.dsize + 20 );
|
||||
nids = 0;
|
||||
for ( i = 0; idl->b_ids[i] != NOID; i++ ) {
|
||||
sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr, idl->b_ids[i] );
|
||||
sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, idl->b_ids[i] );
|
||||
k2.dptr = kstr;
|
||||
k2.dsize = strlen( kstr ) + 1;
|
||||
|
||||
|
|
@ -164,15 +176,27 @@ idl_store(
|
|||
IDList *idl
|
||||
)
|
||||
{
|
||||
int rc;
|
||||
int rc, flags;
|
||||
Datum data;
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &data, 0, sizeof( data ) );
|
||||
#endif
|
||||
|
||||
/* Debug( LDAP_DEBUG_TRACE, "=> idl_store\n", 0, 0, 0 ); */
|
||||
|
||||
data.dptr = (char *) idl;
|
||||
data.dsize = (2 + idl->b_nmax) * sizeof(ID);
|
||||
|
||||
#ifdef LDBM_DEBUG
|
||||
Statslog( LDAP_DEBUG_STATS, "<= idl_store(): rc=%d\n",
|
||||
rc, 0, 0, 0, 0 );
|
||||
#endif
|
||||
|
||||
rc = ldbm_cache_store( db, key, data, LDBM_REPLACE );
|
||||
flags = LDBM_REPLACE;
|
||||
if( li->li_flush_wrt ) flags |= LDBM_SYNC;
|
||||
rc = ldbm_cache_store( db, key, data, flags );
|
||||
|
||||
/* Debug( LDAP_DEBUG_TRACE, "<= idl_store %d\n", rc, 0, 0 ); */
|
||||
return( rc );
|
||||
|
|
@ -186,7 +210,7 @@ idl_split_block(
|
|||
IDList **n2
|
||||
)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/* find where to split the block */
|
||||
for ( i = 0; i < b->b_nids && id > b->b_ids[i]; i++ )
|
||||
|
|
@ -246,7 +270,7 @@ idl_change_first(
|
|||
}
|
||||
|
||||
/* write block with new key */
|
||||
sprintf( bkey.dptr, "%c%s%d", CONT_PREFIX, hkey.dptr, b->b_ids[0] );
|
||||
sprintf( bkey.dptr, "%c%s%ld", CONT_PREFIX, hkey.dptr, b->b_ids[0] );
|
||||
bkey.dsize = strlen( bkey.dptr ) + 1;
|
||||
if ( (rc = idl_store( be, db, bkey, b )) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
|
|
@ -278,7 +302,16 @@ idl_insert_key(
|
|||
char *kstr;
|
||||
Datum k2;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &k2, 0, sizeof( k2 ) );
|
||||
#endif
|
||||
|
||||
if ( (idl = idl_fetch_one( be, db, key )) == NULL ) {
|
||||
#ifdef LDBM_DEBUG
|
||||
Statslog( LDAP_DEBUG_STATS, "=> idl_insert_key(): no key yet\n",
|
||||
0, 0, 0, 0, 0 );
|
||||
#endif
|
||||
|
||||
idl = idl_alloc( 1 );
|
||||
idl->b_ids[idl->b_nids++] = id;
|
||||
rc = idl_store( be, db, key, idl );
|
||||
|
|
@ -326,14 +359,14 @@ idl_insert_key(
|
|||
|
||||
/* store the first id block */
|
||||
kstr = (char *) ch_malloc( key.dsize + 20 );
|
||||
sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr,
|
||||
sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
|
||||
tmp->b_ids[0] );
|
||||
k2.dptr = kstr;
|
||||
k2.dsize = strlen( kstr ) + 1;
|
||||
rc = idl_store( be, db, k2, tmp );
|
||||
|
||||
/* store the second id block */
|
||||
sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr,
|
||||
sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
|
||||
tmp2->b_ids[0] );
|
||||
k2.dptr = kstr;
|
||||
k2.dsize = strlen( kstr ) + 1;
|
||||
|
|
@ -369,7 +402,7 @@ idl_insert_key(
|
|||
|
||||
/* get the block */
|
||||
kstr = (char *) ch_malloc( key.dsize + 20 );
|
||||
sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr, idl->b_ids[i] );
|
||||
sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, idl->b_ids[i] );
|
||||
k2.dptr = kstr;
|
||||
k2.dsize = strlen( kstr ) + 1;
|
||||
if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) {
|
||||
|
|
@ -411,7 +444,7 @@ idl_insert_key(
|
|||
/* is there a next block? */
|
||||
if ( !first && idl->b_ids[i + 1] != NOID ) {
|
||||
/* read it in */
|
||||
sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr,
|
||||
sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
|
||||
idl->b_ids[i + 1] );
|
||||
k2.dptr = kstr;
|
||||
k2.dsize = strlen( kstr ) + 1;
|
||||
|
|
@ -470,7 +503,7 @@ idl_insert_key(
|
|||
|
||||
/* delete all indirect blocks */
|
||||
for ( j = 0; idl->b_ids[j] != NOID; j++ ) {
|
||||
sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr,
|
||||
sprintf( kstr,"%c%s%ld", CONT_PREFIX, key.dptr,
|
||||
idl->b_ids[j] );
|
||||
k2.dptr = kstr;
|
||||
k2.dsize = strlen( kstr ) + 1;
|
||||
|
|
@ -509,14 +542,14 @@ idl_insert_key(
|
|||
rc = idl_store( be, db, key, tmp );
|
||||
|
||||
/* store the first id block */
|
||||
sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr,
|
||||
sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
|
||||
tmp2->b_ids[0] );
|
||||
k2.dptr = kstr;
|
||||
k2.dsize = strlen( kstr ) + 1;
|
||||
rc = idl_store( be, db, k2, tmp2 );
|
||||
|
||||
/* store the second id block */
|
||||
sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr,
|
||||
sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
|
||||
tmp3->b_ids[0] );
|
||||
k2.dptr = kstr;
|
||||
k2.dsize = strlen( kstr ) + 1;
|
||||
|
|
@ -544,7 +577,7 @@ idl_insert_key(
|
|||
int
|
||||
idl_insert( IDList **idl, ID id, int maxids )
|
||||
{
|
||||
int i, j;
|
||||
unsigned int i, j;
|
||||
|
||||
if ( ALLIDS( *idl ) ) {
|
||||
return( 2 ); /* already there */
|
||||
|
|
@ -618,8 +651,8 @@ idl_intersection(
|
|||
IDList *b
|
||||
)
|
||||
{
|
||||
int ai, bi, ni;
|
||||
IDList *n;
|
||||
unsigned int ai, bi, ni;
|
||||
IDList *n;
|
||||
|
||||
if ( a == NULL || b == NULL ) {
|
||||
return( NULL );
|
||||
|
|
@ -666,8 +699,8 @@ idl_union(
|
|||
IDList *b
|
||||
)
|
||||
{
|
||||
int ai, bi, ni;
|
||||
IDList *n;
|
||||
unsigned int ai, bi, ni;
|
||||
IDList *n;
|
||||
|
||||
if ( a == NULL ) {
|
||||
return( idl_dup( b ) );
|
||||
|
|
@ -720,18 +753,15 @@ idl_notin(
|
|||
IDList *b
|
||||
)
|
||||
{
|
||||
int ni, ai, bi;
|
||||
IDList *n;
|
||||
unsigned int ni, ai, bi;
|
||||
IDList *n;
|
||||
|
||||
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 );
|
||||
|
|
@ -802,7 +832,7 @@ idl_firstid( IDList *idl )
|
|||
ID
|
||||
idl_nextid( IDList *idl, ID id )
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
if ( ALLIDS( idl ) ) {
|
||||
return( ++id < idl->b_nids ? id : NOID );
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
/* index.c - routines for dealing with attribute indexes */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/string.h>
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
|
||||
|
|
@ -105,6 +108,10 @@ index_read(
|
|||
char *realval, *tmpval;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &key, 0, sizeof( key ) );
|
||||
#endif
|
||||
|
||||
prefix = index2prefix( indextype );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> index_read( \"%s\" \"%c\" \"%s\" )\n",
|
||||
type, prefix, val );
|
||||
|
|
@ -130,25 +137,26 @@ index_read(
|
|||
realval = val;
|
||||
tmpval = NULL;
|
||||
if ( prefix != '\0' ) {
|
||||
int len;
|
||||
unsigned 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 );
|
||||
|
||||
|
|
@ -174,6 +182,10 @@ add_value(
|
|||
char *realval, *tmpval, *s;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB2
|
||||
memset( &key, 0, sizeof( key ) );
|
||||
#endif
|
||||
|
||||
prefix = index2prefix( indextype );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> add_value( \"%c%s\" )\n", prefix, val, 0 );
|
||||
|
||||
|
|
@ -181,19 +193,17 @@ add_value(
|
|||
tmpval = NULL;
|
||||
idl = NULL;
|
||||
if ( prefix != '\0' ) {
|
||||
int len;
|
||||
unsigned 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;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
/* modify.c - ldbm backend modify routine */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/string.h>
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern int global_schemacheck;
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
|
||||
static int add_values();
|
||||
|
|
@ -27,10 +30,12 @@ ldbm_back_modify(
|
|||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
char *matched = NULL;
|
||||
Entry *e;
|
||||
int i, err, modtype;
|
||||
int i, err;
|
||||
LDAPMod *mod;
|
||||
|
||||
if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
|
||||
Debug(LDAP_DEBUG_ARGS, "ldbm_back_modify:\n", 0, 0, 0);
|
||||
|
||||
if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched,
|
||||
NULL );
|
||||
if ( matched != NULL ) {
|
||||
|
|
@ -38,12 +43,14 @@ ldbm_back_modify(
|
|||
}
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* check for deleted */
|
||||
|
||||
/* lock entry */
|
||||
|
||||
if ( (err = acl_check_mods( be, conn, op, e, mods )) != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, err, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
for ( mod = mods; mod != NULL; mod = mod->mod_next ) {
|
||||
|
|
@ -64,55 +71,52 @@ ldbm_back_modify(
|
|||
if ( err != LDAP_SUCCESS ) {
|
||||
/* unlock entry, delete from cache */
|
||||
send_ldap_result( conn, op, err, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
}
|
||||
|
||||
/* check that the entry still obeys the schema */
|
||||
if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "entry failed schema check\n", 0, 0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, NULL, NULL );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
/* check for abandon */
|
||||
pthread_mutex_lock( &op->o_abandonmutex );
|
||||
if ( op->o_abandon ) {
|
||||
pthread_mutex_unlock( &op->o_abandonmutex );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
pthread_mutex_unlock( &op->o_abandonmutex );
|
||||
|
||||
/* check that the entry still obeys the schema */
|
||||
if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, NULL,
|
||||
NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* modify indexes */
|
||||
if ( index_add_mods( be, mods, e->e_id ) != 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
/* check for abandon */
|
||||
pthread_mutex_lock( &op->o_abandonmutex );
|
||||
if ( op->o_abandon ) {
|
||||
pthread_mutex_unlock( &op->o_abandonmutex );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
pthread_mutex_unlock( &op->o_abandonmutex );
|
||||
|
||||
/* change the entry itself */
|
||||
if ( id2entry_add( be, e ) != 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
return( 0 );
|
||||
|
||||
error_return:;
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
/* entry.c - routines for dealing with entries */
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/ctype.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
|
||||
#include "slap.h"
|
||||
|
||||
void entry_free();
|
||||
|
|
@ -43,9 +46,12 @@ str2entry( char *s )
|
|||
* or newline.
|
||||
*/
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> str2entry\n", s, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> str2entry\n",
|
||||
s ? s : "NULL", 0, 0 );
|
||||
|
||||
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
|
||||
/* initialize reader/writer lock */
|
||||
entry_rdwr_init(e);
|
||||
|
||||
/* check to see if there's an id included */
|
||||
next = s;
|
||||
|
|
@ -112,6 +118,7 @@ str2entry( char *s )
|
|||
}
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= str2entry 0x%x\n", e, 0, 0 );
|
||||
|
||||
return( e );
|
||||
}
|
||||
|
||||
|
|
@ -187,6 +194,12 @@ entry_free( Entry *e )
|
|||
int i;
|
||||
Attribute *a, *next;
|
||||
|
||||
/* XXX check that no reader/writer locks exist */
|
||||
#ifdef LDAP_DEBUG
|
||||
assert( !pthread_rdwr_wchk_np(&e->e_rdwr) &&
|
||||
!pthread_rdwr_rchk_np(&e->e_rdwr) );
|
||||
#endif
|
||||
|
||||
if ( e->e_dn != NULL ) {
|
||||
free( e->e_dn );
|
||||
}
|
||||
|
|
@ -196,3 +209,56 @@ entry_free( Entry *e )
|
|||
}
|
||||
free( e );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_lock(Entry *e, int rw)
|
||||
{
|
||||
Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n",
|
||||
rw ? "w" : "r", e->e_id, 0);
|
||||
if (rw)
|
||||
return pthread_rdwr_wlock_np(&e->e_rdwr);
|
||||
else
|
||||
return pthread_rdwr_rlock_np(&e->e_rdwr);
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_rlock(Entry *e)
|
||||
{
|
||||
return entry_rdwr_lock( e, 0 );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_wlock(Entry *e)
|
||||
{
|
||||
return entry_rdwr_lock( e, 1 );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_unlock(Entry *e, int rw)
|
||||
{
|
||||
Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n",
|
||||
rw ? "w" : "r", e->e_id, 0);
|
||||
if (rw)
|
||||
return pthread_rdwr_wunlock_np(&e->e_rdwr);
|
||||
else
|
||||
return pthread_rdwr_runlock_np(&e->e_rdwr);
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_runlock(Entry *e)
|
||||
{
|
||||
return entry_rdwr_unlock( e, 0 );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_wunlock(Entry *e)
|
||||
{
|
||||
return entry_rdwr_unlock( e, 1 );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_init(Entry *e)
|
||||
{
|
||||
return pthread_rdwr_init_np(&e->e_rdwr, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "slap.h"
|
||||
#include "ldapconfig.h"
|
||||
#include "lutil.h" /* Get lutil_detach() */
|
||||
|
||||
extern void slapd_daemon();
|
||||
extern int lber_debug;
|
||||
|
|
@ -56,13 +57,14 @@ pthread_mutex_t num_sent_mutex;
|
|||
pthread_mutex_t entry2str_mutex;
|
||||
pthread_mutex_t replog_mutex;
|
||||
|
||||
static
|
||||
static void
|
||||
usage( name )
|
||||
char *name;
|
||||
{
|
||||
fprintf( stderr, "usage: %s [-d ?|debuglevel] [-f configfile] [-p portnumber] [-s sysloglevel]\n", name );
|
||||
}
|
||||
|
||||
int
|
||||
main( argc, argv )
|
||||
int argc;
|
||||
char **argv;
|
||||
|
|
@ -267,7 +269,7 @@ main( argc, argv )
|
|||
/* log and send error */
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"ber_get_int returns 0x%x\n", tag, 0, 0 );
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( (tag = ber_peek_tag( &ber, &len ))
|
||||
|
|
@ -278,7 +280,7 @@ main( argc, argv )
|
|||
ber_free( &ber, 1 );
|
||||
close( c.c_sb.sb_sd );
|
||||
c.c_sb.sb_sd = -1;
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
connection_activity( &c );
|
||||
|
|
@ -286,4 +288,5 @@ main( argc, argv )
|
|||
ber_free( &ber, 1 );
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
57
servers/slapd/suffixalias.c
Normal file
57
servers/slapd/suffixalias.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 1998 Will Ballantyne, ITSD, Government of BC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to ITSD, Government of BC. The name of ITSD
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ac/socket.h> /* Get struct sockaddr for slap.h */
|
||||
#include "slap.h"
|
||||
|
||||
/*
|
||||
* given a dn (or root part), return an aliased dn if any of the
|
||||
* alias suffixes match
|
||||
*/
|
||||
char *suffixAlias ( dn, op, be )
|
||||
char *dn;
|
||||
Operation *op;
|
||||
Backend *be;
|
||||
{
|
||||
int i, dnLength;
|
||||
|
||||
dnLength = strlen ( dn );
|
||||
op->o_suffix = NULL;
|
||||
op->o_suffixAliased = NULL;
|
||||
for ( i = 0;
|
||||
be->be_suffixAlias != NULL && be->be_suffixAlias[i] != NULL;
|
||||
i += 2) {
|
||||
int aliasLength = strlen (be->be_suffixAlias[i]);
|
||||
if (aliasLength > dnLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcasecmp(be->be_suffixAlias[i],
|
||||
dn + (dnLength - aliasLength))) {
|
||||
char *oldDN = dn;
|
||||
op->o_suffixAliased = strdup ( be->be_suffixAlias[i] );
|
||||
dn = ch_malloc ( (dnLength - aliasLength) +
|
||||
strlen (be->be_suffixAlias[ i+1 ]) + 1);
|
||||
strncpy (dn, oldDN, dnLength - aliasLength);
|
||||
strcpy (dn + (dnLength - aliasLength), be->be_suffixAlias[ i+1 ]);
|
||||
op->o_suffix = strdup (dn);
|
||||
Debug( LDAP_DEBUG_ARGS, "ALIAS: converted %s to %s", oldDN, dn, 0);
|
||||
free (oldDN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return dn;
|
||||
}
|
||||
|
|
@ -14,8 +14,12 @@
|
|||
* args.c - process command-line arguments, and set appropriate globals.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
|
@ -24,16 +28,16 @@
|
|||
#include "globals.h"
|
||||
|
||||
|
||||
static int
|
||||
static void
|
||||
usage( char *name )
|
||||
{
|
||||
fprintf( stderr, "usage: %s\t[-d debug-level] [-s syslog-level]\n", name );
|
||||
fprintf( stderr, "\t\t[-f slapd-config-file] [-r replication-log-file]\n" );
|
||||
#ifdef KERBEROS
|
||||
#ifdef HAVE_KERBEROS
|
||||
fprintf( stderr, "\t\t[-t tmp-dir] [-o] [-k srvtab-file]\n" );
|
||||
#else /* KERBEROS */
|
||||
#else /* HAVE_KERBEROS */
|
||||
fprintf( stderr, "\t\t[-t tmp-dir] [-o]\n" );
|
||||
#endif /* KERBEROS */
|
||||
#endif /* HAVE_KERBEROS */
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -103,11 +107,11 @@ doargs(
|
|||
g->slurpd_rdir = strdup( optarg );
|
||||
break;
|
||||
case 'k': /* name of kerberos srvtab file */
|
||||
#ifdef KERBEROS
|
||||
#ifdef HAVE_KERBEROS
|
||||
g->default_srvtab = strdup( optarg );
|
||||
#else /* KERBEROS */
|
||||
#else /* HAVE_KERBEROS */
|
||||
fprintf( stderr, "must compile with KERBEROS to use -k option\n" );
|
||||
#endif /* KERBEROS */
|
||||
#endif /* HAVE_KERBEROS */
|
||||
break;
|
||||
case 'h':
|
||||
usage( g->myname );
|
||||
|
|
|
|||
|
|
@ -14,9 +14,12 @@
|
|||
* ch_malloc.c - malloc() and friends, with check for NULL return.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include "../slapd/slap.h"
|
||||
|
||||
|
||||
|
|
@ -33,7 +36,7 @@ ch_malloc(
|
|||
char *new;
|
||||
|
||||
if ( (new = (char *) malloc( size )) == NULL ) {
|
||||
fprintf( stderr, "malloc of %d bytes failed\n", size );
|
||||
fprintf( stderr, "malloc of %lu bytes failed\n", size );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +63,7 @@ ch_realloc(
|
|||
}
|
||||
|
||||
if ( (new = (char *) realloc( block, size )) == NULL ) {
|
||||
fprintf( stderr, "realloc of %d bytes failed\n", size );
|
||||
fprintf( stderr, "realloc of %lu bytes failed\n", size );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +86,7 @@ ch_calloc(
|
|||
char *new;
|
||||
|
||||
if ( (new = (char *) calloc( nelem, size )) == NULL ) {
|
||||
fprintf( stderr, "calloc of %d elems of %d bytes failed\n",
|
||||
fprintf( stderr, "calloc of %lu elems of %lu bytes failed\n",
|
||||
nelem, size );
|
||||
exit( 1 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,13 @@
|
|||
* config.c - configuration file handling routines
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/string.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/ctype.h>
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
|
@ -29,19 +32,11 @@
|
|||
#define MAXARGS 100
|
||||
|
||||
/* Forward declarations */
|
||||
#ifdef NEEDPROTOS
|
||||
static void add_replica( char **, int );
|
||||
static int parse_replica_line( char **, int, Ri *);
|
||||
static void parse_line( char *, int *, char ** );
|
||||
static char *getline( FILE * );
|
||||
static char *strtok_quote( char *, char * );
|
||||
#else /* NEEDPROTOS */
|
||||
static void add_replica();
|
||||
static int parse_replica_line();
|
||||
static void parse_line();
|
||||
static char *getline();
|
||||
static char *strtok_quote();
|
||||
#endif /* NEEDPROTOS */
|
||||
static void add_replica LDAP_P(( char **, int ));
|
||||
static int parse_replica_line LDAP_P(( char **, int, Ri *));
|
||||
static void parse_line LDAP_P(( char *, int *, char ** ));
|
||||
static char *getline LDAP_P(( FILE * ));
|
||||
static char *strtok_quote LDAP_P(( char *, char * ));
|
||||
|
||||
/* current config file line # */
|
||||
static int lineno;
|
||||
|
|
@ -59,8 +54,7 @@ slurpd_read_config(
|
|||
)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ];
|
||||
char *line, *p;
|
||||
char *line;
|
||||
int cargc;
|
||||
char *cargv[MAXARGS];
|
||||
|
||||
|
|
@ -233,7 +227,7 @@ getline(
|
|||
*p = '\0';
|
||||
}
|
||||
lineno++;
|
||||
if ( ! isspace( buf[0] ) ) {
|
||||
if ( ! isspace( (unsigned char) buf[0] ) ) {
|
||||
return( line );
|
||||
}
|
||||
|
||||
|
|
@ -357,13 +351,13 @@ parse_replica_line(
|
|||
strlen( BINDMETHSTR ))) {
|
||||
val = cargv[ i ] + strlen( BINDMETHSTR ) + 1;
|
||||
if ( !strcasecmp( val, KERBEROSSTR )) {
|
||||
#ifdef KERBEROS
|
||||
#ifdef HAVE_KERBEROS
|
||||
ri->ri_bind_method = AUTH_KERBEROS;
|
||||
if ( ri->ri_srvtab == NULL ) {
|
||||
ri->ri_srvtab = strdup( sglob->default_srvtab );
|
||||
}
|
||||
gots |= GOT_METHOD;
|
||||
#else /* KERBEROS */
|
||||
#else /* HAVE_KERBEROS */
|
||||
fprintf( stderr, "Error: a bind method of \"kerberos\" was\n" );
|
||||
fprintf( stderr, "specified in the slapd configuration file,\n" );
|
||||
fprintf( stderr, "but slurpd was not built with kerberos.\n" );
|
||||
|
|
@ -371,7 +365,7 @@ parse_replica_line(
|
|||
fprintf( stderr, "kerberos support if you wish to use\n" );
|
||||
fprintf( stderr, "bindmethod=kerberos\n" );
|
||||
exit( 1 );
|
||||
#endif /* KERBEROS */
|
||||
#endif /* HAVE_KERBEROS */
|
||||
} else if ( !strcasecmp( val, SIMPLESTR )) {
|
||||
ri->ri_bind_method = AUTH_SIMPLE;
|
||||
gots |= GOT_METHOD;
|
||||
|
|
|
|||
|
|
@ -14,45 +14,41 @@
|
|||
* ldap_op.c - routines to perform LDAP operations
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include "portable.h"
|
||||
|
||||
#ifdef KERBEROS
|
||||
#include <krb.h>
|
||||
#endif /* KERBEROS */
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ac/errno.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/ctype.h>
|
||||
#include <ac/time.h>
|
||||
|
||||
#include <ac/krb.h>
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
||||
#include "portable.h"
|
||||
#include "slurp.h"
|
||||
|
||||
/* Forward references */
|
||||
static int get_changetype( char * );
|
||||
static struct berval **make_singlevalued_berval( char *, int );
|
||||
static int op_ldap_add( Ri *, Re *, char ** );
|
||||
static int op_ldap_modify( Ri *, Re *, char ** );
|
||||
static int op_ldap_delete( Ri *, Re *, char ** );
|
||||
static int op_ldap_modrdn( Ri *, Re *, char ** );
|
||||
static LDAPMod *alloc_ldapmod();
|
||||
static void free_ldapmod( LDAPMod * );
|
||||
static void free_ldmarr( LDAPMod ** );
|
||||
static int getmodtype( char * );
|
||||
static void dump_ldm_array( LDAPMod ** );
|
||||
static char **read_krbnames( Ri * );
|
||||
static void upcase( char * );
|
||||
static int do_bind( Ri *, int * );
|
||||
static int do_unbind( Ri * );
|
||||
static struct berval **make_singlevalued_berval LDAP_P(( char *, int ));
|
||||
static int op_ldap_add LDAP_P(( Ri *, Re *, char ** ));
|
||||
static int op_ldap_modify LDAP_P(( Ri *, Re *, char ** ));
|
||||
static int op_ldap_delete LDAP_P(( Ri *, Re *, char ** ));
|
||||
static int op_ldap_modrdn LDAP_P(( Ri *, Re *, char ** ));
|
||||
static LDAPMod *alloc_ldapmod LDAP_P(());
|
||||
static void free_ldapmod LDAP_P(( LDAPMod * ));
|
||||
static void free_ldmarr LDAP_P(( LDAPMod ** ));
|
||||
static int getmodtype LDAP_P(( char * ));
|
||||
static void dump_ldm_array LDAP_P(( LDAPMod ** ));
|
||||
static char **read_krbnames LDAP_P(( Ri * ));
|
||||
static void upcase LDAP_P(( char * ));
|
||||
static int do_bind LDAP_P(( Ri *, int * ));
|
||||
static int do_unbind LDAP_P(( Ri * ));
|
||||
|
||||
|
||||
/* External references */
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
extern char *sys_errlist[];
|
||||
#endif /* SYSERRLIST_IN_STDIO */
|
||||
|
||||
extern char *ch_malloc( unsigned long );
|
||||
extern char *ch_malloc LDAP_P(( unsigned long ));
|
||||
|
||||
static char *kattrs[] = {"kerberosName", NULL };
|
||||
static struct timeval kst = {30L, 0L};
|
||||
|
|
@ -79,7 +75,6 @@ do_ldap(
|
|||
int rc = 0;
|
||||
int lderr = LDAP_SUCCESS;
|
||||
int retry = 2;
|
||||
char *msg;
|
||||
|
||||
*errmsg = NULL;
|
||||
|
||||
|
|
@ -226,7 +221,7 @@ op_ldap_modify(
|
|||
int state; /* This code is a simple-minded state machine */
|
||||
int nvals; /* Number of values we're modifying */
|
||||
int nops; /* Number of LDAPMod structs in ldmarr */
|
||||
LDAPMod *ldm, *nldm, **ldmarr;
|
||||
LDAPMod *ldm, **ldmarr;
|
||||
int i, len;
|
||||
char *type, *value;
|
||||
int rc = 0;
|
||||
|
|
@ -583,10 +578,9 @@ do_bind(
|
|||
int *lderr
|
||||
)
|
||||
{
|
||||
int rc;
|
||||
int ldrc;
|
||||
char msgbuf[ 1024];
|
||||
#ifdef KERBEROS
|
||||
#ifdef HAVE_KERBEROS
|
||||
int rc;
|
||||
int retval = 0;
|
||||
int kni, got_tgt;
|
||||
char **krbnames;
|
||||
|
|
@ -594,7 +588,7 @@ do_bind(
|
|||
char realm[ REALM_SZ ];
|
||||
char name[ ANAME_SZ ];
|
||||
char instance[ INST_SZ ];
|
||||
#endif /* KERBEROS */
|
||||
#endif /* HAVE_KERBEROS */
|
||||
|
||||
*lderr = 0;
|
||||
|
||||
|
|
@ -633,12 +627,12 @@ do_bind(
|
|||
|
||||
switch ( ri->ri_bind_method ) {
|
||||
case AUTH_KERBEROS:
|
||||
#ifndef KERBEROS
|
||||
#ifndef HAVE_KERBEROS
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"Error: Kerberos bind for %s:%d, but not compiled w/kerberos\n",
|
||||
ri->ri_hostname, ri->ri_port, 0 );
|
||||
return( BIND_ERR_KERBEROS_FAILED );
|
||||
#else /* KERBEROS */
|
||||
#else /* HAVE_KERBEROS */
|
||||
/*
|
||||
* Bind using kerberos.
|
||||
* If "bindprincipal" was given in the config file, then attempt
|
||||
|
|
@ -714,7 +708,7 @@ kexit: if ( krbnames != NULL ) {
|
|||
}
|
||||
return( retval);
|
||||
break;
|
||||
#endif /* KERBEROS */
|
||||
#endif /* HAVE_KERBEROS */
|
||||
case AUTH_SIMPLE:
|
||||
/*
|
||||
* Bind with a plaintext password.
|
||||
|
|
@ -771,7 +765,7 @@ LDAPMod **ldmarr )
|
|||
if ( ldm->mod_bvalues != NULL ) {
|
||||
for ( j = 0; ( b = ldm->mod_bvalues[ j ] ) != NULL; j++ ) {
|
||||
msgbuf = ch_malloc( b->bv_len + 512 );
|
||||
sprintf( msgbuf, "***** bv[ %d ] len = %d, val = <%s>",
|
||||
sprintf( msgbuf, "***** bv[ %d ] len = %ld, val = <%s>",
|
||||
j, b->bv_len, b->bv_val );
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"Trace (%d):%s\n", getpid(), msgbuf, 0 );
|
||||
|
|
@ -851,8 +845,6 @@ char *s )
|
|||
char *p;
|
||||
|
||||
for ( p = s; ( p != NULL ) && ( *p != '\0' ); p++ ) {
|
||||
if ( islower( *p )) {
|
||||
*p = toupper( *p );
|
||||
}
|
||||
*p = TOUPPER( (unsigned char) *p );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,16 +14,18 @@
|
|||
* lock.c - routines to open and apply an advisory lock to a file
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ac/string.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/time.h>
|
||||
#include <ac/unistd.h>
|
||||
|
||||
#include <sys/file.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include "portable.h"
|
||||
#ifdef USE_LOCKF
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../slapd/slap.h"
|
||||
|
||||
|
||||
|
|
@ -48,11 +50,12 @@ lock_fopen(
|
|||
}
|
||||
|
||||
/* acquire the lock */
|
||||
#ifdef USE_LOCKF
|
||||
while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) {
|
||||
#ifdef HAVE_FLOCK
|
||||
while ( flock( fileno( *lfp ), LOCK_EX ) != 0 )
|
||||
#else
|
||||
while ( flock( fileno( *lfp ), LOCK_EX ) != 0 ) {
|
||||
while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 )
|
||||
#endif
|
||||
{
|
||||
; /* NULL */
|
||||
}
|
||||
|
||||
|
|
@ -60,10 +63,10 @@ lock_fopen(
|
|||
if ( (fp = fopen( fname, type )) == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"Error: could not open \"%s\"\n", fname, 0, 0 );
|
||||
#ifdef USE_LOCKF
|
||||
lockf( fileno( *lfp ), F_ULOCK, 0 );
|
||||
#else
|
||||
#ifdef HAVE_FLOCK
|
||||
flock( fileno( *lfp ), LOCK_UN );
|
||||
#else
|
||||
lockf( fileno( *lfp ), F_ULOCK, 0 );
|
||||
#endif
|
||||
return( NULL );
|
||||
}
|
||||
|
|
@ -80,10 +83,10 @@ lock_fclose(
|
|||
)
|
||||
{
|
||||
/* unlock */
|
||||
#ifdef USE_LOCKF
|
||||
lockf( fileno( lfp ), F_ULOCK, 0 );
|
||||
#else
|
||||
#ifdef HAVE_FLOCK
|
||||
flock( fileno( lfp ), LOCK_UN );
|
||||
#else
|
||||
lockf( fileno( lfp ), F_ULOCK, 0 );
|
||||
#endif
|
||||
fclose( lfp );
|
||||
|
||||
|
|
|
|||
|
|
@ -34,21 +34,22 @@ extern int sanity();
|
|||
extern void start_lwp_scheduler();
|
||||
#endif /* HAVE_LWP */
|
||||
|
||||
int
|
||||
main(
|
||||
int argc,
|
||||
char **argv
|
||||
)
|
||||
{
|
||||
#ifdef NO_THREADS
|
||||
/* Haven't yet written the non-threaded version */
|
||||
fputs( "slurpd currently requires threads support\n", stderr );
|
||||
return( 1 );
|
||||
#else
|
||||
|
||||
pthread_attr_t attr;
|
||||
int status;
|
||||
int i;
|
||||
|
||||
#ifdef NO_THREADS
|
||||
/* Haven't yet written the non-threaded version */
|
||||
fprintf( stderr, "slurpd currently requires threads support\n" );
|
||||
exit( 1 );
|
||||
#else
|
||||
|
||||
/*
|
||||
* Create and initialize globals. init_globals() also initializes
|
||||
* the main replication queue.
|
||||
|
|
|
|||
|
|
@ -18,28 +18,30 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <ac/errno.h>
|
||||
#include <ac/socket.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/ctype.h>
|
||||
|
||||
#include "../slapd/slap.h"
|
||||
#include "slurp.h"
|
||||
#include "globals.h"
|
||||
|
||||
/* externs */
|
||||
extern char *str_getline( char **next );
|
||||
extern void ch_free( char *p );
|
||||
|
||||
extern char *sys_errlist[];
|
||||
extern char *str_getline LDAP_P(( char **next ));
|
||||
extern void ch_free LDAP_P(( char *p ));
|
||||
|
||||
/* Forward references */
|
||||
static Rh *get_repl_hosts( char *, int *, char ** );
|
||||
static int gettype( char * );
|
||||
static int getchangetype( char *);
|
||||
static int Re_parse( Re *re, char *replbuf );
|
||||
static void Re_dump( Re *re, FILE *fp );
|
||||
static void warn_unknown_replica( char *, int port );
|
||||
static Rh *get_repl_hosts LDAP_P(( char *, int *, char ** ));
|
||||
static int gettype LDAP_P(( char * ));
|
||||
static int getchangetype LDAP_P(( char * ));
|
||||
static int Re_parse LDAP_P(( Re *re, char *replbuf ));
|
||||
static void Re_dump LDAP_P(( Re *re, FILE *fp ));
|
||||
static void warn_unknown_replica LDAP_P(( char *, int port ));
|
||||
|
||||
/* Globals, scoped within this file */
|
||||
static int nur = 0; /* Number of unknown replicas */
|
||||
|
|
@ -80,10 +82,10 @@ Re_free(
|
|||
"Warning: freeing re (dn: %s) with nonzero refcnt\n",
|
||||
re->re_dn, 0, 0 );
|
||||
}
|
||||
#if !defined( THREAD_SUNOS4_LWP )
|
||||
#if !defined( HAVE_LWP )
|
||||
/* This seems to have problems under SunOS lwp */
|
||||
pthread_mutex_destroy( &re->re_mutex );
|
||||
#endif /* THREAD_SUNOS4_LWP */
|
||||
#endif /* HAVE_LWP */
|
||||
ch_free( re->re_timestamp );
|
||||
if (( rh = re->re_replicas ) != NULL ) {
|
||||
for ( i = 0; rh[ i ].rh_hostname != NULL; i++ ) {
|
||||
|
|
@ -176,13 +178,15 @@ Re_parse(
|
|||
*p++ = '\0';
|
||||
}
|
||||
re->re_timestamp = strdup( value );
|
||||
if ( p != NULL && isdigit( *p )) {
|
||||
if ( p != NULL && isdigit( (unsigned char) *p )) {
|
||||
re->re_seq = atoi( p );
|
||||
}
|
||||
state |= GOT_TIME;
|
||||
break;
|
||||
case T_DN:
|
||||
re->re_dn = strdup( value );
|
||||
re->re_dn = ch_malloc( len + 1 );
|
||||
memcpy( re->re_dn, value, len );
|
||||
re->re_dn[ len ]='\0';
|
||||
state |= GOT_DN;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -222,7 +226,9 @@ Re_parse(
|
|||
sizeof( Mi ) * ( nml + 2 ));
|
||||
re->re_mods[ nml ].mi_type = strdup( type );
|
||||
if ( value != NULL ) {
|
||||
re->re_mods[ nml ].mi_val = strdup( value );
|
||||
re->re_mods[ nml ].mi_val = ch_malloc( len + 1 );
|
||||
memcpy( re->re_mods[ nml ].mi_val, value, len );
|
||||
re->re_mods[ nml ].mi_val[ len ] = '\0';
|
||||
re->re_mods[ nml ].mi_len = len;
|
||||
} else {
|
||||
re->re_mods[ nml ].mi_val = NULL;
|
||||
|
|
@ -494,7 +500,6 @@ Re_write(
|
|||
int i;
|
||||
char *s;
|
||||
int rc = 0;
|
||||
Rh *rh;
|
||||
|
||||
if ( re == NULL || fp == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "Internal error: Re_write: NULL argument\n",
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
* replica.c - code to start up replica threads.
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -31,9 +32,6 @@ replicate(
|
|||
Ri *ri
|
||||
)
|
||||
{
|
||||
int i;
|
||||
unsigned long seq;
|
||||
|
||||
Debug( LDAP_DEBUG_ARGS, "begin replication thread for %s:%d\n",
|
||||
ri->ri_hostname, ri->ri_port, 0 );
|
||||
|
||||
|
|
@ -57,15 +55,35 @@ start_replica_thread(
|
|||
pthread_attr_t attr;
|
||||
|
||||
pthread_attr_init( &attr );
|
||||
#ifdef NOTDEF
|
||||
/* if main wants to join with us, we shouldn't detach */
|
||||
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
|
||||
#endif
|
||||
|
||||
if ( pthread_create( &(ri->ri_tid), attr, (void *) replicate,
|
||||
#if !defined(HAVE_PTHREAD_D4) && !defined(HAVE_DCE)
|
||||
/* POSIX_THREADS or compatible
|
||||
* This is a draft 10 or standard pthreads implementation
|
||||
*/
|
||||
if ( pthread_create( &(ri->ri_tid), &attr, replicate,
|
||||
(void *) ri ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
|
||||
ri->ri_hostname, ri->ri_port, 0 );
|
||||
pthread_attr_destroy( &attr );
|
||||
return -1;
|
||||
}
|
||||
#else /* !final */
|
||||
/*
|
||||
* This is a draft 4 or earlier pthreads implementation
|
||||
*/
|
||||
if ( pthread_create( &(ri->ri_tid), attr, replicate,
|
||||
(void *) ri ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
|
||||
ri->ri_hostname, ri->ri_port, 0 );
|
||||
pthread_attr_destroy( &attr );
|
||||
return -1;
|
||||
}
|
||||
#endif /* !final */
|
||||
|
||||
pthread_attr_destroy( &attr );
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,33 +17,23 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <ac/signal.h>
|
||||
|
||||
#include "slurp.h"
|
||||
#include "globals.h"
|
||||
|
||||
|
||||
/* External references */
|
||||
#ifdef NEEDPROTOS
|
||||
extern void write_reject( Ri *, Re *, int, char * );
|
||||
extern void do_nothing();
|
||||
#else /* NEEDPROTOS */
|
||||
extern void write_reject();
|
||||
extern void do_nothing();
|
||||
#endif /* NEEDPROTOS */
|
||||
extern void write_reject LDAP_P(( Ri *, Re *, int, char * ));
|
||||
extern void do_nothing LDAP_P(());
|
||||
|
||||
/* Forward references */
|
||||
#ifdef NEEDPROTOS
|
||||
static int ismine( Ri *, Re * );
|
||||
static int isnew( Ri *, Re * );
|
||||
void tsleep( time_t );
|
||||
#else /* NEEDPROTOS */
|
||||
static int ismine();
|
||||
static int isnew();
|
||||
void tsleep();
|
||||
#endif /* NEEDPROTOS */
|
||||
static int ismine LDAP_P(( Ri *, Re * ));
|
||||
static int isnew LDAP_P(( Ri *, Re * ));
|
||||
void tsleep LDAP_P(( time_t ));
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -56,11 +46,14 @@ Ri_process(
|
|||
{
|
||||
Rq *rq = sglob->rq;
|
||||
Re *re, *new_re;
|
||||
int i;
|
||||
int rc ;
|
||||
char *errmsg;
|
||||
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#ifdef HAVE_LINUX_THREADS
|
||||
(void) SIGNAL( SIGSTKFLT, do_nothing );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR1, do_nothing );
|
||||
#endif
|
||||
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
||||
if ( ri == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 );
|
||||
|
|
@ -146,7 +139,8 @@ Ri_process(
|
|||
|
||||
|
||||
/*
|
||||
* Wake a replication thread which may be sleeping. Send it a SIGUSR1.
|
||||
* Wake a replication thread which may be sleeping.
|
||||
* Send it a SIG(STKFLT|USR1).
|
||||
*/
|
||||
static void
|
||||
Ri_wake(
|
||||
|
|
@ -156,8 +150,13 @@ Ri_wake(
|
|||
if ( ri == NULL ) {
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_LINUX_THREADS
|
||||
pthread_kill( ri->ri_tid, SIGSTKFLT );
|
||||
(void) SIGNAL( SIGSTKFLT, do_nothing );
|
||||
#else
|
||||
pthread_kill( ri->ri_tid, SIGUSR1 );
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
(void) SIGNAL( SIGUSR1, do_nothing );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue