if ( pmods == NULL || pmods[ i ] == NULL ) {
if (( pmods = (LDAPMod **)realloc( pmods, (i + 2) *
sizeof( LDAPMod * ))) == NULL ) {
- tester_perror( "realloc" );
+ tester_perror( "realloc", NULL );
exit( EXIT_FAILURE );
}
*pmodsp = pmods;
pmods[ i + 1 ] = NULL;
if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod )))
== NULL ) {
- tester_perror( "calloc" );
+ tester_perror( "calloc", NULL );
exit( EXIT_FAILURE );
}
pmods[ i ]->mod_op = modop;
if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) {
- tester_perror( "strdup" );
+ tester_perror( "strdup", NULL );
exit( EXIT_FAILURE );
}
}
if (( pmods[ i ]->mod_bvalues =
(struct berval **)ber_memrealloc( pmods[ i ]->mod_bvalues,
(j + 2) * sizeof( struct berval * ))) == NULL ) {
- tester_perror( "ber_memrealloc" );
+ tester_perror( "ber_memrealloc", NULL );
exit( EXIT_FAILURE );
}
pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
if (( bvp = (struct berval *)ber_memalloc( sizeof( struct berval )))
== NULL ) {
- tester_perror( "ber_memalloc" );
+ tester_perror( "ber_memalloc", NULL );
exit( EXIT_FAILURE );
}
pmods[ i ]->mod_bvalues[ j ] = bvp;
bvp->bv_len = vlen;
if (( bvp->bv_val = (char *)malloc( vlen + 1 )) == NULL ) {
- tester_perror( "malloc" );
+ tester_perror( "malloc", NULL );
exit( EXIT_FAILURE );
}
AC_MEMCPY( bvp->bv_val, value, vlen );
retry:;
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
/* add the entry */
rc = ldap_add_ext_s( ld, entry, attrs, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_add_ext_s" );
+ tester_ldap_error( ld, "ldap_add_ext_s", NULL );
switch ( rc ) {
case LDAP_ALREADY_EXISTS:
/* NOTE: this likely means
/* now delete the entry again */
rc = ldap_delete_ext_s( ld, entry, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_delete_ext_s" );
+ tester_ldap_error( ld, "ldap_delete_ext_s", NULL );
switch ( rc ) {
case LDAP_NO_SUCH_OBJECT:
/* NOTE: this likely means
int version = LDAP_VERSION3;
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
rc = -1;
break;
}
/* fallthru */
default:
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
}
if ( !noinit ) {
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, NULL, LDAP_SASL_SIMPLE, &pw, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_search_ext( ld, base->bv_val, LDAP_SCOPE_ONE,
filter, attrs, 0, NULL, NULL, 0, 0, &msgid );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_search_ext" );
+ tester_ldap_error( ld, "ldap_search_ext", NULL );
exit( EXIT_FAILURE );
}
}
void
-tester_ldap_error( LDAP *ld, const char *fname )
+tester_ldap_error( LDAP *ld, const char *fname, const char *msg )
{
int err;
char *text = NULL;
ldap_get_option( ld, LDAP_OPT_ERROR_STRING, (void *)&text );
}
- fprintf( stderr, "%s: %s: %s (%d) %s\n",
+ fprintf( stderr, "%s: %s: %s (%d) %s %s\n",
progname, fname, ldap_err2string( err ), err,
- text == NULL ? "" : text );
+ text == NULL ? "" : text,
+ msg ? msg : "" );
if ( text ) {
ldap_memfree( text );
}
void
-tester_perror( const char *fname )
+tester_perror( const char *fname, const char *msg )
{
int save_errno = errno;
char buf[ BUFSIZ ];
- fprintf( stderr, "%s: %s: (%d) %s\n",
+ fprintf( stderr, "%s: %s: (%d) %s %s\n",
progname, fname, save_errno,
- AC_STRERROR_R( save_errno, buf, sizeof( buf ) ) );
+ AC_STRERROR_R( save_errno, buf, sizeof( buf ) ),
+ msg ? msg : "" );
}
void
extern void tester_init( const char *pname );
extern char * tester_uri( char *uri, char *host, int port );
extern void tester_error( const char *msg );
-extern void tester_perror( const char *fname );
-extern void tester_ldap_error( LDAP *ld, const char *fname );
+extern void tester_perror( const char *fname, const char *msg );
+extern void tester_ldap_error( LDAP *ld, const char *fname, const char *msg );
#endif /* SLAPD_COMMON_H */
retry:;
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
mod.mod_op = LDAP_MOD_ADD;
rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_modify_ext_s" );
+ tester_ldap_error( ld, "ldap_modify_ext_s", NULL );
switch ( rc ) {
case LDAP_TYPE_OR_VALUE_EXISTS:
/* NOTE: this likely means
mod.mod_op = LDAP_MOD_DELETE;
rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_modify_ext_s" );
+ tester_ldap_error( ld, "ldap_modify_ext_s", NULL );
switch ( rc ) {
case LDAP_NO_SUCH_ATTRIBUTE:
/* NOTE: this likely means
retry:;
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
for ( ; i < maxloop; i++ ) {
rc = ldap_rename_s( ld, DNs[0], rdns[0], NULL, 0, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_rename_s" );
+ tester_ldap_error( ld, "ldap_rename_s", NULL );
switch ( rc ) {
case LDAP_NO_SUCH_OBJECT:
/* NOTE: this likely means
}
rc = ldap_rename_s( ld, DNs[1], rdns[1], NULL, 1, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_rename_s" );
+ tester_ldap_error( ld, "ldap_rename_s", NULL );
switch ( rc ) {
case LDAP_NO_SUCH_OBJECT:
/* NOTE: this likely means
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
nvalues = ldap_count_entries( ld, res );
if ( nvalues == 0 ) {
if ( rc ) {
- tester_ldap_error( ld, "ldap_search_ext_s" );
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
}
break;
}
break;
default:
- tester_ldap_error( ld, "ldap_search_ext_s" );
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
break;
}
if ( ld == NULL ) {
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
}
first = 0;
}
- tester_ldap_error( ld, "ldap_search_ext_s" );
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
/* fallthru */
case LDAP_SUCCESS:
break;
default:
- tester_ldap_error( ld, "ldap_search_ext_s" );
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
case LDAP_SUCCESS:
if ( ldap_count_entries( ld, res ) == 0 ) {
if ( rc ) {
- tester_ldap_error( ld, "ldap_search_ext_s" );
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
}
break;
}
break;
default:
- tester_ldap_error( ld, "ldap_search_ext_s" );
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
break;
}
int rc = LDAP_SUCCESS;
int version = LDAP_VERSION3;
int first = 1;
+ char buf[ BUFSIZ ];
+
retry:;
if ( ld == NULL ) {
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- tester_perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize", NULL );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- tester_ldap_error( ld, "ldap_sasl_bind_s" );
+ snprintf( buf, sizeof( buf ),
+ "bindDN=\"%s\"", manager );
+ tester_ldap_error( ld, "ldap_sasl_bind_s", buf );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
}
first = 0;
}
- tester_ldap_error( ld, "ldap_search_ext_s" );
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
/* fallthru */
case LDAP_SUCCESS:
break;
default:
- tester_ldap_error( ld, "ldap_search_ext_s" );
+ snprintf( buf, sizeof( buf ),
+ "base=\"%s\" filter=\"%s\"\n",
+ sbase, filter );
+ tester_ldap_error( ld, "ldap_search_ext_s", buf );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
ldap_unbind_ext( ld, NULL, NULL );
do_retry--;
args = arg2; }
#endif
execvp( prog, args );
- tester_perror( "execvp" );
+ tester_perror( "execvp", NULL );
exit( EXIT_FAILURE );
break;
case -1: /* trouble */
- tester_perror( "fork" );
+ tester_perror( "fork", NULL );
break;
default: /* parent */
rc = _spawnvp( _P_NOWAIT, prog, args );
if ( rc == -1 ) {
- tester_perror( "_spawnvp" );
+ tester_perror( "_spawnvp", NULL );
} else {
children[nkids++] = (HANDLE)rc;
}