mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
ITS#8798 Unify slapd-* tools setup
This commit is contained in:
parent
52f7daab01
commit
412479e6fe
9 changed files with 482 additions and 1079 deletions
|
|
@ -35,34 +35,25 @@
|
||||||
|
|
||||||
#include "slapd-common.h"
|
#include "slapd-common.h"
|
||||||
|
|
||||||
#define LOOPS 100
|
|
||||||
#define RETRIES 0
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_add_entry( char *filename, LDAPMod ***mods );
|
get_add_entry( char *filename, LDAPMod ***mods );
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_addel( char *uri, char *manager, struct berval *passwd,
|
do_addel( struct tester_conn_args *config,
|
||||||
char *dn, LDAPMod **attrs, int maxloop, int maxretries, int delay,
|
char *dn, LDAPMod **attrs, int friendly );
|
||||||
int friendly, int chaserefs );
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage( char *name )
|
usage( char *name, char opt )
|
||||||
{
|
{
|
||||||
fprintf( stderr,
|
if ( opt ) {
|
||||||
"usage: %s "
|
fprintf( stderr, "%s: unable to handle option \'%c\'\n\n",
|
||||||
"-H <uri> | ([-h <host>] -p <port>) "
|
name, opt );
|
||||||
"-D <manager> "
|
}
|
||||||
"-w <passwd> "
|
|
||||||
|
fprintf( stderr, "usage: %s " TESTER_COMMON_HELP
|
||||||
"-f <addfile> "
|
"-f <addfile> "
|
||||||
"[-i <ignore>] "
|
"[-F]\n",
|
||||||
"[-l <loops>] "
|
name );
|
||||||
"[-L <outerloops>] "
|
|
||||||
"[-r <maxretries>] "
|
|
||||||
"[-t <delay>] "
|
|
||||||
"[-F] "
|
|
||||||
"[-C]\n",
|
|
||||||
name );
|
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,99 +61,40 @@ int
|
||||||
main( int argc, char **argv )
|
main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *host = "localhost";
|
|
||||||
char *uri = NULL;
|
|
||||||
int port = -1;
|
|
||||||
char *manager = NULL;
|
|
||||||
struct berval passwd = { 0, NULL };
|
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
char *entry = NULL;
|
char *entry = NULL;
|
||||||
int loops = LOOPS;
|
|
||||||
int outerloops = 1;
|
|
||||||
int retries = RETRIES;
|
|
||||||
int delay = 0;
|
|
||||||
int friendly = 0;
|
int friendly = 0;
|
||||||
int chaserefs = 0;
|
|
||||||
LDAPMod **attrs = NULL;
|
LDAPMod **attrs = NULL;
|
||||||
|
struct tester_conn_args *config;
|
||||||
|
|
||||||
tester_init( "slapd-addel", TESTER_ADDEL );
|
config = tester_init( "slapd-addel", TESTER_ADDEL );
|
||||||
|
|
||||||
while ( ( i = getopt( argc, argv, "CD:Ff:H:h:i:L:l:p:r:t:w:" ) ) != EOF )
|
while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "Ff:" ) ) != EOF )
|
||||||
{
|
{
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 'C':
|
|
||||||
chaserefs++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'F':
|
case 'F':
|
||||||
friendly++;
|
friendly++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'H': /* the server's URI */
|
|
||||||
uri = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h': /* the servers host */
|
|
||||||
host = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
/* ignored (!) by now */
|
/* ignored (!) by now */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p': /* the servers port */
|
|
||||||
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D': /* the servers manager */
|
|
||||||
manager = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w': /* the server managers password */
|
|
||||||
passwd.bv_val = strdup( optarg );
|
|
||||||
passwd.bv_len = strlen( optarg );
|
|
||||||
memset( optarg, '*', passwd.bv_len );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f': /* file with entry search request */
|
case 'f': /* file with entry search request */
|
||||||
filename = strdup( optarg );
|
filename = strdup( optarg );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l': /* the number of loops */
|
|
||||||
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L': /* the number of outerloops */
|
|
||||||
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r': /* number of retries */
|
|
||||||
if ( lutil_atoi( &retries, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't': /* delay in seconds */
|
|
||||||
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage( argv[0] );
|
if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
usage( argv[0], i );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( filename == NULL ) || ( port == -1 && uri == NULL ) ||
|
if ( filename == NULL )
|
||||||
( manager == NULL ) || ( passwd.bv_val == NULL ))
|
usage( argv[0], 0 );
|
||||||
usage( argv[0] );
|
|
||||||
|
|
||||||
entry = get_add_entry( filename, &attrs );
|
entry = get_add_entry( filename, &attrs );
|
||||||
if (( entry == NULL ) || ( *entry == '\0' )) {
|
if (( entry == NULL ) || ( *entry == '\0' )) {
|
||||||
|
|
@ -181,11 +113,10 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = tester_uri( uri, host, port );
|
tester_config_finish( config );
|
||||||
|
|
||||||
for ( i = 0; i < outerloops; i++ ) {
|
for ( i = 0; i < config->outerloops; i++ ) {
|
||||||
do_addel( uri, manager, &passwd, entry, attrs,
|
do_addel( config, entry, attrs, friendly );
|
||||||
loops, retries, delay, friendly, chaserefs );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit( EXIT_SUCCESS );
|
exit( EXIT_SUCCESS );
|
||||||
|
|
@ -311,59 +242,26 @@ get_add_entry( char *filename, LDAPMod ***mods )
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_addel(
|
do_addel(
|
||||||
char *uri,
|
struct tester_conn_args *config,
|
||||||
char *manager,
|
|
||||||
struct berval *passwd,
|
|
||||||
char *entry,
|
char *entry,
|
||||||
LDAPMod **attrs,
|
LDAPMod **attrs,
|
||||||
int maxloop,
|
int friendly )
|
||||||
int maxretries,
|
|
||||||
int delay,
|
|
||||||
int friendly,
|
|
||||||
int chaserefs )
|
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
|
|
||||||
retry:;
|
retry:;
|
||||||
ldap_initialize( &ld, uri );
|
|
||||||
if ( ld == NULL ) {
|
if ( ld == NULL ) {
|
||||||
tester_perror( "ldap_initialize", NULL );
|
tester_init_ld( &ld, config, 0 );
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
if ( do_retry == config->retries ) {
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
|
||||||
fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
|
fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
|
||||||
(long) pid, maxloop, entry );
|
(long) pid, config->loops, entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
|
for ( ; i < config->loops; i++ ) {
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
|
||||||
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
|
||||||
switch ( rc ) {
|
|
||||||
case LDAP_BUSY:
|
|
||||||
case LDAP_UNAVAILABLE:
|
|
||||||
if ( do_retry > 0 ) {
|
|
||||||
do_retry--;
|
|
||||||
if ( delay != 0 ) {
|
|
||||||
sleep( delay );
|
|
||||||
}
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
/* fallthru */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( ; i < maxloop; i++ ) {
|
|
||||||
|
|
||||||
/* add the entry */
|
/* add the entry */
|
||||||
rc = ldap_add_ext_s( ld, entry, attrs, NULL, NULL );
|
rc = ldap_add_ext_s( ld, entry, attrs, NULL, NULL );
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,13 @@
|
||||||
|
|
||||||
#include "slapd-common.h"
|
#include "slapd-common.h"
|
||||||
|
|
||||||
#define LOOPS 100
|
static int
|
||||||
|
do_bind( struct tester_conn_args *config, char *dn, int maxloop,
|
||||||
|
int force, int noinit, LDAP **ldp, int action_type, void *action );
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_bind( char *uri, char *dn, struct berval *pass, int maxloop,
|
do_base( struct tester_conn_args *config, char *dn, char *base, char *filter, char *pwattr,
|
||||||
int force, int chaserefs, int noinit, LDAP **ldp,
|
int force, int noinit, int action_type, void *action );
|
||||||
int action_type, void *action );
|
|
||||||
|
|
||||||
static int
|
|
||||||
do_base( char *uri, char *dn, struct berval *pass, char *base, char *filter, char *pwattr,
|
|
||||||
int maxloop, int force, int chaserefs, int noinit, int delay,
|
|
||||||
int action_type, void *action );
|
|
||||||
|
|
||||||
/* This program can be invoked two ways: if -D is used to specify a Bind DN,
|
/* This program can be invoked two ways: if -D is used to specify a Bind DN,
|
||||||
* that DN will be used repeatedly for all of the Binds. If instead -b is used
|
* that DN will be used repeatedly for all of the Binds. If instead -b is used
|
||||||
|
|
@ -66,18 +62,11 @@ usage( char *name, char opt )
|
||||||
name, opt );
|
name, opt );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( stderr, "usage: %s "
|
fprintf( stderr, "usage: %s " TESTER_COMMON_HELP
|
||||||
"[-H uri | -h <host> [-p port]] "
|
|
||||||
"[-D <dn> [-w <passwd>]] "
|
|
||||||
"[-b <baseDN> [-f <searchfilter>] [-a pwattr]] "
|
"[-b <baseDN> [-f <searchfilter>] [-a pwattr]] "
|
||||||
"[-l <loops>] "
|
|
||||||
"[-L <outerloops>] "
|
|
||||||
"[-B <extra>[,...]] "
|
"[-B <extra>[,...]] "
|
||||||
"[-F] "
|
"[-F] "
|
||||||
"[-C] "
|
"[-I]\n",
|
||||||
"[-I] "
|
|
||||||
"[-i <ignore>] "
|
|
||||||
"[-t delay]\n",
|
|
||||||
name );
|
name );
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
@ -86,20 +75,12 @@ int
|
||||||
main( int argc, char **argv )
|
main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *uri = NULL;
|
|
||||||
char *host = "localhost";
|
|
||||||
char *dn = NULL;
|
|
||||||
char *base = NULL;
|
char *base = NULL;
|
||||||
char *filter = "(objectClass=person)";
|
char *filter = "(objectClass=person)";
|
||||||
struct berval pass = { 0, NULL };
|
|
||||||
char *pwattr = NULL;
|
char *pwattr = NULL;
|
||||||
int port = -1;
|
|
||||||
int loops = LOOPS;
|
|
||||||
int outerloops = 1;
|
|
||||||
int force = 0;
|
int force = 0;
|
||||||
int chaserefs = 0;
|
|
||||||
int noinit = 1;
|
int noinit = 1;
|
||||||
int delay = 0;
|
struct tester_conn_args *config;
|
||||||
|
|
||||||
/* extra action to do after bind... */
|
/* extra action to do after bind... */
|
||||||
struct berval type[] = {
|
struct berval type[] = {
|
||||||
|
|
@ -115,12 +96,12 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
LDAPURLDesc *extra_ludp = NULL;
|
LDAPURLDesc *extra_ludp = NULL;
|
||||||
|
|
||||||
tester_init( "slapd-bind", TESTER_BIND );
|
config = tester_init( "slapd-bind", TESTER_BIND );
|
||||||
|
|
||||||
/* by default, tolerate invalid credentials */
|
/* by default, tolerate invalid credentials */
|
||||||
tester_ignore_str2errlist( "INVALID_CREDENTIALS" );
|
tester_ignore_str2errlist( "INVALID_CREDENTIALS" );
|
||||||
|
|
||||||
while ( ( i = getopt( argc, argv, "a:B:b:D:Ff:H:h:Ii:L:l:p:t:w:" ) ) != EOF )
|
while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "a:B:b:Ff:I" ) ) != EOF )
|
||||||
{
|
{
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 'a':
|
case 'a':
|
||||||
|
|
@ -173,49 +154,6 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 'C':
|
|
||||||
chaserefs++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'H': /* the server uri */
|
|
||||||
uri = optarg;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h': /* the servers host */
|
|
||||||
host = optarg;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
|
||||||
tester_ignore_str2errlist( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'p': /* the servers port */
|
|
||||||
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], 'p' );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D':
|
|
||||||
dn = optarg;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w':
|
|
||||||
ber_str2bv( optarg, 0, 1, &pass );
|
|
||||||
memset( optarg, '*', pass.bv_len );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'l': /* the number of loops */
|
|
||||||
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], 'l' );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L': /* the number of outerloops */
|
|
||||||
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], 'L' );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
filter = optarg;
|
filter = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
@ -229,34 +167,26 @@ main( int argc, char **argv )
|
||||||
noinit = 0;
|
noinit = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
|
||||||
/* sleep between binds */
|
|
||||||
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], 't' );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
usage( argv[0], i );
|
usage( argv[0], i );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( port == -1 && uri == NULL ) {
|
tester_config_finish( config );
|
||||||
usage( argv[0], '\0' );
|
|
||||||
}
|
|
||||||
|
|
||||||
uri = tester_uri( uri, host, port );
|
for ( i = 0; i < config->outerloops; i++ ) {
|
||||||
|
|
||||||
for ( i = 0; i < outerloops; i++ ) {
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ( base != NULL ) {
|
if ( base != NULL ) {
|
||||||
rc = do_base( uri, dn, &pass, base, filter, pwattr, loops,
|
rc = do_base( config, config->binddn, base,
|
||||||
force, chaserefs, noinit, delay, -1, NULL );
|
filter, pwattr, force, noinit, -1, NULL );
|
||||||
} else {
|
} else {
|
||||||
rc = do_bind( uri, dn, &pass, loops,
|
rc = do_bind( config, config->binddn,
|
||||||
force, chaserefs, noinit, NULL, -1, NULL );
|
config->loops, force, noinit, NULL, -1, NULL );
|
||||||
}
|
}
|
||||||
if ( rc == LDAP_SERVER_DOWN )
|
if ( rc == LDAP_SERVER_DOWN )
|
||||||
break;
|
break;
|
||||||
|
|
@ -267,9 +197,8 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_bind( char *uri, char *dn, struct berval *pass, int maxloop,
|
do_bind( struct tester_conn_args *config, char *dn, int maxloop,
|
||||||
int force, int chaserefs, int noinit, LDAP **ldp,
|
int force, int noinit, LDAP **ldp, int action_type, void *action )
|
||||||
int action_type, void *action )
|
|
||||||
{
|
{
|
||||||
LDAP *ld = ldp ? *ldp : NULL;
|
LDAP *ld = ldp ? *ldp : NULL;
|
||||||
int i, rc = -1;
|
int i, rc = -1;
|
||||||
|
|
@ -327,21 +256,10 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop,
|
||||||
|
|
||||||
for ( i = 0; i < maxloop; i++ ) {
|
for ( i = 0; i < maxloop; i++ ) {
|
||||||
if ( !noinit || ld == NULL ) {
|
if ( !noinit || ld == NULL ) {
|
||||||
int version = LDAP_VERSION3;
|
tester_init_ld( &ld, config, TESTER_INIT_ONLY );
|
||||||
ldap_initialize( &ld, uri );
|
|
||||||
if ( ld == NULL ) {
|
|
||||||
tester_perror( "ldap_initialize", NULL );
|
|
||||||
rc = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION,
|
|
||||||
&version );
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL );
|
rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &config->pass, NULL, NULL, NULL );
|
||||||
if ( rc ) {
|
if ( rc ) {
|
||||||
int first = tester_ignore_err( rc );
|
int first = tester_ignore_err( rc );
|
||||||
|
|
||||||
|
|
@ -413,9 +331,8 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop,
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_base( char *uri, char *dn, struct berval *pass, char *base, char *filter, char *pwattr,
|
do_base( struct tester_conn_args *config, char *dn, char *base, char *filter, char *pwattr,
|
||||||
int maxloop, int force, int chaserefs, int noinit, int delay,
|
int force, int noinit, int action_type, void *action )
|
||||||
int action_type, void *action )
|
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
@ -431,27 +348,12 @@ do_base( char *uri, char *dn, struct berval *pass, char *base, char *filter, cha
|
||||||
#else
|
#else
|
||||||
struct timeval beg, end;
|
struct timeval beg, end;
|
||||||
#endif
|
#endif
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
char *nullstr = "";
|
char *nullstr = "";
|
||||||
|
|
||||||
ldap_initialize( &ld, uri );
|
tester_init_ld( &ld, config, 0 );
|
||||||
if ( ld == NULL ) {
|
|
||||||
tester_perror( "ldap_initialize", NULL );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF );
|
|
||||||
|
|
||||||
rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL );
|
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
|
||||||
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf( stderr, "PID=%ld - Bind(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n",
|
fprintf( stderr, "PID=%ld - Bind(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n",
|
||||||
(long) pid, maxloop, base, filter, pwattr );
|
(long) pid, config->loops, base, filter, pwattr );
|
||||||
|
|
||||||
if ( pwattr != NULL ) {
|
if ( pwattr != NULL ) {
|
||||||
attrs[ 0 ] = pwattr;
|
attrs[ 0 ] = pwattr;
|
||||||
|
|
@ -540,10 +442,8 @@ novals:;
|
||||||
(long) pid, base, filter, ndns );
|
(long) pid, base, filter, ndns );
|
||||||
|
|
||||||
/* Ok, got list of DNs, now start binding to each */
|
/* Ok, got list of DNs, now start binding to each */
|
||||||
for ( i = 0; i < maxloop; i++ ) {
|
for ( i = 0; i < config->loops; i++ ) {
|
||||||
int j;
|
int j;
|
||||||
struct berval cred = { 0, NULL };
|
|
||||||
|
|
||||||
|
|
||||||
#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
|
#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
|
||||||
j = rand() % ndns;
|
j = rand() % ndns;
|
||||||
|
|
@ -551,17 +451,17 @@ novals:;
|
||||||
j = ((double)ndns)*rand()/(RAND_MAX + 1.0);
|
j = ((double)ndns)*rand()/(RAND_MAX + 1.0);
|
||||||
|
|
||||||
if ( creds && !BER_BVISEMPTY( &creds[j] ) ) {
|
if ( creds && !BER_BVISEMPTY( &creds[j] ) ) {
|
||||||
cred = creds[j];
|
config->pass = creds[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( do_bind( uri, dns[j], &cred, 1, force, chaserefs, noinit, &ld,
|
if ( do_bind( config, dns[j], 1, force, noinit, &ld,
|
||||||
action_type, action ) && !force )
|
action_type, action ) && !force )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( delay ) {
|
if ( config->delay ) {
|
||||||
sleep( delay );
|
sleep( config->delay );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "ldap.h"
|
#include "ldap.h"
|
||||||
|
|
||||||
|
#include "lutil.h"
|
||||||
#include "ldap_pvt.h"
|
#include "ldap_pvt.h"
|
||||||
#include "slapd-common.h"
|
#include "slapd-common.h"
|
||||||
|
|
||||||
|
|
@ -127,6 +128,9 @@ static const struct {
|
||||||
|
|
||||||
#define UNKNOWN_ERR (1234567890)
|
#define UNKNOWN_ERR (1234567890)
|
||||||
|
|
||||||
|
#define RETRIES 0
|
||||||
|
#define LOOPS 100
|
||||||
|
|
||||||
static int
|
static int
|
||||||
tester_ignore_str2err( const char *err )
|
tester_ignore_str2err( const char *err )
|
||||||
{
|
{
|
||||||
|
|
@ -197,27 +201,26 @@ tester_ignore_err( int err )
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
struct tester_conn_args *
|
||||||
tester_init( const char *pname, tester_t ptype )
|
tester_init( const char *pname, tester_t ptype )
|
||||||
{
|
{
|
||||||
|
static struct tester_conn_args config = {
|
||||||
|
.authmethod = -1,
|
||||||
|
.retries = RETRIES,
|
||||||
|
.loops = LOOPS,
|
||||||
|
.outerloops = 1,
|
||||||
|
|
||||||
|
.uri = NULL,
|
||||||
|
.host = "localhost",
|
||||||
|
.port = 389,
|
||||||
|
};
|
||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
srand( pid );
|
srand( pid );
|
||||||
snprintf( progname, sizeof( progname ), "%s PID=%d", pname, pid );
|
snprintf( progname, sizeof( progname ), "%s PID=%d", pname, pid );
|
||||||
progtype = ptype;
|
progtype = ptype;
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
return &config;
|
||||||
tester_uri( char *uri, char *host, int port )
|
|
||||||
{
|
|
||||||
static char uribuf[ BUFSIZ ];
|
|
||||||
|
|
||||||
if ( uri != NULL ) {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf( uribuf, sizeof( uribuf ), "ldap://%s:%d", host, port );
|
|
||||||
|
|
||||||
return uribuf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -293,6 +296,163 @@ tester_perror( const char *fname, const char *msg )
|
||||||
msg ? msg : "" );
|
msg ? msg : "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
tester_config_opt( struct tester_conn_args *config, char opt, char *optarg )
|
||||||
|
{
|
||||||
|
switch ( opt ) {
|
||||||
|
case 'C':
|
||||||
|
config->chaserefs++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'D':
|
||||||
|
config->binddn = strdup( optarg );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
{
|
||||||
|
int debug;
|
||||||
|
if ( lutil_atoi( &debug, optarg ) != 0 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug )
|
||||||
|
!= LBER_OPT_SUCCESS )
|
||||||
|
{
|
||||||
|
fprintf( stderr,
|
||||||
|
"Could not set LBER_OPT_DEBUG_LEVEL %d\n", debug );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug )
|
||||||
|
!= LDAP_OPT_SUCCESS )
|
||||||
|
{
|
||||||
|
fprintf( stderr,
|
||||||
|
"Could not set LDAP_OPT_DEBUG_LEVEL %d\n", debug );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'H':
|
||||||
|
config->uri = strdup( optarg );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
config->host = strdup( optarg );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'i':
|
||||||
|
tester_ignore_str2errlist( optarg );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
if ( lutil_atoi( &config->outerloops, optarg ) != 0 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
if ( lutil_atoi( &config->loops, optarg ) != 0 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'p':
|
||||||
|
if ( lutil_atoi( &config->port, optarg ) != 0 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'r':
|
||||||
|
if ( lutil_atoi( &config->retries, optarg ) != 0 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 't':
|
||||||
|
if ( lutil_atoi( &config->delay, optarg ) != 0 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
config->pass.bv_val = strdup( optarg );
|
||||||
|
config->pass.bv_len = strlen( optarg );
|
||||||
|
memset( optarg, '*', config->pass.bv_len );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
if ( config->authmethod != -1 && config->authmethod != LDAP_AUTH_SIMPLE ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
config->authmethod = LDAP_AUTH_SIMPLE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LDAP_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tester_config_finish( struct tester_conn_args *config )
|
||||||
|
{
|
||||||
|
if ( !config->uri ) {
|
||||||
|
static char uribuf[ BUFSIZ ];
|
||||||
|
|
||||||
|
config->uri = uribuf;
|
||||||
|
snprintf( uribuf, sizeof( uribuf ), "ldap://%s:%d",
|
||||||
|
config->host, config->port );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( config->authmethod == -1 ) {
|
||||||
|
config->authmethod = LDAP_AUTH_SIMPLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tester_init_ld( LDAP **ldp, struct tester_conn_args *config, int flags )
|
||||||
|
{
|
||||||
|
LDAP *ld;
|
||||||
|
int rc, do_retry = config->retries;
|
||||||
|
int version = LDAP_VERSION3;
|
||||||
|
|
||||||
|
retry:;
|
||||||
|
ldap_initialize( &ld, config->uri );
|
||||||
|
if ( ld == NULL ) {
|
||||||
|
tester_perror( "ldap_initialize", NULL );
|
||||||
|
exit( EXIT_FAILURE );
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
||||||
|
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
||||||
|
config->chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF );
|
||||||
|
|
||||||
|
if ( !( flags & TESTER_INIT_ONLY ) ) {
|
||||||
|
rc = ldap_sasl_bind_s( ld,
|
||||||
|
config->binddn, LDAP_SASL_SIMPLE,
|
||||||
|
&config->pass, NULL, NULL, NULL );
|
||||||
|
|
||||||
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
|
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
||||||
|
switch ( rc ) {
|
||||||
|
case LDAP_BUSY:
|
||||||
|
case LDAP_UNAVAILABLE:
|
||||||
|
if ( do_retry > 0 ) {
|
||||||
|
do_retry--;
|
||||||
|
if ( config->delay > 0 ) {
|
||||||
|
sleep( config->delay );
|
||||||
|
}
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
||||||
|
exit( EXIT_FAILURE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*ldp = ld;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tester_error( const char *msg )
|
tester_error( const char *msg )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ typedef enum {
|
||||||
TESTER_LAST
|
TESTER_LAST
|
||||||
} tester_t;
|
} tester_t;
|
||||||
|
|
||||||
extern void tester_init( const char *pname, tester_t ptype );
|
extern struct tester_conn_args * tester_init( const char *pname, tester_t ptype );
|
||||||
extern char * tester_uri( char *uri, char *host, int port );
|
extern char * tester_uri( char *uri, char *host, int port );
|
||||||
extern void tester_error( const char *msg );
|
extern void tester_error( const char *msg );
|
||||||
extern void tester_perror( const char *fname, const char *msg );
|
extern void tester_perror( const char *fname, const char *msg );
|
||||||
|
|
@ -39,6 +39,41 @@ extern void tester_ldap_error( LDAP *ld, const char *fname, const char *msg );
|
||||||
extern int tester_ignore_str2errlist( const char *err );
|
extern int tester_ignore_str2errlist( const char *err );
|
||||||
extern int tester_ignore_err( int err );
|
extern int tester_ignore_err( int err );
|
||||||
|
|
||||||
|
struct tester_conn_args {
|
||||||
|
char *uri, *host;
|
||||||
|
int port;
|
||||||
|
|
||||||
|
int outerloops;
|
||||||
|
int loops;
|
||||||
|
int retries;
|
||||||
|
int delay;
|
||||||
|
|
||||||
|
int chaserefs;
|
||||||
|
|
||||||
|
int authmethod;
|
||||||
|
|
||||||
|
char *binddn;
|
||||||
|
struct berval pass;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define TESTER_INIT_ONLY (1 << 0)
|
||||||
|
#define TESTER_COMMON_OPTS "CD:d:H:h:L:l:i:p:r:t:w:x"
|
||||||
|
#define TESTER_COMMON_HELP \
|
||||||
|
"[-C] " \
|
||||||
|
"[-D <dn> [-w <passwd>]] " \
|
||||||
|
"[-d <level>] " \
|
||||||
|
"[-H uri | -h <host> [-p port]] " \
|
||||||
|
"[-i <ignore>] " \
|
||||||
|
"[-l <loops>] " \
|
||||||
|
"[-L <outerloops>] " \
|
||||||
|
"[-r <maxretries>] " \
|
||||||
|
"[-t <delay>] " \
|
||||||
|
"[-x] "
|
||||||
|
|
||||||
|
extern int tester_config_opt( struct tester_conn_args *config, char opt, char *optarg );
|
||||||
|
extern void tester_config_finish( struct tester_conn_args *config );
|
||||||
|
extern void tester_init_ld( LDAP **ldp, struct tester_conn_args *conf, int flags );
|
||||||
|
|
||||||
extern pid_t pid;
|
extern pid_t pid;
|
||||||
|
|
||||||
#endif /* SLAPD_COMMON_H */
|
#endif /* SLAPD_COMMON_H */
|
||||||
|
|
|
||||||
|
|
@ -32,31 +32,25 @@
|
||||||
#include "slapd-common.h"
|
#include "slapd-common.h"
|
||||||
|
|
||||||
#define LOOPS 100
|
#define LOOPS 100
|
||||||
#define RETRIES 0
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_modify( char *uri, char *manager, struct berval *passwd,
|
do_modify( struct tester_conn_args *config, char *entry,
|
||||||
char *entry, char *attr, char *value, int maxloop,
|
char *attr, char *value, int friendly );
|
||||||
int maxretries, int delay, int friendly, int chaserefs );
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage( char *name )
|
usage( char *name, int opt )
|
||||||
{
|
{
|
||||||
fprintf( stderr,
|
if ( opt ) {
|
||||||
"usage: %s "
|
fprintf( stderr, "%s: unable to handle option \'%c\'\n\n",
|
||||||
"-H <uri> | ([-h <host>] -p <port>) "
|
name, opt );
|
||||||
"-D <manager> "
|
}
|
||||||
"-w <passwd> "
|
|
||||||
|
fprintf( stderr, "usage: %s " TESTER_COMMON_HELP
|
||||||
|
"-a <attr:val> "
|
||||||
"-e <entry> "
|
"-e <entry> "
|
||||||
"[-i <ignore>] "
|
"[-F]\n",
|
||||||
"[-l <loops>] "
|
name );
|
||||||
"[-L <outerloops>] "
|
|
||||||
"[-r <maxretries>] "
|
|
||||||
"[-t <delay>] "
|
|
||||||
"[-F] "
|
|
||||||
"[-C]\n",
|
|
||||||
name );
|
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,62 +58,25 @@ int
|
||||||
main( int argc, char **argv )
|
main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *uri = NULL;
|
|
||||||
char *host = "localhost";
|
|
||||||
int port = -1;
|
|
||||||
char *manager = NULL;
|
|
||||||
struct berval passwd = { 0, NULL };
|
|
||||||
char *entry = NULL;
|
char *entry = NULL;
|
||||||
char *ava = NULL;
|
char *ava = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int loops = LOOPS;
|
|
||||||
int outerloops = 1;
|
|
||||||
int retries = RETRIES;
|
|
||||||
int delay = 0;
|
|
||||||
int friendly = 0;
|
int friendly = 0;
|
||||||
int chaserefs = 0;
|
struct tester_conn_args *config;
|
||||||
|
|
||||||
tester_init( "slapd-modify", TESTER_MODIFY );
|
config = tester_init( "slapd-modify", TESTER_MODIFY );
|
||||||
|
|
||||||
while ( ( i = getopt( argc, argv, "a:CD:e:FH:h:i:L:l:p:r:t:w:" ) ) != EOF )
|
while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "a:e:F" ) ) != EOF )
|
||||||
{
|
{
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 'C':
|
|
||||||
chaserefs++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'F':
|
case 'F':
|
||||||
friendly++;
|
friendly++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'H': /* the server uri */
|
|
||||||
uri = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h': /* the servers host */
|
|
||||||
host = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
/* ignored (!) by now */
|
/* ignored (!) by now */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p': /* the servers port */
|
|
||||||
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D': /* the servers manager */
|
|
||||||
manager = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w': /* the server managers password */
|
|
||||||
passwd.bv_val = strdup( optarg );
|
|
||||||
passwd.bv_len = strlen( optarg );
|
|
||||||
memset( optarg, '*', passwd.bv_len );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'e': /* entry to modify */
|
case 'e': /* entry to modify */
|
||||||
entry = strdup( optarg );
|
entry = strdup( optarg );
|
||||||
break;
|
break;
|
||||||
|
|
@ -128,38 +85,17 @@ main( int argc, char **argv )
|
||||||
ava = strdup( optarg );
|
ava = strdup( optarg );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l': /* the number of loops */
|
|
||||||
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L': /* the number of outerloops */
|
|
||||||
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r': /* number of retries */
|
|
||||||
if ( lutil_atoi( &retries, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't': /* delay in seconds */
|
|
||||||
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage( argv[0] );
|
if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
usage( argv[0], i );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( entry == NULL ) || ( ava == NULL ) || ( port == -1 && uri == NULL ))
|
if (( entry == NULL ) || ( ava == NULL ))
|
||||||
usage( argv[0] );
|
usage( argv[0], 0 );
|
||||||
|
|
||||||
if ( *entry == '\0' ) {
|
if ( *entry == '\0' ) {
|
||||||
|
|
||||||
|
|
@ -183,11 +119,10 @@ main( int argc, char **argv )
|
||||||
while ( *value && isspace( (unsigned char) *value ))
|
while ( *value && isspace( (unsigned char) *value ))
|
||||||
value++;
|
value++;
|
||||||
|
|
||||||
uri = tester_uri( uri, host, port );
|
tester_config_finish( config );
|
||||||
|
|
||||||
for ( i = 0; i < outerloops; i++ ) {
|
for ( i = 0; i < config->outerloops; i++ ) {
|
||||||
do_modify( uri, manager, &passwd, entry, ava, value,
|
do_modify( config, entry, ava, value, friendly );
|
||||||
loops, retries, delay, friendly, chaserefs );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit( EXIT_SUCCESS );
|
exit( EXIT_SUCCESS );
|
||||||
|
|
@ -195,18 +130,16 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_modify( char *uri, char *manager,
|
do_modify( struct tester_conn_args *config,
|
||||||
struct berval *passwd, char *entry, char* attr, char* value,
|
char *entry, char* attr, char* value, int friendly )
|
||||||
int maxloop, int maxretries, int delay, int friendly, int chaserefs )
|
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
|
|
||||||
struct ldapmod mod;
|
struct ldapmod mod;
|
||||||
struct ldapmod *mods[2];
|
struct ldapmod *mods[2];
|
||||||
char *values[2];
|
char *values[2];
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
|
|
||||||
values[0] = value;
|
values[0] = value;
|
||||||
values[1] = NULL;
|
values[1] = NULL;
|
||||||
|
|
@ -217,42 +150,14 @@ do_modify( char *uri, char *manager,
|
||||||
mods[1] = NULL;
|
mods[1] = NULL;
|
||||||
|
|
||||||
retry:;
|
retry:;
|
||||||
ldap_initialize( &ld, uri );
|
tester_init_ld( &ld, config, 0 );
|
||||||
if ( ld == NULL ) {
|
|
||||||
tester_perror( "ldap_initialize", NULL );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
if ( do_retry == config->retries ) {
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
|
||||||
fprintf( stderr, "PID=%ld - Modify(%d): entry=\"%s\".\n",
|
fprintf( stderr, "PID=%ld - Modify(%d): entry=\"%s\".\n",
|
||||||
(long) pid, maxloop, entry );
|
(long) pid, config->loops, entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
|
for ( ; i < config->loops; i++ ) {
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
|
||||||
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
|
||||||
switch ( rc ) {
|
|
||||||
case LDAP_BUSY:
|
|
||||||
case LDAP_UNAVAILABLE:
|
|
||||||
if ( do_retry > 0 ) {
|
|
||||||
do_retry--;
|
|
||||||
if ( delay > 0 ) {
|
|
||||||
sleep( delay );
|
|
||||||
}
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
/* fallthru */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( ; i < maxloop; i++ ) {
|
|
||||||
mod.mod_op = LDAP_MOD_ADD;
|
mod.mod_op = LDAP_MOD_ADD;
|
||||||
rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL );
|
rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL );
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
|
|
|
||||||
|
|
@ -39,27 +39,21 @@
|
||||||
#define RETRIES 0
|
#define RETRIES 0
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_modrdn( char *uri, char *manager, struct berval *passwd,
|
do_modrdn( struct tester_conn_args *config,
|
||||||
char *entry, int maxloop, int maxretries, int delay,
|
char *entry, int friendly );
|
||||||
int friendly, int chaserefs );
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage( char *name )
|
usage( char *name, char opt )
|
||||||
{
|
{
|
||||||
fprintf( stderr,
|
if ( opt ) {
|
||||||
"usage: %s "
|
fprintf( stderr, "%s: unable to handle option \'%c\'\n\n",
|
||||||
"-H <uri> | ([-h <host>] -p <port>) "
|
name, opt );
|
||||||
"-D <manager> "
|
}
|
||||||
"-w <passwd> "
|
|
||||||
|
fprintf( stderr, "usage: %s " TESTER_COMMON_HELP
|
||||||
"-e <entry> "
|
"-e <entry> "
|
||||||
"[-i <ignore>] "
|
"[-F]\n",
|
||||||
"[-l <loops>] "
|
name );
|
||||||
"[-L <outerloops>] "
|
|
||||||
"[-r <maxretries>] "
|
|
||||||
"[-t <delay>] "
|
|
||||||
"[-F] "
|
|
||||||
"[-C]\n",
|
|
||||||
name );
|
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,96 +61,38 @@ int
|
||||||
main( int argc, char **argv )
|
main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *uri = NULL;
|
|
||||||
char *host = "localhost";
|
|
||||||
int port = -1;
|
|
||||||
char *manager = NULL;
|
|
||||||
struct berval passwd = { 0, NULL };
|
|
||||||
char *entry = NULL;
|
char *entry = NULL;
|
||||||
int loops = LOOPS;
|
|
||||||
int outerloops = 1;
|
|
||||||
int retries = RETRIES;
|
|
||||||
int delay = 0;
|
|
||||||
int friendly = 0;
|
int friendly = 0;
|
||||||
int chaserefs = 0;
|
struct tester_conn_args *config;
|
||||||
|
|
||||||
tester_init( "slapd-modrdn", TESTER_MODRDN );
|
config = tester_init( "slapd-modrdn", TESTER_MODRDN );
|
||||||
|
|
||||||
while ( ( i = getopt( argc, argv, "CD:e:FH:h:i:L:l:p:r:t:w:" ) ) != EOF )
|
while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "e:F" ) ) != EOF )
|
||||||
{
|
{
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 'C':
|
|
||||||
chaserefs++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'F':
|
case 'F':
|
||||||
friendly++;
|
friendly++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'H': /* the server uri */
|
|
||||||
uri = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h': /* the servers host */
|
|
||||||
host = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
/* ignored (!) by now */
|
/* ignored (!) by now */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p': /* the servers port */
|
|
||||||
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D': /* the servers manager */
|
|
||||||
manager = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w': /* the server managers password */
|
|
||||||
passwd.bv_val = strdup( optarg );
|
|
||||||
passwd.bv_len = strlen( optarg );
|
|
||||||
memset( optarg, '*', passwd.bv_len );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'e': /* entry to rename */
|
case 'e': /* entry to rename */
|
||||||
entry = strdup( optarg );
|
entry = strdup( optarg );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l': /* the number of loops */
|
|
||||||
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L': /* the number of outerloops */
|
|
||||||
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r': /* the number of retries */
|
|
||||||
if ( lutil_atoi( &retries, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't': /* delay in seconds */
|
|
||||||
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage( argv[0] );
|
if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
usage( argv[0], i );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( entry == NULL ) || ( port == -1 && uri == NULL ))
|
if ( entry == NULL )
|
||||||
usage( argv[0] );
|
usage( argv[0], 0 );
|
||||||
|
|
||||||
if ( *entry == '\0' ) {
|
if ( *entry == '\0' ) {
|
||||||
|
|
||||||
|
|
@ -166,11 +102,10 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = tester_uri( uri, host, port );
|
tester_config_finish( config );
|
||||||
|
|
||||||
for ( i = 0; i < outerloops; i++ ) {
|
for ( i = 0; i < config->outerloops; i++ ) {
|
||||||
do_modrdn( uri, manager, &passwd, entry,
|
do_modrdn( config, entry, friendly );
|
||||||
loops, retries, delay, friendly, chaserefs );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit( EXIT_SUCCESS );
|
exit( EXIT_SUCCESS );
|
||||||
|
|
@ -178,17 +113,15 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_modrdn( char *uri, char *manager,
|
do_modrdn( struct tester_conn_args *config,
|
||||||
struct berval *passwd, char *entry, int maxloop, int maxretries,
|
char *entry, int friendly )
|
||||||
int delay, int friendly, int chaserefs )
|
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
int i, do_retry = maxretries;
|
int i, do_retry = config->retries;
|
||||||
char *DNs[2];
|
char *DNs[2];
|
||||||
char *rdns[2];
|
char *rdns[2];
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
char *p1, *p2;
|
char *p1, *p2;
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
|
|
||||||
DNs[0] = entry;
|
DNs[0] = entry;
|
||||||
DNs[1] = strdup( entry );
|
DNs[1] = strdup( entry );
|
||||||
|
|
@ -211,42 +144,14 @@ do_modrdn( char *uri, char *manager,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
retry:;
|
retry:;
|
||||||
ldap_initialize( &ld, uri );
|
tester_init_ld( &ld, config, 0 );
|
||||||
if ( ld == NULL ) {
|
|
||||||
tester_perror( "ldap_initialize", NULL );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
if ( do_retry == config->retries ) {
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
|
||||||
fprintf( stderr, "PID=%ld - Modrdn(%d): entry=\"%s\".\n",
|
fprintf( stderr, "PID=%ld - Modrdn(%d): entry=\"%s\".\n",
|
||||||
(long) pid, maxloop, entry );
|
(long) pid, config->loops, entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
|
for ( ; i < config->loops; i++ ) {
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
|
||||||
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
|
||||||
switch ( rc ) {
|
|
||||||
case LDAP_BUSY:
|
|
||||||
case LDAP_UNAVAILABLE:
|
|
||||||
if ( do_retry > 0 ) {
|
|
||||||
do_retry--;
|
|
||||||
if ( delay > 0) {
|
|
||||||
sleep( delay );
|
|
||||||
}
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
/* fallthru */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( ; i < maxloop; i++ ) {
|
|
||||||
rc = ldap_rename_s( ld, DNs[0], rdns[0], NULL, 0, NULL, NULL );
|
rc = ldap_rename_s( ld, DNs[0], rdns[0], NULL, 0, NULL, NULL );
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
tester_ldap_error( ld, "ldap_rename_s", NULL );
|
tester_ldap_error( ld, "ldap_rename_s", NULL );
|
||||||
|
|
|
||||||
|
|
@ -49,26 +49,20 @@
|
||||||
#define RETRIES 0
|
#define RETRIES 0
|
||||||
#define DEFAULT_BASE "ou=people,dc=example,dc=com"
|
#define DEFAULT_BASE "ou=people,dc=example,dc=com"
|
||||||
|
|
||||||
static void
|
|
||||||
do_conn( char *uri, char *manager, struct berval *passwd,
|
|
||||||
LDAP **ld, int nobind, int maxretries, int conn_num );
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_read( LDAP *ld, char *entry,
|
do_read( LDAP *ld, char *entry,
|
||||||
char **attrs, int noattrs, int nobind, int maxloop,
|
char **attrs, int noattrs, int nobind, int maxloop,
|
||||||
int maxretries, int delay, int force, int chaserefs, int idx );
|
int force, int idx );
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_random( LDAP *ld,
|
do_random( LDAP *ld,
|
||||||
char *sbase, char *filter, char **attrs, int noattrs, int nobind,
|
char *sbase, char *filter, char **attrs, int noattrs, int nobind,
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs,
|
int force, int idx );
|
||||||
int idx );
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_random2( LDAP *ld,
|
do_random2( LDAP *ld,
|
||||||
char *sbase, char *filter, char **attrs, int noattrs, int nobind,
|
char *sbase, char *filter, char **attrs, int noattrs, int nobind,
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs,
|
int force, int idx );
|
||||||
int idx );
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
do_onethread( void *arg );
|
do_onethread( void *arg );
|
||||||
|
|
@ -88,14 +82,10 @@ ldap_pvt_thread_t rtid[MAX_THREAD*2], *rwtid = rtid + MAX_THREAD;
|
||||||
* Shared globals (command line args)
|
* Shared globals (command line args)
|
||||||
*/
|
*/
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
|
struct tester_conn_args *config;
|
||||||
char *entry = NULL;
|
char *entry = NULL;
|
||||||
char *filter = NULL;
|
char *filter = NULL;
|
||||||
int loops = LOOPS;
|
|
||||||
int outerloops = 1;
|
|
||||||
int retries = RETRIES;
|
|
||||||
int delay = 0;
|
|
||||||
int force = 0;
|
int force = 0;
|
||||||
int chaserefs = 0;
|
|
||||||
char *srchattrs[] = { "1.1", NULL };
|
char *srchattrs[] = { "1.1", NULL };
|
||||||
char **attrs = srchattrs;
|
char **attrs = srchattrs;
|
||||||
int noattrs = 0;
|
int noattrs = 0;
|
||||||
|
|
@ -137,28 +127,23 @@ thread_verbose(int idx, char *string)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage( char *name )
|
usage( char *name, char opt )
|
||||||
{
|
{
|
||||||
fprintf( stderr,
|
if ( opt ) {
|
||||||
"usage: %s "
|
fprintf( stderr, "%s: unable to handle option \'%c\'\n\n",
|
||||||
"-H <uri> | ([-h <host>] -p <port>) "
|
name, opt );
|
||||||
"-D <manager> "
|
}
|
||||||
"-w <passwd> "
|
|
||||||
|
fprintf( stderr, "usage: %s " TESTER_COMMON_HELP
|
||||||
"-e <entry> "
|
"-e <entry> "
|
||||||
"[-A] "
|
"[-A] "
|
||||||
"[-C] "
|
|
||||||
"[-F] "
|
"[-F] "
|
||||||
"[-N] "
|
"[-N] "
|
||||||
"[-v] "
|
"[-v] "
|
||||||
"[-c connections] "
|
"[-c connections] "
|
||||||
"[-f filter] "
|
"[-f filter] "
|
||||||
"[-i <ignore>] "
|
|
||||||
"[-l <loops>] "
|
|
||||||
"[-L <outerloops>] "
|
|
||||||
"[-m threads] "
|
"[-m threads] "
|
||||||
"[-M threads] "
|
"[-M threads] "
|
||||||
"[-r <maxretries>] "
|
|
||||||
"[-t <delay>] "
|
|
||||||
"[-T <attrs>] "
|
"[-T <attrs>] "
|
||||||
"[<attrs>] "
|
"[<attrs>] "
|
||||||
"\n",
|
"\n",
|
||||||
|
|
@ -179,61 +164,28 @@ main( int argc, char **argv )
|
||||||
int ptpass;
|
int ptpass;
|
||||||
int testfail = 0;
|
int testfail = 0;
|
||||||
|
|
||||||
|
config = tester_init( "slapd-mtread", TESTER_READ );
|
||||||
tester_init( "slapd-mtread", TESTER_READ );
|
|
||||||
|
|
||||||
/* by default, tolerate referrals and no such object */
|
/* by default, tolerate referrals and no such object */
|
||||||
tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" );
|
tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" );
|
||||||
|
|
||||||
while ( (i = getopt( argc, argv, "ACc:D:e:Ff:H:h:i:L:l:M:m:Np:r:t:T:w:v" )) != EOF ) {
|
while ( (i = getopt( argc, argv, TESTER_COMMON_OPTS "Ac:e:Ff:M:m:NT:v" )) != EOF ) {
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 'A':
|
case 'A':
|
||||||
noattrs++;
|
noattrs++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
|
||||||
chaserefs++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'H': /* the server uri */
|
|
||||||
uri = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h': /* the servers host */
|
|
||||||
host = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
|
||||||
tester_ignore_str2errlist( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
nobind++;
|
nobind = TESTER_INIT_ONLY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p': /* the servers port */
|
|
||||||
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D': /* the servers manager */
|
|
||||||
manager = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w': /* the server managers password */
|
|
||||||
passwd.bv_val = strdup( optarg );
|
|
||||||
passwd.bv_len = strlen( optarg );
|
|
||||||
memset( optarg, '*', passwd.bv_len );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'c': /* the number of connections */
|
case 'c': /* the number of connections */
|
||||||
if ( lutil_atoi( &noconns, optarg ) != 0 ) {
|
if ( lutil_atoi( &noconns, optarg ) != 0 ) {
|
||||||
usage( argv[0] );
|
usage( argv[0], i );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -249,21 +201,9 @@ main( int argc, char **argv )
|
||||||
force++;
|
force++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l': /* the number of loops */
|
|
||||||
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L': /* the number of outerloops */
|
|
||||||
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'M': /* the number of R/W threads */
|
case 'M': /* the number of R/W threads */
|
||||||
if ( lutil_atoi( &rwthreads, optarg ) != 0 ) {
|
if ( lutil_atoi( &rwthreads, optarg ) != 0 ) {
|
||||||
usage( argv[0] );
|
usage( argv[0], i );
|
||||||
}
|
}
|
||||||
if (rwthreads > MAX_THREAD)
|
if (rwthreads > MAX_THREAD)
|
||||||
rwthreads = MAX_THREAD;
|
rwthreads = MAX_THREAD;
|
||||||
|
|
@ -271,39 +211,30 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
case 'm': /* the number of threads */
|
case 'm': /* the number of threads */
|
||||||
if ( lutil_atoi( &threads, optarg ) != 0 ) {
|
if ( lutil_atoi( &threads, optarg ) != 0 ) {
|
||||||
usage( argv[0] );
|
usage( argv[0], i );
|
||||||
}
|
}
|
||||||
if (threads > MAX_THREAD)
|
if (threads > MAX_THREAD)
|
||||||
threads = MAX_THREAD;
|
threads = MAX_THREAD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r': /* the number of retries */
|
|
||||||
if ( lutil_atoi( &retries, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't': /* delay in seconds */
|
|
||||||
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
attrs = ldap_str2charray( optarg, "," );
|
attrs = ldap_str2charray( optarg, "," );
|
||||||
if ( attrs == NULL ) {
|
if ( attrs == NULL ) {
|
||||||
usage( argv[0] );
|
usage( argv[0], i );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage( argv[0] );
|
if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
usage( argv[0], i );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( entry == NULL ) || ( port == -1 && uri == NULL ))
|
if ( entry == NULL )
|
||||||
usage( argv[0] );
|
usage( argv[0], 0 );
|
||||||
|
|
||||||
if ( *entry == '\0' ) {
|
if ( *entry == '\0' ) {
|
||||||
fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
|
fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
|
||||||
|
|
@ -326,16 +257,13 @@ main( int argc, char **argv )
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = tester_uri( uri, host, port );
|
tester_config_finish( config );
|
||||||
/* One connection and one connection only */
|
|
||||||
do_conn( uri, manager, &passwd, &ld, nobind, retries, 0 );
|
|
||||||
lds[0] = ld;
|
|
||||||
for(i = 1; i < noconns; i++) {
|
|
||||||
do_conn( uri, manager, &passwd, &lds[i], nobind, retries, i );
|
|
||||||
}
|
|
||||||
|
|
||||||
ldap_pvt_thread_initialize();
|
ldap_pvt_thread_initialize();
|
||||||
|
|
||||||
|
for (i = 0; i < noconns; i++) {
|
||||||
|
tester_init_ld( &lds[i], config, nobind );
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(outstr, BUFSIZ, "MT Test Start: conns: %d (%s)", noconns, uri);
|
snprintf(outstr, BUFSIZ, "MT Test Start: conns: %d (%s)", noconns, uri);
|
||||||
tester_error(outstr);
|
tester_error(outstr);
|
||||||
snprintf(outstr, BUFSIZ, "Threads: RO: %d RW: %d", threads, rwthreads);
|
snprintf(outstr, BUFSIZ, "Threads: RO: %d RW: %d", threads, rwthreads);
|
||||||
|
|
@ -354,7 +282,7 @@ main( int argc, char **argv )
|
||||||
thread_verbose(-1, outstr);
|
thread_verbose(-1, outstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptpass = outerloops * loops;
|
ptpass = config->outerloops * config->loops;
|
||||||
|
|
||||||
/* wait for read only threads to complete */
|
/* wait for read only threads to complete */
|
||||||
for ( i = 0; i < threads; i++ )
|
for ( i = 0; i < threads; i++ )
|
||||||
|
|
@ -413,7 +341,7 @@ do_onethread( void *arg )
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( j = 0; j < outerloops; j++ ) {
|
for ( j = 0; j < config->outerloops; j++ ) {
|
||||||
for(i = 0; i < noconns; i++) {
|
for(i = 0; i < noconns; i++) {
|
||||||
mlds[i] = ldap_dup(lds[i]);
|
mlds[i] = ldap_dup(lds[i]);
|
||||||
if (mlds[i] == NULL) {
|
if (mlds[i] == NULL) {
|
||||||
|
|
@ -439,17 +367,14 @@ do_onethread( void *arg )
|
||||||
if ( filter != NULL ) {
|
if ( filter != NULL ) {
|
||||||
if (strchr(filter, '['))
|
if (strchr(filter, '['))
|
||||||
do_random2( mlds[thisconn], entry, filter, attrs,
|
do_random2( mlds[thisconn], entry, filter, attrs,
|
||||||
noattrs, nobind, loops, retries, delay, force,
|
noattrs, nobind, force, idx );
|
||||||
chaserefs, idx );
|
|
||||||
else
|
else
|
||||||
do_random( mlds[thisconn], entry, filter, attrs,
|
do_random( mlds[thisconn], entry, filter, attrs,
|
||||||
noattrs, nobind, loops, retries, delay, force,
|
noattrs, nobind, force, idx );
|
||||||
chaserefs, idx );
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
do_read( mlds[thisconn], entry, attrs,
|
do_read( mlds[thisconn], entry, attrs, noattrs,
|
||||||
noattrs, nobind, loops, retries, delay, force,
|
nobind, config->loops, force, idx );
|
||||||
chaserefs, idx );
|
|
||||||
}
|
}
|
||||||
for(i = 0; i < noconns; i++) {
|
for(i = 0; i < noconns; i++) {
|
||||||
(void) ldap_destroy(mlds[i]);
|
(void) ldap_destroy(mlds[i]);
|
||||||
|
|
@ -504,7 +429,7 @@ do_onerwthread( void *arg )
|
||||||
attrs[3].mod_values = uid_vals;
|
attrs[3].mod_values = uid_vals;
|
||||||
uid_vals[0] = &uids[0];
|
uid_vals[0] = &uids[0];
|
||||||
|
|
||||||
for ( j = 0; j < outerloops; j++ ) {
|
for ( j = 0; j < config->outerloops; j++ ) {
|
||||||
for(i = 0; i < noconns; i++) {
|
for(i = 0; i < noconns; i++) {
|
||||||
mlds[i] = ldap_dup(lds[i]);
|
mlds[i] = ldap_dup(lds[i]);
|
||||||
if (mlds[i] == NULL) {
|
if (mlds[i] == NULL) {
|
||||||
|
|
@ -537,7 +462,7 @@ do_onerwthread( void *arg )
|
||||||
|
|
||||||
adds = 0;
|
adds = 0;
|
||||||
dels = 0;
|
dels = 0;
|
||||||
for (i = 0; i < loops; i++) {
|
for (i = 0; i < config->loops; i++) {
|
||||||
ret = ldap_add_ext_s(ld, dn, &attrp[0], NULL, NULL);
|
ret = ldap_add_ext_s(ld, dn, &attrp[0], NULL, NULL);
|
||||||
if (ret == LDAP_SUCCESS) {
|
if (ret == LDAP_SUCCESS) {
|
||||||
adds++;
|
adds++;
|
||||||
|
|
@ -570,69 +495,12 @@ do_onerwthread( void *arg )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
do_conn( char *uri, char *manager, struct berval *passwd,
|
|
||||||
LDAP **ldp, int nobind, int maxretries, int conn_num )
|
|
||||||
{
|
|
||||||
LDAP *ld = NULL;
|
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
int do_retry = maxretries;
|
|
||||||
int rc = LDAP_SUCCESS;
|
|
||||||
char thrstr[BUFSIZ];
|
|
||||||
|
|
||||||
retry:;
|
|
||||||
ldap_initialize( &ld, uri );
|
|
||||||
if ( ld == NULL ) {
|
|
||||||
snprintf( thrstr, BUFSIZ, "connection: %d", conn_num );
|
|
||||||
tester_error( thrstr );
|
|
||||||
tester_perror( "ldap_initialize", NULL );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
|
||||||
snprintf( thrstr, BUFSIZ, "do_conn #%d\n", conn_num );
|
|
||||||
thread_verbose( -1, thrstr );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( nobind == 0 ) {
|
|
||||||
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
|
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
|
||||||
snprintf( thrstr, BUFSIZ, "connection: %d", conn_num );
|
|
||||||
tester_error( thrstr );
|
|
||||||
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
|
|
||||||
switch ( rc ) {
|
|
||||||
case LDAP_BUSY:
|
|
||||||
case LDAP_UNAVAILABLE:
|
|
||||||
if ( do_retry > 0 ) {
|
|
||||||
ldap_unbind_ext( ld, NULL, NULL );
|
|
||||||
ld = NULL;
|
|
||||||
do_retry--;
|
|
||||||
if ( delay != 0 ) {
|
|
||||||
sleep( delay );
|
|
||||||
}
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
/* fallthru */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*ldp = ld;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_random( LDAP *ld,
|
do_random( LDAP *ld,
|
||||||
char *sbase, char *filter, char **srchattrs, int noattrs, int nobind,
|
char *sbase, char *filter, char **srchattrs, int noattrs, int nobind,
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs,
|
int force, int idx )
|
||||||
int idx )
|
|
||||||
{
|
{
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
char *attrs[ 2 ];
|
char *attrs[ 2 ];
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
int nvalues = 0;
|
int nvalues = 0;
|
||||||
|
|
@ -645,7 +513,7 @@ do_random( LDAP *ld,
|
||||||
|
|
||||||
snprintf( thrstr, BUFSIZ,
|
snprintf( thrstr, BUFSIZ,
|
||||||
"Read(%d): base=\"%s\", filter=\"%s\".\n",
|
"Read(%d): base=\"%s\", filter=\"%s\".\n",
|
||||||
innerloop, sbase, filter );
|
config->loops, sbase, filter );
|
||||||
thread_verbose( idx, thrstr );
|
thread_verbose( idx, thrstr );
|
||||||
|
|
||||||
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
||||||
|
|
@ -671,19 +539,18 @@ do_random( LDAP *ld,
|
||||||
|
|
||||||
ldap_msgfree( res );
|
ldap_msgfree( res );
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
if ( do_retry == config->retries ) {
|
||||||
snprintf( thrstr, BUFSIZ,
|
snprintf( thrstr, BUFSIZ,
|
||||||
"Read base=\"%s\" filter=\"%s\" got %d values.\n",
|
"Read base=\"%s\" filter=\"%s\" got %d values.\n",
|
||||||
sbase, filter, nvalues );
|
sbase, filter, nvalues );
|
||||||
thread_verbose( idx, thrstr );
|
thread_verbose( idx, thrstr );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0; i < innerloop; i++ ) {
|
for ( i = 0; i < config->loops; i++ ) {
|
||||||
int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0);
|
int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0);
|
||||||
|
|
||||||
do_read( ld, values[ r ],
|
do_read( ld, values[ r ],
|
||||||
srchattrs, noattrs, nobind, 1, maxretries,
|
srchattrs, noattrs, nobind, 1, force, idx );
|
||||||
delay, force, chaserefs, idx );
|
|
||||||
}
|
}
|
||||||
for( i = 0; i < nvalues; i++) {
|
for( i = 0; i < nvalues; i++) {
|
||||||
if (values[i] != NULL)
|
if (values[i] != NULL)
|
||||||
|
|
@ -705,10 +572,9 @@ do_random( LDAP *ld,
|
||||||
static void
|
static void
|
||||||
do_random2( LDAP *ld,
|
do_random2( LDAP *ld,
|
||||||
char *sbase, char *filter, char **srchattrs, int noattrs, int nobind,
|
char *sbase, char *filter, char **srchattrs, int noattrs, int nobind,
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs,
|
int force, int idx )
|
||||||
int idx )
|
|
||||||
{
|
{
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
int lo, hi, range;
|
int lo, hi, range;
|
||||||
int flen;
|
int flen;
|
||||||
|
|
@ -719,7 +585,7 @@ do_random2( LDAP *ld,
|
||||||
|
|
||||||
snprintf( thrstr, BUFSIZ,
|
snprintf( thrstr, BUFSIZ,
|
||||||
"Read(%d): base=\"%s\", filter=\"%s\".\n",
|
"Read(%d): base=\"%s\", filter=\"%s\".\n",
|
||||||
innerloop, sbase, filter );
|
config->loops, sbase, filter );
|
||||||
thread_verbose( idx, thrstr );
|
thread_verbose( idx, thrstr );
|
||||||
|
|
||||||
ptr = strchr(filter, '[');
|
ptr = strchr(filter, '[');
|
||||||
|
|
@ -735,7 +601,7 @@ do_random2( LDAP *ld,
|
||||||
flen = ptr - filter;
|
flen = ptr - filter;
|
||||||
ftail++;
|
ftail++;
|
||||||
|
|
||||||
for ( i = 0; i < innerloop; i++ ) {
|
for ( i = 0; i < config->loops; i++ ) {
|
||||||
int r = ((double)range)*rand()/(RAND_MAX + 1.0);
|
int r = ((double)range)*rand()/(RAND_MAX + 1.0);
|
||||||
sprintf(fbuf, "%.*s%d%s", flen, filter, r, ftail);
|
sprintf(fbuf, "%.*s%d%s", flen, filter, r, ftail);
|
||||||
|
|
||||||
|
|
@ -780,21 +646,21 @@ do_random2( LDAP *ld,
|
||||||
static void
|
static void
|
||||||
do_read( LDAP *ld, char *entry,
|
do_read( LDAP *ld, char *entry,
|
||||||
char **attrs, int noattrs, int nobind, int maxloop,
|
char **attrs, int noattrs, int nobind, int maxloop,
|
||||||
int maxretries, int delay, int force, int chaserefs, int idx )
|
int force, int idx )
|
||||||
{
|
{
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
char thrstr[BUFSIZ];
|
char thrstr[BUFSIZ];
|
||||||
|
|
||||||
retry:;
|
retry:;
|
||||||
if ( do_retry == maxretries ) {
|
if ( do_retry == config->retries ) {
|
||||||
snprintf( thrstr, BUFSIZ, "Read(%d): entry=\"%s\".\n",
|
snprintf( thrstr, BUFSIZ, "Read(%d): entry=\"%s\".\n",
|
||||||
maxloop, entry );
|
maxloop, entry );
|
||||||
thread_verbose( idx, thrstr );
|
thread_verbose( idx, thrstr );
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(thrstr, BUFSIZ, "LD %p cnt: %d (retried %d) (%s)", \
|
snprintf(thrstr, BUFSIZ, "LD %p cnt: %d (retried %d) (%s)", \
|
||||||
(void *) ld, maxloop, (do_retry - maxretries), entry);
|
(void *) ld, maxloop, (do_retry - config->retries), entry);
|
||||||
thread_verbose( idx, thrstr );
|
thread_verbose( idx, thrstr );
|
||||||
|
|
||||||
for ( ; i < maxloop; i++ ) {
|
for ( ; i < maxloop; i++ ) {
|
||||||
|
|
|
||||||
|
|
@ -41,35 +41,28 @@
|
||||||
#define RETRIES 0
|
#define RETRIES 0
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_read( char *uri, char *manager, struct berval *passwd,
|
do_read( struct tester_conn_args *config, char *entry, LDAP **ld,
|
||||||
char *entry, LDAP **ld,
|
char **attrs, int noattrs, int nobind, int maxloop, int force );
|
||||||
char **attrs, int noattrs, int nobind, int maxloop,
|
|
||||||
int maxretries, int delay, int force, int chaserefs );
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_random( char *uri, char *manager, struct berval *passwd,
|
do_random( struct tester_conn_args *config, char *sbase,
|
||||||
char *sbase, char *filter, char **attrs, int noattrs, int nobind,
|
char *filter, char **attrs, int noattrs, int nobind, int force );
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs );
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage( char *name )
|
usage( char *name, int opt )
|
||||||
{
|
{
|
||||||
fprintf( stderr,
|
if ( opt ) {
|
||||||
"usage: %s "
|
fprintf( stderr, "%s: unable to handle option \'%c\'\n\n",
|
||||||
"-H <uri> | ([-h <host>] -p <port>) "
|
name, opt );
|
||||||
"-D <manager> "
|
}
|
||||||
"-w <passwd> "
|
|
||||||
|
fprintf( stderr, "usage: %s " TESTER_COMMON_HELP
|
||||||
"-e <entry> "
|
"-e <entry> "
|
||||||
"[-A] "
|
"[-A] "
|
||||||
"[-C] "
|
|
||||||
"[-F] "
|
"[-F] "
|
||||||
"[-N] "
|
"[-N] "
|
||||||
|
"[-S[S[S]]] "
|
||||||
"[-f filter] "
|
"[-f filter] "
|
||||||
"[-i <ignore>] "
|
|
||||||
"[-l <loops>] "
|
|
||||||
"[-L <outerloops>] "
|
|
||||||
"[-r <maxretries>] "
|
|
||||||
"[-t <delay>] "
|
|
||||||
"[-T <attrs>] "
|
"[-T <attrs>] "
|
||||||
"[<attrs>] "
|
"[<attrs>] "
|
||||||
"\n",
|
"\n",
|
||||||
|
|
@ -87,69 +80,28 @@ int
|
||||||
main( int argc, char **argv )
|
main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *uri = NULL;
|
|
||||||
char *host = "localhost";
|
|
||||||
int port = -1;
|
|
||||||
char *manager = NULL;
|
|
||||||
struct berval passwd = { 0, NULL };
|
|
||||||
char *entry = NULL;
|
char *entry = NULL;
|
||||||
char *filter = NULL;
|
char *filter = NULL;
|
||||||
int loops = LOOPS;
|
|
||||||
int outerloops = 1;
|
|
||||||
int retries = RETRIES;
|
|
||||||
int delay = 0;
|
|
||||||
int force = 0;
|
int force = 0;
|
||||||
int chaserefs = 0;
|
|
||||||
char *srchattrs[] = { "1.1", NULL };
|
char *srchattrs[] = { "1.1", NULL };
|
||||||
char **attrs = srchattrs;
|
char **attrs = srchattrs;
|
||||||
int noattrs = 0;
|
int noattrs = 0;
|
||||||
int nobind = 0;
|
int nobind = 0;
|
||||||
|
struct tester_conn_args *config;
|
||||||
|
|
||||||
tester_init( "slapd-read", TESTER_READ );
|
config = tester_init( "slapd-read", TESTER_READ );
|
||||||
|
|
||||||
/* by default, tolerate referrals and no such object */
|
/* by default, tolerate referrals and no such object */
|
||||||
tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" );
|
tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" );
|
||||||
|
|
||||||
while ( (i = getopt( argc, argv, "ACD:e:Ff:H:h:i:L:l:p:r:St:T:w:" )) != EOF ) {
|
while ( (i = getopt( argc, argv, TESTER_COMMON_OPTS "Ae:Ff:NST:" )) != EOF ) {
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 'A':
|
case 'A':
|
||||||
noattrs++;
|
noattrs++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
|
||||||
chaserefs++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'H': /* the server uri */
|
|
||||||
uri = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h': /* the servers host */
|
|
||||||
host = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
|
||||||
tester_ignore_str2errlist( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
nobind++;
|
nobind = TESTER_INIT_ONLY;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'p': /* the servers port */
|
|
||||||
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D': /* the servers manager */
|
|
||||||
manager = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w': /* the server managers password */
|
|
||||||
passwd.bv_val = strdup( optarg );
|
|
||||||
passwd.bv_len = strlen( optarg );
|
|
||||||
memset( optarg, '*', passwd.bv_len );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'e': /* DN to search for */
|
case 'e': /* DN to search for */
|
||||||
|
|
@ -164,49 +116,28 @@ main( int argc, char **argv )
|
||||||
force++;
|
force++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l': /* the number of loops */
|
|
||||||
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L': /* the number of outerloops */
|
|
||||||
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r': /* the number of retries */
|
|
||||||
if ( lutil_atoi( &retries, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
swamp++;
|
swamp++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't': /* delay in seconds */
|
|
||||||
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
|
||||||
usage( argv[0] );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
attrs = ldap_str2charray( optarg, "," );
|
attrs = ldap_str2charray( optarg, "," );
|
||||||
if ( attrs == NULL ) {
|
if ( attrs == NULL ) {
|
||||||
usage( argv[0] );
|
usage( argv[0], i );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage( argv[0] );
|
if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
usage( argv[0], i );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( entry == NULL ) || ( port == -1 && uri == NULL ))
|
if ( entry == NULL )
|
||||||
usage( argv[0] );
|
usage( argv[0], 0 );
|
||||||
|
|
||||||
if ( *entry == '\0' ) {
|
if ( *entry == '\0' ) {
|
||||||
fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
|
fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
|
||||||
|
|
@ -218,18 +149,16 @@ main( int argc, char **argv )
|
||||||
attrs = &argv[optind];
|
attrs = &argv[optind];
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = tester_uri( uri, host, port );
|
tester_config_finish( config );
|
||||||
|
|
||||||
for ( i = 0; i < outerloops; i++ ) {
|
for ( i = 0; i < config->outerloops; i++ ) {
|
||||||
if ( filter != NULL ) {
|
if ( filter != NULL ) {
|
||||||
do_random( uri, manager, &passwd, entry, filter, attrs,
|
do_random( config, entry, filter, attrs,
|
||||||
noattrs, nobind, loops, retries, delay, force,
|
noattrs, nobind, force );
|
||||||
chaserefs );
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
do_read( uri, manager, &passwd, entry, NULL, attrs,
|
do_read( config, entry, NULL, attrs,
|
||||||
noattrs, nobind, loops, retries, delay, force,
|
noattrs, nobind, config->loops, force );
|
||||||
chaserefs );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,15 +166,13 @@ main( int argc, char **argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_random( char *uri, char *manager, struct berval *passwd,
|
do_random( struct tester_conn_args *config, char *sbase, char *filter,
|
||||||
char *sbase, char *filter, char **srchattrs, int noattrs, int nobind,
|
char **srchattrs, int noattrs, int nobind, int force )
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs )
|
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
char *attrs[ 2 ];
|
char *attrs[ 2 ];
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
int nvalues = 0;
|
int nvalues = 0;
|
||||||
char **values = NULL;
|
char **values = NULL;
|
||||||
LDAPMessage *res = NULL, *e = NULL;
|
LDAPMessage *res = NULL, *e = NULL;
|
||||||
|
|
@ -253,34 +180,11 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
||||||
attrs[ 0 ] = LDAP_NO_ATTRS;
|
attrs[ 0 ] = LDAP_NO_ATTRS;
|
||||||
attrs[ 1 ] = NULL;
|
attrs[ 1 ] = NULL;
|
||||||
|
|
||||||
ldap_initialize( &ld, uri );
|
tester_init_ld( &ld, config, nobind );
|
||||||
if ( ld == NULL ) {
|
|
||||||
tester_perror( "ldap_initialize", NULL );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
if ( do_retry == config->retries ) {
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
|
||||||
fprintf( stderr, "PID=%ld - Read(%d): base=\"%s\", filter=\"%s\".\n",
|
fprintf( stderr, "PID=%ld - Read(%d): base=\"%s\", filter=\"%s\".\n",
|
||||||
(long) pid, innerloop, sbase, filter );
|
(long) pid, config->loops, sbase, filter );
|
||||||
}
|
|
||||||
|
|
||||||
if ( nobind == 0 ) {
|
|
||||||
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", NULL );
|
|
||||||
switch ( rc ) {
|
|
||||||
case LDAP_BUSY:
|
|
||||||
case LDAP_UNAVAILABLE:
|
|
||||||
/* fallthru */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
||||||
|
|
@ -306,20 +210,19 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
||||||
|
|
||||||
ldap_msgfree( res );
|
ldap_msgfree( res );
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
if ( do_retry == config->retries ) {
|
||||||
fprintf( stderr, " PID=%ld - Read base=\"%s\" filter=\"%s\" got %d values.\n",
|
fprintf( stderr, " PID=%ld - Read base=\"%s\" filter=\"%s\" got %d values.\n",
|
||||||
(long) pid, sbase, filter, nvalues );
|
(long) pid, sbase, filter, nvalues );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0; i < innerloop; i++ ) {
|
for ( i = 0; i < config->loops; i++ ) {
|
||||||
#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
|
#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
|
||||||
int r = rand() % nvalues;
|
int r = rand() % nvalues;
|
||||||
#endif
|
#endif
|
||||||
int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0);
|
int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0);
|
||||||
|
|
||||||
do_read( uri, manager, passwd, values[ r ], &ld,
|
do_read( config, values[ r ], &ld,
|
||||||
srchattrs, noattrs, nobind, 1, maxretries,
|
srchattrs, noattrs, nobind, 1, force );
|
||||||
delay, force, chaserefs );
|
|
||||||
}
|
}
|
||||||
free( values );
|
free( values );
|
||||||
break;
|
break;
|
||||||
|
|
@ -337,14 +240,12 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_read( char *uri, char *manager, struct berval *passwd, char *entry,
|
do_read( struct tester_conn_args *config, char *entry, LDAP **ldp,
|
||||||
LDAP **ldp, char **attrs, int noattrs, int nobind, int maxloop,
|
char **attrs, int noattrs, int nobind, int maxloop, int force )
|
||||||
int maxretries, int delay, int force, int chaserefs )
|
|
||||||
{
|
{
|
||||||
LDAP *ld = ldp ? *ldp : NULL;
|
LDAP *ld = ldp ? *ldp : NULL;
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
int *msgids = NULL, active = 0;
|
int *msgids = NULL, active = 0;
|
||||||
|
|
||||||
/* make room for msgid */
|
/* make room for msgid */
|
||||||
|
|
@ -354,44 +255,12 @@ do_read( char *uri, char *manager, struct berval *passwd, char *entry,
|
||||||
|
|
||||||
retry:;
|
retry:;
|
||||||
if ( ld == NULL ) {
|
if ( ld == NULL ) {
|
||||||
ldap_initialize( &ld, uri );
|
tester_init_ld( &ld, config, nobind );
|
||||||
if ( ld == NULL ) {
|
}
|
||||||
tester_perror( "ldap_initialize", NULL );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
if ( do_retry == config->retries ) {
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n",
|
||||||
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
(long) pid, maxloop, entry );
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
|
||||||
fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n",
|
|
||||||
(long) pid, maxloop, entry );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( nobind == 0 ) {
|
|
||||||
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", NULL );
|
|
||||||
switch ( rc ) {
|
|
||||||
case LDAP_BUSY:
|
|
||||||
case LDAP_UNAVAILABLE:
|
|
||||||
if ( do_retry > 0 ) {
|
|
||||||
ldap_unbind_ext( ld, NULL, NULL );
|
|
||||||
ld = NULL;
|
|
||||||
do_retry--;
|
|
||||||
if ( delay != 0 ) {
|
|
||||||
sleep( delay );
|
|
||||||
}
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
/* fallthru */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( swamp > 1 ) {
|
if ( swamp > 1 ) {
|
||||||
|
|
|
||||||
|
|
@ -40,46 +40,35 @@
|
||||||
#define RETRIES 0
|
#define RETRIES 0
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_search( char *uri, char *manager, struct berval *passwd,
|
do_search( struct tester_conn_args *config,
|
||||||
char *sbase, int scope, char *filter, LDAP **ldp,
|
char *sbase, int scope, char *filter, LDAP **ldp,
|
||||||
char **attrs, int noattrs, int nobind,
|
char **attrs, int noattrs, int nobind,
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs );
|
int innerloop, int force );
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_random( char *uri, char *manager, struct berval *passwd,
|
do_random( struct tester_conn_args *config,
|
||||||
char *sbase, int scope, char *filter, char *attr,
|
char *sbase, int scope, char *filter, char *attr,
|
||||||
char **attrs, int noattrs, int nobind,
|
char **attrs, int noattrs, int nobind, int force );
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs );
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage( char *name, char o )
|
usage( char *name, char opt )
|
||||||
{
|
{
|
||||||
if ( o != '\0' ) {
|
if ( opt != '\0' ) {
|
||||||
fprintf( stderr, "unknown/incorrect option \"%c\"\n", o );
|
fprintf( stderr, "unknown/incorrect option \"%c\"\n", opt );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( stderr,
|
fprintf( stderr, "usage: %s " TESTER_COMMON_HELP
|
||||||
"usage: %s "
|
|
||||||
"-H <uri> | ([-h <host>] -p <port>) "
|
|
||||||
"-D <manager> "
|
|
||||||
"-w <passwd> "
|
|
||||||
"-b <searchbase> "
|
"-b <searchbase> "
|
||||||
"-s <scope> "
|
"-s <scope> "
|
||||||
"-f <searchfilter> "
|
"-f <searchfilter> "
|
||||||
"[-a <attr>] "
|
"[-a <attr>] "
|
||||||
"[-A] "
|
"[-A] "
|
||||||
"[-C] "
|
|
||||||
"[-F] "
|
"[-F] "
|
||||||
"[-N] "
|
"[-N] "
|
||||||
"[-S[S[S]]] "
|
"[-S[S[S]]] "
|
||||||
"[-i <ignore>] "
|
|
||||||
"[-l <loops>] "
|
|
||||||
"[-L <outerloops>] "
|
|
||||||
"[-r <maxretries>] "
|
|
||||||
"[-t <delay>] "
|
|
||||||
"[<attrs>] "
|
"[<attrs>] "
|
||||||
"\n",
|
"\n",
|
||||||
name );
|
name );
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,72 +82,31 @@ int
|
||||||
main( int argc, char **argv )
|
main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *uri = NULL;
|
|
||||||
char *host = "localhost";
|
|
||||||
int port = -1;
|
|
||||||
char *manager = NULL;
|
|
||||||
struct berval passwd = { 0, NULL };
|
|
||||||
char *sbase = NULL;
|
char *sbase = NULL;
|
||||||
int scope = LDAP_SCOPE_SUBTREE;
|
int scope = LDAP_SCOPE_SUBTREE;
|
||||||
char *filter = NULL;
|
char *filter = NULL;
|
||||||
char *attr = NULL;
|
char *attr = NULL;
|
||||||
char *srchattrs[] = { "cn", "sn", NULL };
|
char *srchattrs[] = { "cn", "sn", NULL };
|
||||||
char **attrs = srchattrs;
|
char **attrs = srchattrs;
|
||||||
int loops = LOOPS;
|
|
||||||
int outerloops = 1;
|
|
||||||
int retries = RETRIES;
|
|
||||||
int delay = 0;
|
|
||||||
int force = 0;
|
int force = 0;
|
||||||
int chaserefs = 0;
|
|
||||||
int noattrs = 0;
|
int noattrs = 0;
|
||||||
int nobind = 0;
|
int nobind = 0;
|
||||||
|
struct tester_conn_args *config;
|
||||||
|
|
||||||
tester_init( "slapd-search", TESTER_SEARCH );
|
config = tester_init( "slapd-search", TESTER_SEARCH );
|
||||||
|
|
||||||
/* by default, tolerate referrals and no such object */
|
/* by default, tolerate referrals and no such object */
|
||||||
tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" );
|
tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" );
|
||||||
|
|
||||||
while ( ( i = getopt( argc, argv, "Aa:b:CD:f:FH:h:i:l:L:Np:r:Ss:t:T:w:" ) ) != EOF )
|
while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "Aa:b:f:FNSs:T:" ) ) != EOF )
|
||||||
{
|
{
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 'A':
|
case 'A':
|
||||||
noattrs++;
|
noattrs++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
|
||||||
chaserefs++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'H': /* the server uri */
|
|
||||||
uri = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h': /* the servers host */
|
|
||||||
host = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
|
||||||
tester_ignore_str2errlist( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
nobind++;
|
nobind = TESTER_INIT_ONLY;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'p': /* the servers port */
|
|
||||||
if ( lutil_atoi( &port, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], i );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D': /* the servers manager */
|
|
||||||
manager = strdup( optarg );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w': /* the server managers password */
|
|
||||||
passwd.bv_val = strdup( optarg );
|
|
||||||
passwd.bv_len = strlen( optarg );
|
|
||||||
memset( optarg, '*', passwd.bv_len );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
|
|
@ -177,30 +125,6 @@ main( int argc, char **argv )
|
||||||
force++;
|
force++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l': /* number of loops */
|
|
||||||
if ( lutil_atoi( &loops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], i );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L': /* number of loops */
|
|
||||||
if ( lutil_atoi( &outerloops, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], i );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r': /* number of retries */
|
|
||||||
if ( lutil_atoi( &retries, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], i );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't': /* delay in seconds */
|
|
||||||
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
|
||||||
usage( argv[0], i );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
attrs = ldap_str2charray( optarg, "," );
|
attrs = ldap_str2charray( optarg, "," );
|
||||||
if ( attrs == NULL ) {
|
if ( attrs == NULL ) {
|
||||||
|
|
@ -220,13 +144,16 @@ main( int argc, char **argv )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
usage( argv[0], i );
|
usage( argv[0], i );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( sbase == NULL ) || ( filter == NULL ) || ( port == -1 && uri == NULL ))
|
if (( sbase == NULL ) || ( filter == NULL ))
|
||||||
usage( argv[0], '\0' );
|
usage( argv[0], 0 );
|
||||||
|
|
||||||
if ( *filter == '\0' ) {
|
if ( *filter == '\0' ) {
|
||||||
|
|
||||||
|
|
@ -240,20 +167,18 @@ main( int argc, char **argv )
|
||||||
attrs = &argv[optind];
|
attrs = &argv[optind];
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = tester_uri( uri, host, port );
|
tester_config_finish( config );
|
||||||
|
|
||||||
for ( i = 0; i < outerloops; i++ ) {
|
for ( i = 0; i < config->outerloops; i++ ) {
|
||||||
if ( attr != NULL ) {
|
if ( attr != NULL ) {
|
||||||
do_random( uri, manager, &passwd,
|
do_random( config,
|
||||||
sbase, scope, filter, attr,
|
sbase, scope, filter, attr,
|
||||||
attrs, noattrs, nobind,
|
attrs, noattrs, nobind, force );
|
||||||
loops, retries, delay, force, chaserefs );
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
do_search( uri, manager, &passwd,
|
do_search( config, sbase, scope, filter,
|
||||||
sbase, scope, filter, NULL,
|
NULL, attrs, noattrs, config->loops,
|
||||||
attrs, noattrs, nobind,
|
nobind, force );
|
||||||
loops, retries, delay, force, chaserefs );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,16 +187,14 @@ main( int argc, char **argv )
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_random( char *uri, char *manager, struct berval *passwd,
|
do_random( struct tester_conn_args *config,
|
||||||
char *sbase, int scope, char *filter, char *attr,
|
char *sbase, int scope, char *filter, char *attr,
|
||||||
char **srchattrs, int noattrs, int nobind,
|
char **srchattrs, int noattrs, int nobind, int force )
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs )
|
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
char *attrs[ 2 ];
|
char *attrs[ 2 ];
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
int nvalues = 0;
|
int nvalues = 0;
|
||||||
char **values = NULL;
|
char **values = NULL;
|
||||||
LDAPMessage *res = NULL, *e = NULL;
|
LDAPMessage *res = NULL, *e = NULL;
|
||||||
|
|
@ -279,35 +202,7 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
||||||
attrs[ 0 ] = attr;
|
attrs[ 0 ] = attr;
|
||||||
attrs[ 1 ] = NULL;
|
attrs[ 1 ] = NULL;
|
||||||
|
|
||||||
ldap_initialize( &ld, uri );
|
tester_init_ld( &ld, config, nobind );
|
||||||
if ( ld == NULL ) {
|
|
||||||
tester_perror( "ldap_initialize", NULL );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
|
||||||
fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n",
|
|
||||||
(long) pid, innerloop, sbase, filter, attr );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( nobind == 0 ) {
|
|
||||||
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", NULL );
|
|
||||||
switch ( rc ) {
|
|
||||||
case LDAP_BUSY:
|
|
||||||
case LDAP_UNAVAILABLE:
|
|
||||||
/* fallthru */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
||||||
filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
|
filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
|
||||||
|
|
@ -348,12 +243,12 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
if ( do_retry == config->retries ) {
|
||||||
fprintf( stderr, " PID=%ld - Search base=\"%s\" filter=\"%s\" got %d values.\n",
|
fprintf( stderr, " PID=%ld - Search base=\"%s\" filter=\"%s\" got %d values.\n",
|
||||||
(long) pid, sbase, filter, nvalues );
|
(long) pid, sbase, filter, nvalues );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0; i < innerloop; i++ ) {
|
for ( i = 0; i < config->loops; i++ ) {
|
||||||
char buf[ BUFSIZ ];
|
char buf[ BUFSIZ ];
|
||||||
#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
|
#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
|
||||||
int r = rand() % nvalues;
|
int r = rand() % nvalues;
|
||||||
|
|
@ -362,10 +257,10 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
||||||
|
|
||||||
snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ r ] );
|
snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ r ] );
|
||||||
|
|
||||||
do_search( uri, manager, passwd,
|
do_search( config,
|
||||||
sbase, scope, buf, &ld,
|
sbase, scope, buf, &ld,
|
||||||
srchattrs, noattrs, nobind,
|
srchattrs, noattrs, nobind,
|
||||||
1, maxretries, delay, force, chaserefs );
|
1, force );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -376,21 +271,27 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
||||||
|
|
||||||
fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc );
|
fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc );
|
||||||
|
|
||||||
|
if ( values ) {
|
||||||
|
for ( i = 0; i < nvalues; i++ ) {
|
||||||
|
free( values[i] );
|
||||||
|
}
|
||||||
|
free( values );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ld != NULL ) {
|
if ( ld != NULL ) {
|
||||||
ldap_unbind_ext( ld, NULL, NULL );
|
ldap_unbind_ext( ld, NULL, NULL );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_search( char *uri, char *manager, struct berval *passwd,
|
do_search( struct tester_conn_args *config,
|
||||||
char *sbase, int scope, char *filter, LDAP **ldp,
|
char *sbase, int scope, char *filter, LDAP **ldp,
|
||||||
char **attrs, int noattrs, int nobind,
|
char **attrs, int noattrs, int nobind,
|
||||||
int innerloop, int maxretries, int delay, int force, int chaserefs )
|
int innerloop, int force )
|
||||||
{
|
{
|
||||||
LDAP *ld = ldp ? *ldp : NULL;
|
LDAP *ld = ldp ? *ldp : NULL;
|
||||||
int i = 0, do_retry = maxretries;
|
int i = 0, do_retry = config->retries;
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
int version = LDAP_VERSION3;
|
|
||||||
char buf[ BUFSIZ ];
|
char buf[ BUFSIZ ];
|
||||||
int *msgids = NULL, active = 0;
|
int *msgids = NULL, active = 0;
|
||||||
|
|
||||||
|
|
@ -401,51 +302,15 @@ do_search( char *uri, char *manager, struct berval *passwd,
|
||||||
|
|
||||||
retry:;
|
retry:;
|
||||||
if ( ld == NULL ) {
|
if ( ld == NULL ) {
|
||||||
ldap_initialize( &ld, uri );
|
fprintf( stderr,
|
||||||
if ( ld == NULL ) {
|
"PID=%ld - Search(%d): "
|
||||||
tester_perror( "ldap_initialize", NULL );
|
"base=\"%s\" scope=%s filter=\"%s\" "
|
||||||
exit( EXIT_FAILURE );
|
"attrs=%s%s.\n",
|
||||||
}
|
(long) pid, innerloop,
|
||||||
|
sbase, ldap_pvt_scope2str( scope ), filter,
|
||||||
|
attrs[0], attrs[1] ? " (more...)" : "" );
|
||||||
|
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
|
tester_init_ld( &ld, config, nobind );
|
||||||
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
|
|
||||||
chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF );
|
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
|
||||||
fprintf( stderr,
|
|
||||||
"PID=%ld - Search(%d): "
|
|
||||||
"base=\"%s\" scope=%s filter=\"%s\" "
|
|
||||||
"attrs=%s%s.\n",
|
|
||||||
(long) pid, innerloop,
|
|
||||||
sbase, ldap_pvt_scope2str( scope ), filter,
|
|
||||||
attrs[0], attrs[1] ? " (more...)" : "" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( nobind == 0 ) {
|
|
||||||
rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
|
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
|
||||||
snprintf( buf, sizeof( buf ),
|
|
||||||
"bindDN=\"%s\"", manager );
|
|
||||||
tester_ldap_error( ld, "ldap_sasl_bind_s", buf );
|
|
||||||
switch ( rc ) {
|
|
||||||
case LDAP_BUSY:
|
|
||||||
case LDAP_UNAVAILABLE:
|
|
||||||
if ( do_retry > 0 ) {
|
|
||||||
ldap_unbind_ext( ld, NULL, NULL );
|
|
||||||
ld = NULL;
|
|
||||||
do_retry--;
|
|
||||||
if ( delay != 0 ) {
|
|
||||||
sleep( delay );
|
|
||||||
}
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
/* fallthru */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( swamp > 1 ) {
|
if ( swamp > 1 ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue