From b735ca3237aef5d209e603465d1adfb717ed45b4 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 24 Dec 2001 20:07:19 +0000 Subject: [PATCH] Add some cheats to dnNormalize and dnMatch to workaround ava normalization issues. --- servers/slapd/dn.c | 9 +++++---- servers/slapd/entry.c | 28 ++++++++++++++-------------- servers/slapd/tools/slapadd.c | 13 +++++++++---- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index fc64e02e84..dec568d392 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -351,10 +351,12 @@ dnNormalize( out = ber_bvdup( val ); } + /* FIXME: cheat! */ + ldap_pvt_str2upper( out->bv_val ); + Debug( LDAP_DEBUG_TRACE, "<<< dnNormalize: <%s>\n", out->bv_val, 0, 0 ); *normalized = out; - return LDAP_SUCCESS; } @@ -423,8 +425,7 @@ dnPretty( /* * dnMatch routine * - * note: uses exact string match (strcmp) because it is supposed to work - * on normalized DNs. + * FIXME: strcasecmp should be replaced with schema aware checks */ int dnMatch( @@ -445,7 +446,7 @@ dnMatch( match = value->bv_len - asserted->bv_len; if ( match == 0 ) { - match = strcmp( value->bv_val, asserted->bv_val ); + match = strcasecmp( value->bv_val, asserted->bv_val ); } #ifdef NEW_LOGGING diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 523bbd79ed..78ca41f9af 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -65,7 +65,7 @@ str2entry( char *s ) #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: \"%s\"\n", s ? s : "NULL" )); + "str2entry: \"%s\"\n", s ? s : "NULL" )); #else Debug( LDAP_DEBUG_TRACE, "=> str2entry\n", s ? s : "NULL", 0, 0 ); @@ -77,7 +77,7 @@ str2entry( char *s ) if( e == NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "str2entry: entry allocation failed.\n" )); + "str2entry: entry allocation failed.\n" )); #else Debug( LDAP_DEBUG_ANY, "<= str2entry NULL (entry allocation failed)\n", @@ -156,7 +156,7 @@ str2entry( char *s ) return NULL; } - e->e_name.bv_val = pdn->bv_val != NULL + e->e_name.bv_val = ( pdn->bv_val != NULL ) ? pdn->bv_val : ch_strdup( "" ); e->e_name.bv_len = pdn->bv_len; free( pdn ); @@ -169,7 +169,7 @@ str2entry( char *s ) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: str2ad(%s): %s\n", type, text )); + "str2entry: str2ad(%s): %s\n", type, text )); #else Debug( slapMode & SLAP_TOOL_MODE ? LDAP_DEBUG_ANY : LDAP_DEBUG_TRACE, @@ -186,7 +186,7 @@ str2entry( char *s ) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: str2undef_ad(%s): %s\n", type, text )); + "str2entry: str2undef_ad(%s): %s\n", type, text )); #else Debug( LDAP_DEBUG_ANY, "<= str2entry: str2undef_ad(%s): %s\n", @@ -219,8 +219,8 @@ str2entry( char *s ) } else { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "str2entry: no validator for syntax %s\n", - ad->ad_type->sat_syntax->ssyn_oid )); + "str2entry: no validator for syntax %s\n", + ad->ad_type->sat_syntax->ssyn_oid )); #else Debug( LDAP_DEBUG_ANY, "str2entry: no validator for syntax %s\n", @@ -235,8 +235,8 @@ str2entry( char *s ) if( rc != 0 ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, - "str2entry: invalid value for syntax %s\n", - ad->ad_type->sat_syntax->ssyn_oid )); + "str2entry: invalid value for syntax %s\n", + ad->ad_type->sat_syntax->ssyn_oid )); #else Debug( LDAP_DEBUG_ANY, "str2entry: invalid value for syntax %s\n", @@ -259,7 +259,7 @@ str2entry( char *s ) if( rc != 0 ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "str2entry: NULL (attr_merge)\n" )); + "str2entry: NULL (attr_merge)\n" )); #else Debug( LDAP_DEBUG_ANY, "<= str2entry NULL (attr_merge)\n", 0, 0, 0 ); @@ -278,8 +278,8 @@ str2entry( char *s ) if ( e->e_dn == NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "str2entry: entry %ld has no dn.\n", - (long) e->e_id )); + "str2entry: entry %ld has no dn.\n", + (long) e->e_id )); #else Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has no dn\n", (long) e->e_id, 0, 0 ); @@ -296,8 +296,8 @@ str2entry( char *s ) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "str2entry: entry %ld has invalid dn: %s\n", - (long) e->e_id, e->e_dn )); + "str2entry: entry %ld has invalid dn: %s\n", + (long) e->e_id, e->e_dn )); #else Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has invalid dn: %s\n", diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index 6f5ddeb6fa..581072850a 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -76,11 +76,16 @@ main( int argc, char **argv ) /* check backend */ if( select_backend( e->e_ndn, is_entry_referral(e), nosubs ) != be ) { - fprintf( stderr, "%s: database (%s) not configured to " - "hold dn=\"%s\" (line=%d)\n", - progname, + fprintf( stderr, "%s: line %d: " + "database (%s) not configured to hold \"%s\"\n", + progname, lineno, be ? be->be_suffix[0] : "", - e->e_dn, lineno ); + e->e_dn ); + fprintf( stderr, "%s: line %d: " + "database (%s) not configured to hold \"%s\"\n", + progname, lineno, + be ? be->be_nsuffix[0]->bv_val : "", + e->e_ndn ); rc = EXIT_FAILURE; entry_free( e ); if( continuemode ) continue; -- 2.39.5