]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9865 slapd-watcher: add -c contextDN option
authorHoward Chu <hyc@openldap.org>
Thu, 16 Jun 2022 15:15:56 +0000 (16:15 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 23 Jun 2022 18:47:20 +0000 (18:47 +0000)
tests/progs/slapd-watcher.c

index ef9233a279dd88e3ee977c84ecadd932a27664d5..0fed11fec4e88a1831b33a5c96cf0479e7c7579d 100644 (file)
@@ -139,12 +139,13 @@ usage( char *name, char opt )
                "[-x | -Y <SASL mech>] "
                "[-i <interval>] "
                "[-s <sids>] "
+               "[-c <contextDN>] "
                "[-b <baseDN> ] 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 ) {