From: Pierangelo Masarati Date: Sat, 25 Mar 2006 08:10:31 +0000 (+0000) Subject: don't chase referrals (essentially, because it may cause an endless loop in libldap... X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~108 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=82d50f40ed4280a5cb77f8da674d3815c383d33b;p=openldap don't chase referrals (essentially, because it may cause an endless loop in libldap/request.c:ldap_chase_v3referrals) --- diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index 5c437634ff..a699c324be 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -320,6 +320,7 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); + (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, 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 c538e4ff7a..b24a84944f 100644 --- a/tests/progs/slapd-bind.c +++ b/tests/progs/slapd-bind.c @@ -197,6 +197,8 @@ 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 ); } rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL ); diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index 4be8a5d97d..4063c52b69 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -194,6 +194,7 @@ do_modify( char *uri, char *manager, struct ldapmod mod; struct ldapmod *mods[2]; char *values[2]; + int version = LDAP_VERSION3; pid = getpid(); @@ -212,11 +213,8 @@ retry:; exit( EXIT_FAILURE ); } - { - int version = LDAP_VERSION3; - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, - &version ); - } + (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); + (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, 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 b28ae28484..3b8d27563c 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -205,6 +205,7 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); + (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, 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 78173dc60b..1febf0e546 100644 --- a/tests/progs/slapd-read.c +++ b/tests/progs/slapd-read.c @@ -168,6 +168,7 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); + (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, 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 4cbe545307..3d330ac204 100644 --- a/tests/progs/slapd-search.c +++ b/tests/progs/slapd-search.c @@ -212,6 +212,7 @@ 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 ); if ( do_retry == maxretries ) { fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n", @@ -258,6 +259,10 @@ do_random( char *uri, char *manager, struct berval *passwd, ldap_msgfree( res ); + if ( do_retry == maxretries ) { + fprintf( stderr, "PID=%ld - got %d values.\n", (long) pid, nvalues ); + } + for ( i = 0; i < innerloop; i++ ) { char buf[ BUFSIZ ]; @@ -297,6 +302,7 @@ retry:; } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); + (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, 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 e9a3d2832a..9358e93403 100644 --- a/tests/progs/slapd-tester.c +++ b/tests/progs/slapd-tester.c @@ -58,7 +58,7 @@ #define TBINDFILE "do_bind.0" static char *get_file_name( char *dirname, char *filename ); -static int get_search_filters( char *filename, char *filters[], char *bases[] ); +static int get_search_filters( char *filename, char *filters[], char *attrs[], char *bases[] ); static int get_read_entries( char *filename, char *entries[] ); static void fork_child( char *prog, char **args ); static void wait4kids( int nkidval ); @@ -115,6 +115,7 @@ main( int argc, char **argv ) /* search */ char *sfile = NULL; char *sreqs[MAXREQS]; + char *sattrs[MAXREQS]; char *sbase[MAXREQS]; int snum = 0; char *sargs[MAXARGS]; @@ -276,7 +277,7 @@ main( int argc, char **argv ) /* look for search requests */ if ( sfile ) { - snum = get_search_filters( sfile, sreqs, sbase ); + snum = get_search_filters( sfile, sreqs, sattrs, sbase ); } /* look for read requests */ @@ -291,12 +292,12 @@ main( int argc, char **argv ) /* look for modify requests */ if ( modfile ) { - modnum = get_search_filters( modfile, modreqs, moddn ); + modnum = get_search_filters( modfile, modreqs, NULL, moddn ); } /* look for bind requests */ if ( bfile ) { - bnum = get_search_filters( bfile, bcreds, breqs ); + bnum = get_search_filters( bfile, bcreds, NULL, breqs ); } /* setup friendly option */ @@ -359,7 +360,11 @@ main( int argc, char **argv ) sargs[sanum++] = NULL; /* will hold the search base */ sargs[sanum++] = "-f"; sargs[sanum++] = NULL; /* will hold the search request */ + sargs[sanum++] = NULL; + sargs[sanum] = NULL; /* might hold the "attr" request */ + + sargs[sanum + 1] = NULL; /* * generate the read clients @@ -544,6 +549,13 @@ main( int argc, char **argv ) sargs[sanum - 2] = sreqs[j]; sargs[sanum - 4] = sbase[j]; + if ( sattrs[j] != NULL ) { + sargs[sanum - 1] = "-a"; + sargs[sanum] = sattrs[j]; + + } else { + sargs[sanum - 1] = NULL; + } fork_child( scmd, sargs ); } @@ -603,7 +615,7 @@ get_file_name( char *dirname, char *filename ) static int -get_search_filters( char *filename, char *filters[], char *bases[] ) +get_search_filters( char *filename, char *filters[], char *attrs[], char *bases[] ) { FILE *fp; int filter = 0; @@ -621,7 +633,23 @@ get_search_filters( char *filename, char *filters[], char *bases[] ) if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' ))) *nl = '\0'; - filters[filter++] = ArgDup( line ); + filters[filter] = ArgDup( line ); + if ( attrs ) { + if ( filters[filter][0] == '+') { + char *sep = strchr( filters[filter], ':' ); + + if ( sep != NULL ) { + attrs[ filter ] = &filters[ filter ][ 1 ]; + sep[ 0 ] = '\0'; + /* NOTE: don't free this! */ + filters[ filter ] = &sep[ 1 ]; + } + + } else { + attrs[ filter] = NULL; + } + } + filter++; } fclose( fp );