From: Pierangelo Masarati Date: Sat, 25 Mar 2006 10:13:30 +0000 (+0000) Subject: make referral chasing optional X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~106 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9003f3cfa48f481f06364cdb801adb06ce2a05bf;p=openldap make referral chasing optional --- diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index a699c324be..f199eab12e 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -44,7 +44,7 @@ get_add_entry( char *filename, LDAPMod ***mods ); static void do_addel( char *uri, char *manager, struct berval *passwd, char *dn, LDAPMod **attrs, int maxloop, int maxretries, int delay, - int friendly ); + int friendly, int chaserefs ); static void usage( char *name ) @@ -59,7 +59,8 @@ usage( char *name ) "[-L ] " "[-r ] " "[-t ] " - "[-F]\n", + "[-F] " + "[-C]\n", name ); exit( EXIT_FAILURE ); } @@ -80,12 +81,17 @@ main( int argc, char **argv ) int retries = RETRIES; int delay = 0; int friendly = 0; + int chaserefs = 0; LDAPMod **attrs = NULL; tester_init( "slapd-modify" ); - while ( (i = getopt( argc, argv, "FH:h:p:D:w:f:l:L:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "CFH:h:p:D:w:f:l:L:r:t:" )) != EOF ) { switch( i ) { + case 'C': + chaserefs++; + break; + case 'F': friendly++; break; @@ -172,7 +178,7 @@ main( int argc, char **argv ) for ( i = 0; i < outerloops; i++ ) { do_addel( uri, manager, &passwd, entry, attrs, - loops, retries, delay, friendly ); + loops, retries, delay, friendly, chaserefs ); } exit( EXIT_SUCCESS ); @@ -303,8 +309,8 @@ do_addel( int maxloop, int maxretries, int delay, - int friendly -) + int friendly, + int chaserefs ) { LDAP *ld = NULL; int i = 0, do_retry = maxretries; @@ -320,7 +326,8 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + (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", diff --git a/tests/progs/slapd-bind.c b/tests/progs/slapd-bind.c index b24a84944f..9b6d03a4c6 100644 --- a/tests/progs/slapd-bind.c +++ b/tests/progs/slapd-bind.c @@ -40,10 +40,12 @@ #define LOOPS 100 static int -do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force, int noinit, LDAP **ldp ); +do_bind( char *uri, char *dn, struct berval *pass, int maxloop, + int force, int chaserefs, int noinit, LDAP **ldp ); static int -do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int force, int noinit, int delay ); +do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, + int force, int chaserefs, int noinit, int delay ); /* 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 @@ -63,6 +65,7 @@ usage( char *name ) "[-l ] " "[-L ] " "[-F] " + "[-C] " "[-I] " "[-t delay]\n", name ); @@ -84,6 +87,7 @@ main( int argc, char **argv ) int loops = LOOPS; int outerloops = 1; int force = 0; + int chaserefs = 0; int noinit = 0; int delay = 0; @@ -91,68 +95,72 @@ main( int argc, char **argv ) while ( (i = getopt( argc, argv, "b:H:h:p:D:w:l:L:f:FIt:" )) != EOF ) { switch( i ) { - case 'b': /* base DN of a tree of user DNs */ - ber_str2bv( optarg, 0, 0, &base ); - break; + case 'b': /* base DN of a tree of user DNs */ + ber_str2bv( optarg, 0, 0, &base ); + break; - case 'H': /* the server uri */ - uri = strdup( optarg ); - break; + case 'C': + chaserefs++; + break; - case 'h': /* the servers host */ - host = strdup( optarg ); - break; + case 'H': /* the server uri */ + uri = strdup( optarg ); + break; - case 'p': /* the servers port */ - if ( lutil_atoi( &port, optarg ) != 0 ) { - usage( argv[0] ); - } - break; + case 'h': /* the servers host */ + host = strdup( optarg ); + break; - case 'D': - dn = strdup( optarg ); - break; + case 'p': /* the servers port */ + if ( lutil_atoi( &port, optarg ) != 0 ) { + usage( argv[0] ); + } + break; - case 'w': - pass.bv_val = strdup( optarg ); - pass.bv_len = strlen( optarg ); - break; + case 'D': + dn = strdup( optarg ); + break; - case 'l': /* the number of loops */ - if ( lutil_atoi( &loops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; + case 'w': + pass.bv_val = strdup( optarg ); + pass.bv_len = strlen( optarg ); + break; - case 'L': /* the number of outerloops */ - if ( lutil_atoi( &outerloops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; + case 'l': /* the number of loops */ + if ( lutil_atoi( &loops, optarg ) != 0 ) { + usage( argv[0] ); + } + break; - case 'f': - filter = optarg; - break; + case 'L': /* the number of outerloops */ + if ( lutil_atoi( &outerloops, optarg ) != 0 ) { + usage( argv[0] ); + } + break; - case 'F': - force++; - break; + case 'f': + filter = optarg; + break; - case 'I': - /* reuse connection */ - noinit++; - break; + case 'F': + force++; + break; - case 't': - /* sleep between binds */ - if ( lutil_atoi( &delay, optarg ) != 0 ) { - usage( argv[0] ); - } - break; + case 'I': + /* reuse connection */ + noinit++; + break; - default: + case 't': + /* sleep between binds */ + if ( lutil_atoi( &delay, optarg ) != 0 ) { usage( argv[0] ); - break; + } + break; + + default: + usage( argv[0] ); + break; } } @@ -164,9 +172,11 @@ main( int argc, char **argv ) for ( i = 0; i < outerloops; i++ ) { if ( base.bv_val != NULL ) { - do_base( uri, &base, &pass, loops, force, noinit, delay ); + do_base( uri, &base, &pass, loops, + force, chaserefs, noinit, delay ); } else { - do_bind( uri, dn, &pass, loops, force, noinit, NULL ); + do_bind( uri, dn, &pass, loops, + force, chaserefs, noinit, NULL ); } } @@ -175,7 +185,8 @@ main( int argc, char **argv ) static int -do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force, int noinit, LDAP **ldp ) +do_bind( char *uri, char *dn, struct berval *pass, int maxloop, + int force, int chaserefs, int noinit, LDAP **ldp ) { LDAP *ld = ldp ? *ldp : NULL; int i, first = 1, rc = -1; @@ -198,7 +209,7 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force, int n (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - LDAP_OPT_OFF ); + chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF ); } rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL ); @@ -245,7 +256,8 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force, int n static int -do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int force, int noinit, int delay ) +do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, + int force, int chaserefs, int noinit, int delay ) { LDAP *ld = NULL; int i = 0; @@ -273,7 +285,8 @@ do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int f } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, + chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF ); rc = ldap_sasl_bind_s( ld, NULL, LDAP_SASL_SIMPLE, &pw, NULL, NULL, NULL ); if ( rc != LDAP_SUCCESS ) { @@ -347,7 +360,9 @@ do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int f ptr = lutil_strcopy(dn, rdns[j].bv_val); strcpy(ptr, base->bv_val); - if ( do_bind( uri, dn, pass, 1, force, noinit, &ld ) && !force ) { + if ( do_bind( uri, dn, pass, 1, force, chaserefs, noinit, &ld ) + && !force ) + { break; } diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index 4063c52b69..6d19b07dcd 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -37,7 +37,7 @@ static void do_modify( char *uri, char *manager, struct berval *passwd, char *entry, char *attr, char *value, int maxloop, - int maxretries, int delay, int friendly ); + int maxretries, int delay, int friendly, int chaserefs ); static void @@ -53,7 +53,8 @@ usage( char *name ) "[-L ] " "[-r ] " "[-t ] " - "[-F]\n", + "[-F] " + "[-C]\n", name ); exit( EXIT_FAILURE ); } @@ -75,11 +76,16 @@ main( int argc, char **argv ) int retries = RETRIES; int delay = 0; int friendly = 0; + int chaserefs = 0; tester_init( "slapd-modify" ); - while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:a:l:L:r:t:" )) != EOF ) { - switch( i ) { + while ( (i = getopt( argc, argv, "CFH:h:p:D:w:e:a:l:L:r:t:" )) != EOF ) { + switch ( i ) { + case 'C': + chaserefs++; + break; + case 'F': friendly++; break; @@ -174,7 +180,7 @@ main( int argc, char **argv ) for ( i = 0; i < outerloops; i++ ) { do_modify( uri, manager, &passwd, entry, ava, value, - loops, retries, delay, friendly ); + loops, retries, delay, friendly, chaserefs ); } exit( EXIT_SUCCESS ); @@ -184,7 +190,7 @@ main( int argc, char **argv ) static void do_modify( char *uri, char *manager, struct berval *passwd, char *entry, char* attr, char* value, - int maxloop, int maxretries, int delay, int friendly ) + int maxloop, int maxretries, int delay, int friendly, int chaserefs ) { LDAP *ld = NULL; int i = 0, do_retry = maxretries; @@ -214,7 +220,8 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + (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", diff --git a/tests/progs/slapd-modrdn.c b/tests/progs/slapd-modrdn.c index 3b8d27563c..2080ac4aab 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -41,7 +41,7 @@ static void do_modrdn( char *uri, char *manager, struct berval *passwd, char *entry, int maxloop, int maxretries, int delay, - int friendly ); + int friendly, int chaserefs ); static void usage( char *name ) @@ -56,7 +56,8 @@ usage( char *name ) "[-L ] " "[-r ] " "[-t ] " - "[-F]\n", + "[-F] " + "[-C]\n", name ); exit( EXIT_FAILURE ); } @@ -76,11 +77,16 @@ main( int argc, char **argv ) int retries = RETRIES; int delay = 0; int friendly = 0; + int chaserefs = 0; tester_init( "slapd-modrdn" ); - while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:l:L:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "CFH:h:p:D:w:e:l:L:r:t:" )) != EOF ) { switch( i ) { + case 'C': + chaserefs++; + break; + case 'F': friendly++; break; @@ -157,7 +163,7 @@ main( int argc, char **argv ) for ( i = 0; i < outerloops; i++ ) { do_modrdn( uri, manager, &passwd, entry, - loops, retries, delay, friendly ); + loops, retries, delay, friendly, chaserefs ); } exit( EXIT_SUCCESS ); @@ -166,8 +172,8 @@ main( int argc, char **argv ) static void do_modrdn( char *uri, char *manager, - struct berval *passwd, char *entry, int maxloop, int maxretries, int delay, - int friendly ) + struct berval *passwd, char *entry, int maxloop, int maxretries, + int delay, int friendly, int chaserefs ) { LDAP *ld = NULL; int i = 0, do_retry = maxretries; @@ -205,7 +211,8 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + (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", diff --git a/tests/progs/slapd-read.c b/tests/progs/slapd-read.c index 1febf0e546..b08910da5d 100644 --- a/tests/progs/slapd-read.c +++ b/tests/progs/slapd-read.c @@ -40,7 +40,7 @@ static void do_read( char *uri, char *entry, int maxloop, - int maxretries, int delay, int force ); + int maxretries, int delay, int force, int chaserefs ); static void usage( char *name ) @@ -50,6 +50,7 @@ usage( char *name ) "-H | ([-h ] -p ) " "-e " "[-F] " + "[-C] " "[-l ] " "[-L ] " "[-r ] " @@ -71,11 +72,16 @@ main( int argc, char **argv ) int retries = RETRIES; int delay = 0; int force = 0; + int chaserefs = 0; tester_init( "slapd-read" ); - while ( (i = getopt( argc, argv, "H:h:p:e:Fl:L:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "CH:h:p:e:Fl:L:r:t:" )) != EOF ) { switch( i ) { + case 'C': + chaserefs++; + break; + case 'H': /* the server uri */ uri = strdup( optarg ); break; @@ -140,7 +146,7 @@ main( int argc, char **argv ) uri = tester_uri( uri, host, port ); for ( i = 0; i < outerloops; i++ ) { - do_read( uri, entry, loops, retries, delay, force ); + do_read( uri, entry, loops, retries, delay, force, chaserefs ); } exit( EXIT_SUCCESS ); @@ -149,7 +155,7 @@ main( int argc, char **argv ) static void do_read( char *uri, char *entry, int maxloop, - int maxretries, int delay, int force ) + int maxretries, int delay, int force, int chaserefs ) { LDAP *ld = NULL; int i = 0, do_retry = maxretries; @@ -168,7 +174,8 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + (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): entry=\"%s\".\n", diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c index 3d330ac204..1810eee30e 100644 --- a/tests/progs/slapd-search.c +++ b/tests/progs/slapd-search.c @@ -41,12 +41,12 @@ static void do_search( char *uri, char *manager, struct berval *passwd, char *sbase, char *filter, LDAP **ldp, - int innerloop, int maxretries, int delay, int force ); + int innerloop, int maxretries, int delay, int force, int chaserefs ); static void do_random( char *uri, char *manager, struct berval *passwd, char *sbase, char *filter, char *attr, int innerloop, - int maxretries, int delay, int force ); + int maxretries, int delay, int force, int chaserefs ); static void usage( char *name ) @@ -60,6 +60,7 @@ usage( char *name ) "-f " "[-a ] " "[-F] " + "[-C] " "[-l ] " "[-L ] " "[-r ] " @@ -85,11 +86,16 @@ main( int argc, char **argv ) int retries = RETRIES; int delay = 0; int force = 0; + int chaserefs = 0; tester_init( "slapd-search" ); - while ( (i = getopt( argc, argv, "a:b:D:f:FH:h:l:L:p:w:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "a:b:CD:f:FH:h:l:L:p:w:r:t:" )) != EOF ) { switch( i ) { + case 'C': + chaserefs++; + break; + case 'H': /* the server uri */ uri = strdup( optarg ); break; @@ -175,11 +181,11 @@ main( int argc, char **argv ) for ( i = 0; i < outerloops; i++ ) { if ( attr != NULL ) { do_random( uri, manager, &passwd, sbase, filter, attr, - loops, retries, delay, force ); + loops, retries, delay, force, chaserefs ); } else { do_search( uri, manager, &passwd, sbase, filter, NULL, - loops, retries, delay, force ); + loops, retries, delay, force, chaserefs ); } } @@ -190,7 +196,7 @@ main( int argc, char **argv ) static void do_random( char *uri, char *manager, struct berval *passwd, char *sbase, char *filter, char *attr, - int innerloop, int maxretries, int delay, int force ) + int innerloop, int maxretries, int delay, int force, int chaserefs ) { LDAP *ld = NULL; int i = 0, do_retry = maxretries; @@ -212,7 +218,8 @@ do_random( char *uri, char *manager, struct berval *passwd, } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + (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", @@ -269,7 +276,7 @@ do_random( char *uri, char *manager, struct berval *passwd, snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ rand() % nvalues ] ); do_search( uri, manager, passwd, sbase, buf, &ld, - 1, maxretries, delay, force ); + 1, maxretries, delay, force, chaserefs ); } } @@ -283,7 +290,8 @@ do_random( char *uri, char *manager, struct berval *passwd, static void do_search( char *uri, char *manager, struct berval *passwd, char *sbase, char *filter, LDAP **ldp, - int innerloop, int maxretries, int delay, int force ) + int innerloop, int maxretries, int delay, + int force, int chaserefs ) { LDAP *ld = ldp ? *ldp : NULL; int i = 0, do_retry = maxretries; @@ -302,7 +310,8 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + (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\".\n", diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c index 9358e93403..024ca3acdf 100644 --- a/tests/progs/slapd-tester.c +++ b/tests/progs/slapd-tester.c @@ -89,7 +89,8 @@ usage( char *name ) "-P " "[-r ] " "[-t ] " - "[-F]\n", + "[-F] " + "[-C]\n", name ); exit( EXIT_FAILURE ); } @@ -112,6 +113,7 @@ main( int argc, char **argv ) DIR *datadir; struct dirent *file; int friendly = 0; + int chaserefs = 0; /* search */ char *sfile = NULL; char *sreqs[MAXREQS]; @@ -168,8 +170,12 @@ main( int argc, char **argv ) tester_init( "slapd-tester" ); - while ( (i = getopt( argc, argv, "D:d:FH:h:j:l:L:P:p:r:t:w:" )) != EOF ) { + while ( (i = getopt( argc, argv, "CD:d:FH:h:j:l:L:P:p:r:t:w:" )) != EOF ) { switch( i ) { + case 'C': + chaserefs++; + break; + case 'D': /* slapd manager */ manager = ArgDup( optarg ); break; @@ -356,6 +362,9 @@ main( int argc, char **argv ) if ( friendly ) { sargs[sanum++] = friendlyOpt; } + if ( chaserefs ) { + sargs[sanum++] = "-C"; + } sargs[sanum++] = "-b"; sargs[sanum++] = NULL; /* will hold the search base */ sargs[sanum++] = "-f"; @@ -394,6 +403,9 @@ main( int argc, char **argv ) if ( friendly ) { rargs[ranum++] = friendlyOpt; } + if ( chaserefs ) { + rargs[ranum++] = "-C"; + } rargs[ranum++] = "-e"; rargs[ranum++] = NULL; /* will hold the read entry */ rargs[ranum++] = NULL; @@ -430,6 +442,9 @@ main( int argc, char **argv ) if ( friendly ) { margs[manum++] = friendlyOpt; } + if ( chaserefs ) { + margs[manum++] = "-C"; + } margs[manum++] = "-e"; margs[manum++] = NULL; /* will hold the modrdn entry */ margs[manum++] = NULL; @@ -466,6 +481,9 @@ main( int argc, char **argv ) if ( friendly ) { modargs[modanum++] = friendlyOpt; } + if ( chaserefs ) { + modargs[modanum++] = "-C"; + } modargs[modanum++] = "-e"; modargs[modanum++] = NULL; /* will hold the modify entry */ modargs[modanum++] = "-a";; @@ -504,6 +522,9 @@ main( int argc, char **argv ) if ( friendly ) { aargs[aanum++] = friendlyOpt; } + if ( chaserefs ) { + aargs[aanum++] = "-C"; + } aargs[aanum++] = "-f"; aargs[aanum++] = NULL; /* will hold the add data file */ aargs[aanum++] = NULL; @@ -538,6 +559,9 @@ main( int argc, char **argv ) if ( friendly ) { bargs[banum++] = friendlyOpt; } + if ( chaserefs ) { + bargs[banum++] = "-C"; + } bargs[banum++] = "-D"; bargs[banum++] = NULL; bargs[banum++] = "-w";