X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslapcommon.c;h=05f331a6f67eced51a68e51475e21d9027a56c26;hb=e3e7a22b5d7c6410ab54c31038fc153dadc8ca66;hp=fad2bb9a960e7be359a1de93af9108e0c6e93bc5;hpb=4e22081e02abd6f280fa2c44fab97b884fb52222;p=openldap diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index fad2bb9a96..05f331a6f6 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2008 The OpenLDAP Foundation. + * Copyright 1998-2009 The OpenLDAP Foundation. * Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 2003 IBM Corporation. * All rights reserved. @@ -218,7 +218,7 @@ slap_tool_init( char *subtree = NULL; char *ldiffile = NULL; char **debug_unknowns = NULL; - int rc, i, dbnum; + int rc, i; int mode = SLAP_TOOL_MODE; int truncatemode = 0; int use_glue = 1; @@ -353,7 +353,7 @@ slap_tool_init( break; case 'n': /* which config file db to index */ - if ( lutil_atoi( &dbnum, optarg ) ) { + if ( lutil_atoi( &dbnum, optarg ) || dbnum < 0 ) { usage( tool, progname ); } break; @@ -564,7 +564,7 @@ slap_tool_init( } if ( use_glue ) { - rc = glue_sub_attach(); + rc = glue_sub_attach( 0 ); if ( rc != 0 ) { fprintf( stderr, @@ -689,12 +689,12 @@ slap_tool_init( progname, dbnum, 0 ); } - } else if ( dbnum < 0 || dbnum > (nbackends-1) ) { + } else if ( dbnum >= nbackends ) { fprintf( stderr, "Database number selected via -n is out of range\n" "Must be in the range 0 to %d" - " (number of configured databases)\n", - nbackends-1 ); + " (the number of configured databases)\n", + nbackends - 1 ); exit( EXIT_FAILURE ); } else { @@ -705,6 +705,15 @@ slap_tool_init( } startup:; + if ( be ) { + BackendDB *bdtmp; + + dbnum = 0; + LDAP_STAILQ_FOREACH( bdtmp, &backendDB, be_next ) { + if ( bdtmp == be ) break; + dbnum++; + } + } #ifdef CSRIMALLOC mal_leaktrace(1);