1999-09-02 16:40:22 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-26 23:24:38 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2006-01-04 07:11:52 +08:00
|
|
|
* Copyright 1999-2006 The OpenLDAP Foundation.
|
2003-11-26 23:24:38 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
1999-09-02 08:56:32 +08:00
|
|
|
*/
|
2003-11-26 23:24:38 +08:00
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was initially developed by Kurt Spanier for inclusion
|
|
|
|
* in OpenLDAP Software.
|
|
|
|
*/
|
|
|
|
|
1999-02-15 18:49:20 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
1999-06-03 08:37:44 +08:00
|
|
|
|
|
|
|
#include <ac/stdlib.h>
|
1999-02-15 18:49:20 +08:00
|
|
|
|
|
|
|
#include <ac/ctype.h>
|
1999-11-02 01:21:24 +08:00
|
|
|
#include <ac/param.h>
|
1999-02-15 18:49:20 +08:00
|
|
|
#include <ac/socket.h>
|
1999-03-29 09:55:49 +08:00
|
|
|
#include <ac/string.h>
|
1999-02-15 18:49:20 +08:00
|
|
|
#include <ac/unistd.h>
|
|
|
|
#include <ac/wait.h>
|
|
|
|
|
1999-08-04 02:14:24 +08:00
|
|
|
#include <ldap.h>
|
2005-11-24 09:10:05 +08:00
|
|
|
#include <lutil.h>
|
1999-02-15 18:49:20 +08:00
|
|
|
|
2006-01-12 21:01:38 +08:00
|
|
|
#include "slapd-common.h"
|
|
|
|
|
1999-02-15 18:49:20 +08:00
|
|
|
#define LOOPS 100
|
2005-04-21 00:16:39 +08:00
|
|
|
#define RETRIES 0
|
1999-02-15 18:49:20 +08:00
|
|
|
|
|
|
|
static char *
|
|
|
|
get_add_entry( char *filename, LDAPMod ***mods );
|
|
|
|
|
|
|
|
static void
|
2006-01-12 21:01:38 +08:00
|
|
|
do_addel( char *uri, char *manager, struct berval *passwd,
|
2005-11-05 00:17:32 +08:00
|
|
|
char *dn, LDAPMod **attrs, int maxloop, int maxretries, int delay,
|
2006-03-25 18:13:30 +08:00
|
|
|
int friendly, int chaserefs );
|
1999-02-15 18:49:20 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
usage( char *name )
|
|
|
|
{
|
2005-08-19 15:27:32 +08:00
|
|
|
fprintf( stderr,
|
|
|
|
"usage: %s "
|
|
|
|
"-H <uri> | ([-h <host>] -p <port>) "
|
|
|
|
"-D <manager> "
|
|
|
|
"-w <passwd> "
|
|
|
|
"-f <addfile> "
|
2006-06-09 17:30:36 +08:00
|
|
|
"[-i <ignore>] "
|
2005-08-19 15:27:32 +08:00
|
|
|
"[-l <loops>] "
|
2006-03-04 00:02:34 +08:00
|
|
|
"[-L <outerloops>] "
|
2005-08-19 15:27:32 +08:00
|
|
|
"[-r <maxretries>] "
|
2005-11-07 07:35:53 +08:00
|
|
|
"[-t <delay>] "
|
2006-03-25 18:13:30 +08:00
|
|
|
"[-F] "
|
|
|
|
"[-C]\n",
|
1999-02-15 18:49:20 +08:00
|
|
|
name );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main( int argc, char **argv )
|
|
|
|
{
|
1999-03-06 14:33:34 +08:00
|
|
|
int i;
|
2005-04-21 00:16:39 +08:00
|
|
|
char *host = "localhost";
|
2003-02-13 16:02:40 +08:00
|
|
|
char *uri = NULL;
|
2005-04-21 00:16:39 +08:00
|
|
|
int port = -1;
|
1999-02-15 18:49:20 +08:00
|
|
|
char *manager = NULL;
|
2006-01-12 21:01:38 +08:00
|
|
|
struct berval passwd = { 0, NULL };
|
1999-02-15 18:49:20 +08:00
|
|
|
char *filename = NULL;
|
|
|
|
char *entry = NULL;
|
2005-04-21 00:16:39 +08:00
|
|
|
int loops = LOOPS;
|
2006-03-04 00:02:34 +08:00
|
|
|
int outerloops = 1;
|
2005-04-21 00:16:39 +08:00
|
|
|
int retries = RETRIES;
|
2005-08-19 15:27:32 +08:00
|
|
|
int delay = 0;
|
2005-11-05 00:17:32 +08:00
|
|
|
int friendly = 0;
|
2006-03-25 18:13:30 +08:00
|
|
|
int chaserefs = 0;
|
2005-04-21 00:16:39 +08:00
|
|
|
LDAPMod **attrs = NULL;
|
1999-02-15 18:49:20 +08:00
|
|
|
|
2006-06-09 17:30:36 +08:00
|
|
|
tester_init( "slapd-addel", TESTER_ADDEL );
|
2006-01-12 21:01:38 +08:00
|
|
|
|
2006-12-04 05:34:24 +08:00
|
|
|
while ( ( i = getopt( argc, argv, "CD:Ff:H:h:i:L:l:p:r:t:w:" ) ) != EOF )
|
|
|
|
{
|
|
|
|
switch ( i ) {
|
2006-03-25 18:13:30 +08:00
|
|
|
case 'C':
|
|
|
|
chaserefs++;
|
|
|
|
break;
|
|
|
|
|
2005-11-05 00:17:32 +08:00
|
|
|
case 'F':
|
|
|
|
friendly++;
|
|
|
|
break;
|
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
case 'H': /* the server's URI */
|
|
|
|
uri = strdup( optarg );
|
2003-02-13 16:02:40 +08:00
|
|
|
break;
|
2005-04-21 00:16:39 +08:00
|
|
|
|
|
|
|
case 'h': /* the servers host */
|
|
|
|
host = strdup( optarg );
|
1999-02-15 18:49:20 +08:00
|
|
|
break;
|
|
|
|
|
2006-06-09 17:30:36 +08:00
|
|
|
case 'i':
|
|
|
|
/* ignored (!) by now */
|
|
|
|
break;
|
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
case 'p': /* the servers port */
|
2005-11-24 09:10:05 +08:00
|
|
|
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
|
|
|
usage( argv[0] );
|
|
|
|
}
|
2005-04-21 00:16:39 +08:00
|
|
|
break;
|
1999-02-15 18:49:20 +08:00
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
case 'D': /* the servers manager */
|
|
|
|
manager = strdup( optarg );
|
1999-02-15 18:49:20 +08:00
|
|
|
break;
|
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
case 'w': /* the server managers password */
|
2006-01-12 21:01:38 +08:00
|
|
|
passwd.bv_val = strdup( optarg );
|
|
|
|
passwd.bv_len = strlen( optarg );
|
2006-07-02 02:22:43 +08:00
|
|
|
memset( optarg, '*', passwd.bv_len );
|
1999-02-15 18:49:20 +08:00
|
|
|
break;
|
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
case 'f': /* file with entry search request */
|
|
|
|
filename = strdup( optarg );
|
|
|
|
break;
|
1999-02-15 18:49:20 +08:00
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
case 'l': /* the number of loops */
|
2005-11-24 09:10:05 +08:00
|
|
|
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
|
|
|
usage( argv[0] );
|
|
|
|
}
|
2005-04-21 00:16:39 +08:00
|
|
|
break;
|
1999-02-15 18:49:20 +08:00
|
|
|
|
2006-03-04 00:02:34 +08:00
|
|
|
case 'L': /* the number of outerloops */
|
|
|
|
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
|
|
|
usage( argv[0] );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-19 15:27:32 +08:00
|
|
|
case 'r': /* number of retries */
|
2005-11-24 09:10:05 +08:00
|
|
|
if ( lutil_atoi( &retries, optarg ) != 0 ) {
|
|
|
|
usage( argv[0] );
|
|
|
|
}
|
2005-04-21 00:16:39 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-19 15:27:32 +08:00
|
|
|
case 't': /* delay in seconds */
|
2005-11-24 09:10:05 +08:00
|
|
|
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
|
|
|
usage( argv[0] );
|
|
|
|
}
|
2005-08-19 15:27:32 +08:00
|
|
|
break;
|
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
default:
|
|
|
|
usage( argv[0] );
|
|
|
|
break;
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-13 16:02:40 +08:00
|
|
|
if (( filename == NULL ) || ( port == -1 && uri == NULL ) ||
|
2006-01-12 21:01:38 +08:00
|
|
|
( manager == NULL ) || ( passwd.bv_val == NULL ))
|
1999-02-15 18:49:20 +08:00
|
|
|
usage( argv[0] );
|
|
|
|
|
|
|
|
entry = get_add_entry( filename, &attrs );
|
|
|
|
if (( entry == NULL ) || ( *entry == '\0' )) {
|
|
|
|
|
|
|
|
fprintf( stderr, "%s: invalid entry DN in file \"%s\".\n",
|
|
|
|
argv[0], filename );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (( attrs == NULL ) || ( *attrs == '\0' )) {
|
|
|
|
|
|
|
|
fprintf( stderr, "%s: invalid attrs in file \"%s\".\n",
|
|
|
|
argv[0], filename );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-01-12 21:01:38 +08:00
|
|
|
uri = tester_uri( uri, host, port );
|
|
|
|
|
2006-03-04 00:02:34 +08:00
|
|
|
for ( i = 0; i < outerloops; i++ ) {
|
|
|
|
do_addel( uri, manager, &passwd, entry, attrs,
|
2006-03-25 18:13:30 +08:00
|
|
|
loops, retries, delay, friendly, chaserefs );
|
2006-03-04 00:02:34 +08:00
|
|
|
}
|
1999-02-15 18:49:20 +08:00
|
|
|
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_SUCCESS );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
|
|
|
|
{
|
|
|
|
LDAPMod **pmods;
|
|
|
|
int i, j;
|
|
|
|
struct berval *bvp;
|
|
|
|
|
|
|
|
pmods = *pmodsp;
|
|
|
|
modop |= LDAP_MOD_BVALUES;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
if ( pmods != NULL ) {
|
|
|
|
for ( ; pmods[ i ] != NULL; ++i ) {
|
|
|
|
if ( strcasecmp( pmods[ i ]->mod_type, attr ) == 0 &&
|
|
|
|
pmods[ i ]->mod_op == modop ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pmods == NULL || pmods[ i ] == NULL ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
if (( pmods = (LDAPMod **)realloc( pmods, (i + 2) *
|
1999-02-15 18:49:20 +08:00
|
|
|
sizeof( LDAPMod * ))) == NULL ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_perror( "realloc", NULL );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
*pmodsp = pmods;
|
|
|
|
pmods[ i + 1 ] = NULL;
|
|
|
|
if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod )))
|
|
|
|
== NULL ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_perror( "calloc", NULL );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
pmods[ i ]->mod_op = modop;
|
|
|
|
if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_perror( "strdup", NULL );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( value != NULL ) {
|
|
|
|
j = 0;
|
|
|
|
if ( pmods[ i ]->mod_bvalues != NULL ) {
|
|
|
|
for ( ; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (( pmods[ i ]->mod_bvalues =
|
1999-05-29 09:26:12 +08:00
|
|
|
(struct berval **)ber_memrealloc( pmods[ i ]->mod_bvalues,
|
1999-02-15 18:49:20 +08:00
|
|
|
(j + 2) * sizeof( struct berval * ))) == NULL ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_perror( "ber_memrealloc", NULL );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
|
1999-05-29 09:26:12 +08:00
|
|
|
if (( bvp = (struct berval *)ber_memalloc( sizeof( struct berval )))
|
1999-02-15 18:49:20 +08:00
|
|
|
== NULL ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_perror( "ber_memalloc", NULL );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
pmods[ i ]->mod_bvalues[ j ] = bvp;
|
|
|
|
|
|
|
|
bvp->bv_len = vlen;
|
|
|
|
if (( bvp->bv_val = (char *)malloc( vlen + 1 )) == NULL ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_perror( "malloc", NULL );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
2000-07-28 09:07:07 +08:00
|
|
|
AC_MEMCPY( bvp->bv_val, value, vlen );
|
1999-02-15 18:49:20 +08:00
|
|
|
bvp->bv_val[ vlen ] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
get_add_entry( char *filename, LDAPMod ***mods )
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
char *entry = NULL;
|
|
|
|
|
1999-03-04 21:22:06 +08:00
|
|
|
if ( (fp = fopen( filename, "r" )) != NULL ) {
|
1999-02-15 18:49:20 +08:00
|
|
|
char line[BUFSIZ];
|
|
|
|
|
|
|
|
if ( fgets( line, BUFSIZ, fp )) {
|
|
|
|
char *nl;
|
|
|
|
|
|
|
|
if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
|
|
|
|
*nl = '\0';
|
|
|
|
entry = strdup( line );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( fgets( line, BUFSIZ, fp )) {
|
|
|
|
char *nl;
|
|
|
|
char *value;
|
|
|
|
|
|
|
|
if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
|
|
|
|
*nl = '\0';
|
|
|
|
|
|
|
|
if ( *line == '\0' ) break;
|
|
|
|
if ( !( value = strchr( line, ':' ))) break;
|
|
|
|
|
|
|
|
*value++ = '\0';
|
1999-02-23 03:29:42 +08:00
|
|
|
while ( *value && isspace( (unsigned char) *value ))
|
|
|
|
value++;
|
1999-02-15 18:49:20 +08:00
|
|
|
|
|
|
|
addmodifyop( mods, LDAP_MOD_ADD, line, value, strlen( value ));
|
|
|
|
|
|
|
|
}
|
|
|
|
fclose( fp );
|
|
|
|
}
|
|
|
|
|
|
|
|
return( entry );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_addel(
|
2003-02-13 16:02:40 +08:00
|
|
|
char *uri,
|
1999-02-15 18:49:20 +08:00
|
|
|
char *manager,
|
2006-01-12 21:01:38 +08:00
|
|
|
struct berval *passwd,
|
1999-02-15 18:49:20 +08:00
|
|
|
char *entry,
|
|
|
|
LDAPMod **attrs,
|
2005-04-21 00:16:39 +08:00
|
|
|
int maxloop,
|
2005-08-19 15:27:32 +08:00
|
|
|
int maxretries,
|
2005-11-05 00:17:32 +08:00
|
|
|
int delay,
|
2006-03-25 18:13:30 +08:00
|
|
|
int friendly,
|
|
|
|
int chaserefs )
|
1999-02-15 18:49:20 +08:00
|
|
|
{
|
2003-02-13 16:02:40 +08:00
|
|
|
LDAP *ld = NULL;
|
2005-04-21 00:16:39 +08:00
|
|
|
int i = 0, do_retry = maxretries;
|
2004-09-05 02:31:43 +08:00
|
|
|
int rc = LDAP_SUCCESS;
|
2006-01-12 21:01:38 +08:00
|
|
|
int version = LDAP_VERSION3;
|
1999-02-15 18:49:20 +08:00
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
retry:;
|
2006-01-12 21:01:38 +08:00
|
|
|
ldap_initialize( &ld, uri );
|
2003-02-13 16:02:40 +08:00
|
|
|
if ( ld == NULL ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_perror( "ldap_initialize", NULL );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
|
2006-01-12 21:01:38 +08:00
|
|
|
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
2006-03-25 18:13:30 +08:00
|
|
|
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
|
|
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
2001-12-20 13:58:08 +08:00
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
if ( do_retry == maxretries ) {
|
|
|
|
fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
|
|
|
|
(long) pid, maxloop, entry );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
|
2006-01-12 21:01:38 +08:00
|
|
|
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
|
2005-04-21 00:16:39 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
2005-08-17 16:17:30 +08:00
|
|
|
switch ( rc ) {
|
|
|
|
case LDAP_BUSY:
|
|
|
|
case LDAP_UNAVAILABLE:
|
2005-08-19 15:27:32 +08:00
|
|
|
if ( do_retry > 0 ) {
|
|
|
|
do_retry--;
|
|
|
|
if ( delay != 0 ) {
|
|
|
|
sleep( delay );
|
|
|
|
}
|
2005-08-17 16:17:30 +08:00
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
default:
|
|
|
|
break;
|
2005-04-21 00:16:39 +08:00
|
|
|
}
|
|
|
|
exit( EXIT_FAILURE );
|
|
|
|
}
|
1999-02-15 18:49:20 +08:00
|
|
|
|
2005-04-21 00:16:39 +08:00
|
|
|
for ( ; i < maxloop; i++ ) {
|
1999-02-15 18:49:20 +08:00
|
|
|
|
|
|
|
/* add the entry */
|
2006-01-12 21:01:38 +08:00
|
|
|
rc = ldap_add_ext_s( ld, entry, attrs, NULL, NULL );
|
2004-09-05 02:31:43 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_ldap_error( ld, "ldap_add_ext_s", NULL );
|
2005-11-04 22:49:59 +08:00
|
|
|
switch ( rc ) {
|
2005-11-04 23:51:19 +08:00
|
|
|
case LDAP_ALREADY_EXISTS:
|
|
|
|
/* NOTE: this likely means
|
|
|
|
* the delete failed
|
|
|
|
* during the previous round... */
|
2005-11-05 00:17:32 +08:00
|
|
|
if ( !friendly ) {
|
|
|
|
goto done;
|
|
|
|
}
|
2005-11-04 23:51:19 +08:00
|
|
|
break;
|
|
|
|
|
2005-11-04 22:49:59 +08:00
|
|
|
case LDAP_BUSY:
|
|
|
|
case LDAP_UNAVAILABLE:
|
|
|
|
if ( do_retry > 0 ) {
|
|
|
|
do_retry--;
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
/* fall thru */
|
1999-02-15 18:49:20 +08:00
|
|
|
|
2005-11-04 22:49:59 +08:00
|
|
|
default:
|
|
|
|
goto done;
|
|
|
|
}
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
|
2003-12-24 22:03:43 +08:00
|
|
|
#if 0
|
1999-02-15 18:49:20 +08:00
|
|
|
/* wait a second for the add to really complete */
|
2003-12-24 22:03:43 +08:00
|
|
|
/* This masks some race conditions though. */
|
2003-02-22 20:55:05 +08:00
|
|
|
sleep( 1 );
|
2003-12-24 22:03:43 +08:00
|
|
|
#endif
|
1999-02-15 18:49:20 +08:00
|
|
|
|
|
|
|
/* now delete the entry again */
|
2006-01-12 21:01:38 +08:00
|
|
|
rc = ldap_delete_ext_s( ld, entry, NULL, NULL );
|
2004-09-05 02:31:43 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
2006-04-08 19:01:01 +08:00
|
|
|
tester_ldap_error( ld, "ldap_delete_ext_s", NULL );
|
2005-11-04 22:49:59 +08:00
|
|
|
switch ( rc ) {
|
2005-11-04 23:51:19 +08:00
|
|
|
case LDAP_NO_SUCH_OBJECT:
|
|
|
|
/* NOTE: this likely means
|
|
|
|
* the add failed
|
|
|
|
* during the previous round... */
|
2005-11-05 00:17:32 +08:00
|
|
|
if ( !friendly ) {
|
|
|
|
goto done;
|
|
|
|
}
|
2005-11-04 23:51:19 +08:00
|
|
|
break;
|
|
|
|
|
2005-11-04 22:49:59 +08:00
|
|
|
case LDAP_BUSY:
|
|
|
|
case LDAP_UNAVAILABLE:
|
|
|
|
if ( do_retry > 0 ) {
|
|
|
|
do_retry--;
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
/* fall thru */
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto done;
|
2005-04-21 00:16:39 +08:00
|
|
|
}
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-04 22:49:59 +08:00
|
|
|
done:;
|
2004-09-05 02:31:43 +08:00
|
|
|
fprintf( stderr, " PID=%ld - Add/Delete done (%d).\n", (long) pid, rc );
|
1999-02-17 19:13:22 +08:00
|
|
|
|
2006-01-12 21:01:38 +08:00
|
|
|
ldap_unbind_ext( ld, NULL, NULL );
|
1999-02-15 18:49:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|