/* $OpenLDAP$ */
/*
- * Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
+ * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#define LDAP_IS_LEAF 0x23 /* not LDAPv3 */
#define LDAP_ALIAS_DEREF_PROBLEM 0x24
-#define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x30,0x32) /* 48-50 */
+#define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x2F,0x32) /* 47-50 */
+#define LDAP_PROXY_AUTHZ_FAILURE 0x2F /* LDAPv3 proxy authorization */
#define LDAP_INAPPROPRIATE_AUTH 0x30
#define LDAP_INVALID_CREDENTIALS 0x31
#define LDAP_INSUFFICIENT_ACCESS 0x32
LDAPControl ***serverctrls,
int freeit ));
+LDAP_F( int )
+ldap_parse_intermediate_resp_result LDAP_P((
+ LDAP *ld,
+ LDAPMessage *res,
+ char **retoidp,
+ struct berval **retdatap,
+ int freeit ));
+
/*
* in abandon.c:
*/
ldap_uncache_request LDAP_P(( LDAP *ld, int msgid ));
+/*
+ * LDAP Cancel Extended Operation <draft-zeilenga-ldap-cancel-xx.txt>
+ */
+
+LDAP_F( int )
+ldap_cancel LDAP_P(( LDAP *ld,
+ int cancelid,
+ LDAPControl **sctrls,
+ LDAPControl **cctrls,
+ int *msgidp ));
+
+LDAP_F( int )
+ldap_cancel_s LDAP_P((
+ LDAP *ld,
+ int cancelid,
+ LDAPControl **sctrl,
+ LDAPControl **cctrl ));
+
/*
* in compare.c:
*/
struct berval **contextp,
int *errcodep ));
+/*
+ * LDAP Who Am I? (whoami.c)
+ */
+
+LDAP_F( int )
+ldap_parse_whoami LDAP_P((
+ LDAP *ld,
+ LDAPMessage *res,
+ struct berval **authzid ));
+
+LDAP_F( int )
+ldap_whoami LDAP_P(( LDAP *ld,
+ LDAPControl **sctrls,
+ LDAPControl **cctrls,
+ int *msgidp ));
+
+LDAP_F( int )
+ldap_whoami_s LDAP_P((
+ LDAP *ld,
+ struct berval **authzid,
+ LDAPControl **sctrls,
+ LDAPControl **cctrls ));
LDAP_END_DECL
#endif /* _LDAP_H */
# $OpenLDAP$
-## Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+## Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
##
## LIBAVL
/* avl.c - routines to implement an avl tree */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
/*
* Copyright (c) 1993 Regents of the University of Michigan.
* All rights reserved.
* is provided ``as is'' without express or implied warranty.
*/
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-static char avl_version[] = "AVL library version 1.0\n";
-#endif
+#include "portable.h"
-#include <sys/types.h>
#include <stdio.h>
+#include <ac/stdlib.h>
+
+#ifdef CSRIMALLOC
+#define ber_memalloc malloc
+#define ber_memrealloc realloc
+#define ber_memfree free
+#else
+#include "lber.h"
+#endif
+
+#define AVL_INTERNAL
#include "avl.h"
#define ROTATERIGHT(x) { \
Avlnode *tmp;\
- if ( *x == NULL || (*x)->avl_left == NULL ) {\
- (void) printf("RR error\n"); exit(1); \
+ if ( *(x) == NULL || (*(x))->avl_left == NULL ) {\
+ (void) fputs("RR error\n", stderr); exit( EXIT_FAILURE ); \
}\
- tmp = (*x)->avl_left;\
- (*x)->avl_left = tmp->avl_right;\
- tmp->avl_right = *x;\
- *x = tmp;\
+ tmp = (*(x))->avl_left;\
+ (*(x))->avl_left = tmp->avl_right;\
+ tmp->avl_right = *(x);\
+ *(x) = tmp;\
}
#define ROTATELEFT(x) { \
Avlnode *tmp;\
- if ( *x == NULL || (*x)->avl_right == NULL ) {\
- (void) printf("RL error\n"); exit(1); \
+ if ( *(x) == NULL || (*(x))->avl_right == NULL ) {\
+ (void) fputs("RL error\n", stderr); exit( EXIT_FAILURE ); \
}\
- tmp = (*x)->avl_right;\
- (*x)->avl_right = tmp->avl_left;\
- tmp->avl_left = *x;\
- *x = tmp;\
+ tmp = (*(x))->avl_right;\
+ (*(x))->avl_right = tmp->avl_left;\
+ tmp->avl_left = *(x);\
+ *(x) = tmp;\
}
/*
* and balance of an avl tree.
*/
-static
-ravl_insert( iroot, data, taller, fcmp, fdup, depth )
- Avlnode **iroot;
- caddr_t data;
- int *taller;
- IFP fcmp; /* comparison function */
- IFP fdup; /* function to call for duplicates */
- int depth;
+static int
+ravl_insert(
+ Avlnode **iroot,
+ void* data,
+ int *taller,
+ AVL_CMP fcmp, /* comparison function */
+ AVL_DUP fdup, /* function to call for duplicates */
+ int depth
+)
{
int rc, cmp, tallersub;
Avlnode *l, *r;
if ( *iroot == 0 ) {
- if ( (*iroot = (Avlnode *) malloc( sizeof( Avlnode ) ))
+ if ( (*iroot = (Avlnode *) ber_memalloc( sizeof( Avlnode ) ))
== NULL ) {
return( -1 );
}
* NOTE: this routine may malloc memory
*/
-avl_insert( root, data, fcmp, fdup )
- Avlnode **root;
- caddr_t data;
- IFP fcmp;
- IFP fdup;
+int
+avl_insert( Avlnode **root, void* data, AVL_CMP fcmp, AVL_DUP fdup )
{
int taller;
* been shortened because of a deletion.
*/
-static
-right_balance( root )
- Avlnode **root;
+static int
+right_balance( Avlnode **root )
{
- int shorter;
+ int shorter = -1;
Avlnode *r, *l;
switch( (*root)->avl_bf ) {
* been shortened because of a deletion.
*/
-static
-left_balance( root )
- Avlnode **root;
+static int
+left_balance( Avlnode **root )
{
- int shorter;
+ int shorter = -1;
Avlnode *r, *l;
switch( (*root)->avl_bf ) {
* rebalancing.
*/
-static caddr_t
-ravl_delete( root, data, fcmp, shorter )
- Avlnode **root;
- caddr_t data;
- IFP fcmp;
- int *shorter;
+static void*
+ravl_delete( Avlnode **root, void* data, AVL_CMP fcmp, int *shorter )
{
int shortersubtree = 0;
int cmp;
- caddr_t savedata;
+ void* savedata;
Avlnode *minnode, *savenode;
if ( *root == NULLAVL )
if ( (*root)->avl_left == 0 ) {
*root = (*root)->avl_right;
*shorter = 1;
- free( (char *) savenode );
+ ber_memfree( (char *) savenode );
return( savedata );
/* no right child */
} else if ( (*root)->avl_right == 0 ) {
*root = (*root)->avl_left;
*shorter = 1;
- free( (char *) savenode );
+ ber_memfree( (char *) savenode );
return( savedata );
}
* the avl tree rooted at root.
*/
-caddr_t
-avl_delete( root, data, fcmp )
- Avlnode **root;
- caddr_t data;
- IFP fcmp;
+void*
+avl_delete( Avlnode **root, void* data, AVL_CMP fcmp )
{
int shorter;
return( ravl_delete( root, data, fcmp, &shorter ) );
}
-static
-avl_inapply( root, fn, arg, stopflag )
- Avlnode *root;
- IFP fn;
- caddr_t arg;
- int stopflag;
+static int
+avl_inapply( Avlnode *root, AVL_APPLY fn, void* arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
return( avl_inapply( root->avl_right, fn, arg, stopflag ) );
}
-static
-avl_postapply( root, fn, arg, stopflag )
- Avlnode *root;
- IFP fn;
- caddr_t arg;
- int stopflag;
+static int
+avl_postapply( Avlnode *root, AVL_APPLY fn, void* arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
return( (*fn)( root->avl_data, arg ) );
}
-static
-avl_preapply( root, fn, arg, stopflag )
- Avlnode *root;
- IFP fn;
- caddr_t arg;
- int stopflag;
+static int
+avl_preapply( Avlnode *root, AVL_APPLY fn, void* arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
* of nodes.
*/
-avl_apply( root, fn, arg, stopflag, type )
- Avlnode *root;
- IFP fn;
- caddr_t arg;
- int stopflag;
- int type;
+int
+avl_apply( Avlnode *root, AVL_APPLY fn, void* arg, int stopflag, int type )
{
switch ( type ) {
case AVL_INORDER:
* AVL_NOMORE is returned.
*/
-avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag )
- Avlnode *root;
- caddr_t data;
- IFP fmatch;
- caddr_t marg;
- IFP fcmp;
- caddr_t carg;
- int stopflag;
+int
+avl_prefixapply(
+ Avlnode *root,
+ void* data,
+ AVL_CMP fmatch,
+ void* marg,
+ AVL_CMP fcmp,
+ void* carg,
+ int stopflag
+)
{
int cmp;
if ( root == 0 )
return( AVL_NOMORE );
- cmp = (*fcmp)( data, root->avl_data, carg );
+ cmp = (*fcmp)( data, root->avl_data /* , carg */);
if ( cmp == 0 ) {
if ( (*fmatch)( root->avl_data, marg ) == stopflag )
return( stopflag );
* number of items actually freed is returned.
*/
-avl_free( root, dfree )
- Avlnode *root;
- IFP dfree;
+int
+avl_free( Avlnode *root, AVL_FREE dfree )
{
int nleft, nright;
if ( dfree )
(*dfree)( root->avl_data );
+ ber_memfree( root );
return( nleft + nright + 1 );
}
* < 0 if arg1 is less than arg2 and > 0 if arg1 is greater than arg2.
*/
-caddr_t
-avl_find( root, data, fcmp )
- Avlnode *root;
- caddr_t data;
- IFP fcmp;
+void*
+avl_find( Avlnode *root, const void* data, AVL_CMP fcmp )
{
int cmp;
* they match, non-zero otherwise.
*/
-caddr_t
-avl_find_lin( root, data, fcmp )
- Avlnode *root;
- caddr_t data;
- IFP fcmp;
+void*
+avl_find_lin( Avlnode *root, const void* data, AVL_CMP fcmp )
{
- caddr_t res;
+ void* res;
if ( root == 0 )
return( NULL );
return( avl_find_lin( root->avl_right, data, fcmp ) );
}
-static caddr_t *avl_list;
+/* NON-REENTRANT INTERFACE */
+
+static void* *avl_list;
static int avl_maxlist;
static int avl_nextlist;
#define AVL_GRABSIZE 100
/* ARGSUSED */
-static
-avl_buildlist( data, arg )
- caddr_t data;
- int arg;
+static int
+avl_buildlist( void* data, void* arg )
{
static int slots;
- if ( avl_list == (caddr_t *) 0 ) {
- avl_list = (caddr_t *) malloc(AVL_GRABSIZE * sizeof(caddr_t));
+ if ( avl_list == (void* *) 0 ) {
+ avl_list = (void* *) ber_memalloc(AVL_GRABSIZE * sizeof(void*));
slots = AVL_GRABSIZE;
avl_maxlist = 0;
} else if ( avl_maxlist == slots ) {
slots += AVL_GRABSIZE;
- avl_list = (caddr_t *) realloc( (char *) avl_list,
- (unsigned) slots * sizeof(caddr_t));
+ avl_list = (void* *) ber_memrealloc( (char *) avl_list,
+ (unsigned) slots * sizeof(void*));
}
avl_list[ avl_maxlist++ ] = data;
* different trees) cannot be active at once.
*/
-caddr_t
-avl_getfirst( root )
- Avlnode *root;
+void*
+avl_getfirst( Avlnode *root )
{
if ( avl_list ) {
- free( (char *) avl_list);
- avl_list = (caddr_t *) 0;
+ ber_memfree( (char *) avl_list);
+ avl_list = (void* *) 0;
}
avl_maxlist = 0;
avl_nextlist = 0;
if ( root == 0 )
return( 0 );
- (void) avl_apply( root, avl_buildlist, (caddr_t) 0, -1, AVL_INORDER );
+ (void) avl_apply( root, avl_buildlist, (void*) 0, -1, AVL_INORDER );
return( avl_list[ avl_nextlist++ ] );
}
-caddr_t
-avl_getnext()
+void*
+avl_getnext( void )
{
if ( avl_list == 0 )
return( 0 );
if ( avl_nextlist == avl_maxlist ) {
- free( (caddr_t) avl_list);
- avl_list = (caddr_t *) 0;
+ ber_memfree( (void*) avl_list);
+ avl_list = (void* *) 0;
return( 0 );
}
return( avl_list[ avl_nextlist++ ] );
}
-avl_dup_error()
+/* end non-reentrant code */
+
+
+int
+avl_dup_error( void* left, void* right )
{
return( -1 );
}
-avl_dup_ok()
+int
+avl_dup_ok( void* left, void* right )
{
return( 0 );
}
/* testavl.c - Test Tim Howes AVL code */
-#include <sys/types.h>
-#include <stdio.h>
-#include "avl.h"
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
-char *strdup( s )
-char *s;
-{
- char *new;
+#include "portable.h"
- if ( (new = (char *) malloc( strlen( s ) + 1 )) == NULL )
- return( NULL );
+#include <stdio.h>
- strcpy( new, s );
+#include <ac/stdlib.h>
+#include <ac/string.h>
- return( new );
-}
+#define AVL_INTERNAL
+#define AVL_NONREENTRANT
+#include "avl.h"
-main( argc, argv )
-int argc;
-char **argv;
+static void ravl_print LDAP_P(( Avlnode *root, int depth ));
+static void myprint LDAP_P(( Avlnode *root ));
+static int avl_strcmp LDAP_P(( const void *s, const void *t ));
+
+int
+main( int argc, char **argv )
{
- Avlnode *tree = NULLAVL;
+ Avlnode *tree = NULL;
char command[ 10 ];
char name[ 80 ];
char *p;
- int free(), strcmp();
printf( "> " );
while ( fgets( command, sizeof( command ), stdin ) != NULL ) {
switch( *command ) {
case 'n': /* new tree */
( void ) avl_free( tree, free );
- tree = NULLAVL;
+ tree = NULL;
break;
case 'p': /* print */
( void ) myprint( tree );
break;
case 't': /* traverse with first, next */
+#ifdef AVL_NONREENTRANT
printf( "***\n" );
for ( p = (char * ) avl_getfirst( tree );
- p != NULL; p = (char *) avl_getnext( tree, p ) )
+ p != NULL;
+ p = (char *) avl_getnext())
printf( "%s\n", p );
printf( "***\n" );
+#else
+ printf( "*** reentrant interface not implemented ***" );
+#endif
break;
case 'f': /* find */
printf( "data? " );
if ( fgets( name, sizeof( name ), stdin ) == NULL )
- exit( 0 );
+ exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0';
- if ( (p = (char *) avl_find( tree, name, strcmp ))
+ if ( (p = (char *) avl_find( tree, name, avl_strcmp ))
== NULL )
printf( "Not found.\n\n" );
else
case 'i': /* insert */
printf( "data? " );
if ( fgets( name, sizeof( name ), stdin ) == NULL )
- exit( 0 );
+ exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0';
- if ( avl_insert( &tree, strdup( name ), strcmp,
- avl_dup_error ) != OK )
+ if ( avl_insert( &tree, strdup( name ), avl_strcmp,
+ avl_dup_error ) != 0 )
printf( "\nNot inserted!\n" );
break;
case 'd': /* delete */
printf( "data? " );
if ( fgets( name, sizeof( name ), stdin ) == NULL )
- exit( 0 );
+ exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0';
- if ( avl_delete( &tree, name, strcmp ) == NULL )
+ if ( avl_delete( &tree, name, avl_strcmp ) == NULL )
printf( "\nNot found!\n" );
break;
case 'q': /* quit */
- exit( 0 );
+ exit( EXIT_SUCCESS );
break;
case '\n':
break;
printf( "> " );
}
- /* NOTREACHED */
+
+ return( 0 );
}
-static ravl_print( root, depth )
-Avlnode *root;
-int depth;
+static void ravl_print( Avlnode *root, int depth )
{
int i;
for ( i = 0; i < depth; i++ )
printf( " " );
- printf( "%s %d\n", root->avl_data, root->avl_bf );
+ printf( "%s %d\n", (char *) root->avl_data, root->avl_bf );
ravl_print( root->avl_left, depth+1 );
}
-myprint( root )
-Avlnode *root;
+static void myprint( Avlnode *root )
{
printf( "********\n" );
if ( root == 0 )
printf( "\tNULL\n" );
else
- ( void ) ravl_print( root, 0 );
+ ravl_print( root, 0 );
printf( "********\n" );
}
+
+static int avl_strcmp( const void *s, const void *t )
+{
+ return strcmp( s, t );
+}
# $OpenLDAP$
-## Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+## Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
##
## Makefile.in for LDAP -lldap
controls.c messages.c references.c extended.c cyrus.c \
modify.c add.c modrdn.c delete.c abandon.c cache.c \
sasl.c sbind.c kbind.c unbind.c \
- filter.c free.c sort.c \
+ filter.c free.c sort.c passwd.c whoami.c \
getdn.c getentry.c getattr.c getvalues.c addentry.c \
- request.c os-ip.c url.c sortctrl.c vlvctrl.c whoami.c \
+ request.c os-ip.c url.c sortctrl.c vlvctrl.c \
init.c options.c print.c string.c util-int.c schema.c \
- charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c
+ charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \
+ cancel.c
OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
controls.lo messages.lo references.lo extended.lo cyrus.lo \
modify.lo add.lo modrdn.lo delete.lo abandon.lo cache.lo \
sasl.lo sbind.lo kbind.lo unbind.lo \
- filter.lo free.lo sort.lo \
+ filter.lo free.lo sort.lo passwd.lo whoami.lo \
getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
- request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo whoami.lo \
+ request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \
init.lo options.lo print.lo string.lo util-int.lo schema.lo \
- charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo
+ charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \
+ cancel.lo
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
/* $OpenLDAP$ */
/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
}
/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* Adapted for inclusion into OpenLDAP by Kurt D. Zeilenga */
LDAPControl **ctrlp )
{
LDAPControl *ctrl;
- struct berval *bvalp;
assert( requestOID != NULL );
assert( ber != NULL );
return LDAP_NO_MEMORY;
}
- if ( ber_flatten( ber, &bvalp ) == -1 ) {
+ if ( ber_flatten2( ber, &ctrl->ldctl_value, 1 ) == -1 ) {
LDAP_FREE( ctrl );
return LDAP_NO_MEMORY;
}
- ctrl->ldctl_value = *bvalp;
- ber_memfree( bvalp );
-
ctrl->ldctl_oid = LDAP_STRDUP( requestOID );
ctrl->ldctl_iscritical = iscritical;
/* $OpenLDAP$ */
/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
{LDAP_IS_LEAF, "Entry is a leaf" },
{LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem" },
+ {LDAP_PROXY_AUTHZ_FAILURE, "Proxy Authorization Failure" },
{LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication" },
{LDAP_INVALID_CREDENTIALS, "Invalid credentials" },
{LDAP_INSUFFICIENT_ACCESS, "Insufficient access" },
/* $OpenLDAP$ */
/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* OpenLDAP Filter API Test */
static int filter2ber( char *filter )
{
int rc;
- struct berval *bv = NULL;
+ struct berval bv = {0};
BerElement *ber;
printf( "Filter: %s\n", filter );
return EXIT_FAILURE;
}
- rc = ber_flatten( ber, &bv );
+ rc = ber_flatten2( ber, &bv, 0 );
if( rc < 0 ) {
- perror( "ber_flatten" );
+ perror( "ber_flatten2" );
return EXIT_FAILURE;
}
- printf( "BER encoding (len=%ld):\n", (long) bv->bv_len );
- ber_bprint( bv->bv_val, bv->bv_len );
+ printf( "BER encoding (len=%ld):\n", (long) bv.bv_len );
+ ber_bprint( bv.bv_val, bv.bv_len );
- ber_free( ber, 0 );
- ber_bvfree( bv );
+ ber_free( ber, 1 );
return EXIT_SUCCESS;
}
# End Source File
# Begin Source File
+SOURCE=.\cancel.c
+# End Source File
+# Begin Source File
+
SOURCE=.\charray.c
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=.\passwd.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\include\portable.h
# End Source File
# Begin Source File
SOURCE=.\vlvctrl.c
# End Source File
+# Begin Source File
+
+SOURCE=.\whoami.c
+# End Source File
# End Target
# End Project