don't chase referrals (essentially, because it may cause an endless loop in libldap/request.c:ldap_chase_v3referrals)

This commit is contained in:
Pierangelo Masarati 2006-03-25 08:10:31 +00:00
parent 1418b2c5b1
commit 82d50f40ed
7 changed files with 48 additions and 11 deletions

View File

@ -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",

View File

@ -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 );

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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 );