]> git.sur5r.net Git - openldap/commitdiff
make sure we don't interfere with frontend's entry when the suffix is empty (test027)
authorPierangelo Masarati <ando@openldap.org>
Sun, 17 Sep 2006 16:45:24 +0000 (16:45 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sun, 17 Sep 2006 16:45:24 +0000 (16:45 +0000)
servers/slapd/back-bdb/monitor.c

index db5a23e5448db16e8194cf8e6b76ad277085ec20..63be159702bcfc9f362d168bb7e5b2e62240ffc7 100644 (file)
@@ -329,13 +329,24 @@ bdb_monitor_db_open( BackendDB *be )
                ldap_bv2escaped_filter_value( &be->be_nsuffix[ 0 ], &suffix );
        }
 
-       /* just look for the naming context */
-       filter->bv_len = STRLENOF( "(namingContexts:distinguishedNameMatch:=" )
-               + suffix.bv_len + STRLENOF( ")" );
-       ptr = filter->bv_val = ch_malloc( filter->bv_len + 1 );
-       ptr = lutil_strcopy( ptr, "(namingContexts:distinguishedNameMatch:=" );
-       ptr = lutil_strncopy( ptr, suffix.bv_val, suffix.bv_len );
-       ptr = lutil_strcopy( ptr, ")" );
+       if ( BER_BVISEMPTY( &suffix ) ) {
+               /* frontend also has empty suffix, sigh! */
+               filter->bv_len = STRLENOF( "(&(namingContexts:distinguishedNameMatch:=" )
+                       + suffix.bv_len + STRLENOF( ")(!(cn=frontend)))" );
+               ptr = filter->bv_val = ch_malloc( filter->bv_len + 1 );
+               ptr = lutil_strcopy( ptr, "(&(namingContexts:distinguishedNameMatch:=" );
+               ptr = lutil_strncopy( ptr, suffix.bv_val, suffix.bv_len );
+               ptr = lutil_strcopy( ptr, ")(!(cn=frontend)))" );
+
+       } else {
+               /* just look for the naming context */
+               filter->bv_len = STRLENOF( "(namingContexts:distinguishedNameMatch:=" )
+                       + suffix.bv_len + STRLENOF( ")" );
+               ptr = filter->bv_val = ch_malloc( filter->bv_len + 1 );
+               ptr = lutil_strcopy( ptr, "(namingContexts:distinguishedNameMatch:=" );
+               ptr = lutil_strncopy( ptr, suffix.bv_val, suffix.bv_len );
+               ptr = lutil_strcopy( ptr, ")" );
+       }
        ptr[ 0 ] = '\0';
        assert( filter->bv_len == ptr - filter->bv_val );