From: Howard Chu Date: Thu, 16 Jun 2022 15:15:56 +0000 (+0100) Subject: ITS#9865 slapd-watcher: add -c contextDN option X-Git-Tag: OPENLDAP_REL_ENG_2_5_13~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d31febadff007cd5f2d4c51cd593249aea7ecd70;p=thirdparty%2Fopenldap.git ITS#9865 slapd-watcher: add -c contextDN option --- diff --git a/tests/progs/slapd-watcher.c b/tests/progs/slapd-watcher.c index ef9233a279..0fed11fec4 100644 --- a/tests/progs/slapd-watcher.c +++ b/tests/progs/slapd-watcher.c @@ -139,12 +139,13 @@ usage( char *name, char opt ) "[-x | -Y ] " "[-i ] " "[-s ] " + "[-c ] " "[-b ] URI[...]\n", name ); exit( EXIT_FAILURE ); } -struct berval base; +struct berval base, cbase; int interval = 10; int numservers; server *servers; @@ -509,9 +510,9 @@ setup_server( struct tester_conn_args *config, server *sv, int first ) } ldap_msgfree( res ); - if ( base.bv_val ) { + if ( cbase.bv_val ) { char *attr2[] = { at_contextCSN.bv_val, NULL }; - rc = ldap_search_ext_s( ld, base.bv_val, LDAP_SCOPE_BASE, "(objectClass=*)", + rc = ldap_search_ext_s( ld, cbase.bv_val, LDAP_SCOPE_BASE, "(objectClass=*)", attr2, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res ); switch(rc) { case LDAP_SUCCESS: @@ -573,11 +574,17 @@ main( int argc, char **argv ) config = tester_init( "slapd-watcher", TESTER_TESTER ); config->authmethod = LDAP_AUTH_SIMPLE; - while ( ( i = getopt( argc, argv, "D:O:R:U:X:Y:b:d:i:s:w:x" ) ) != EOF ) + while ( ( i = getopt( argc, argv, "D:O:R:U:X:Y:b:c:d:i:s:w:x" ) ) != EOF ) { switch ( i ) { - case 'b': /* base DN for contextCSN lookups */ + case 'b': /* base DN for DB entrycount lookups */ ber_str2bv( optarg, 0, 0, &base ); + if ( !cbase.bv_val ) + cbase = base; + break; + + case 'c': /* base DN for contextCSN lookups */ + ber_str2bv( optarg, 0, 0, &cbase ); break; case 'i': @@ -693,7 +700,7 @@ server_down1: } if (( servers[i].flags & HAS_BASE ) && !msg2[i] ) { char *attrs[2] = { at_contextCSN.bv_val }; - rc = ldap_search_ext( ld, base.bv_val, + rc = ldap_search_ext( ld, cbase.bv_val, LDAP_SCOPE_BASE, "(objectClass=*)", attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &msg2[i] ); if ( rc != LDAP_SUCCESS ) {