From 0bff9e6eb7bd48d1b78b1aa57bd0850815ff0439 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 27 Dec 2001 15:16:12 +0000 Subject: [PATCH] struct bervals for DN; fix in send children --- servers/slapd/back-monitor/back-monitor.h | 18 ++-- servers/slapd/back-monitor/backend.c | 14 +-- servers/slapd/back-monitor/bind.c | 2 + servers/slapd/back-monitor/cache.c | 41 +++++--- servers/slapd/back-monitor/compare.c | 2 +- servers/slapd/back-monitor/conn.c | 64 +++++++----- servers/slapd/back-monitor/database.c | 18 ++-- servers/slapd/back-monitor/entry.c | 2 +- servers/slapd/back-monitor/init.c | 97 ++++++++++++++----- servers/slapd/back-monitor/log.c | 7 +- servers/slapd/back-monitor/modify.c | 2 +- servers/slapd/back-monitor/operation.c | 24 ++--- .../slapd/back-monitor/proto-back-monitor.h | 3 +- servers/slapd/back-monitor/search.c | 5 +- servers/slapd/back-monitor/sent.c | 44 ++++----- servers/slapd/back-monitor/thread.c | 5 +- 16 files changed, 214 insertions(+), 134 deletions(-) diff --git a/servers/slapd/back-monitor/back-monitor.h b/servers/slapd/back-monitor/back-monitor.h index 17441a8b01..9c463c8f1c 100644 --- a/servers/slapd/back-monitor/back-monitor.h +++ b/servers/slapd/back-monitor/back-monitor.h @@ -51,7 +51,7 @@ LDAP_BEGIN_DECL * selection. */ struct monitorcache { - char *mc_ndn; + struct berval *mc_ndn; Entry *mc_e; }; @@ -168,9 +168,9 @@ struct monitorinfo { struct monitorsubsys { int mss_type; char *mss_name; - char *mss_rdn; - char *mss_dn; - char *mss_ndn; + struct berval *mss_rdn; + struct berval *mss_dn; + struct berval *mss_ndn; int mss_flags; #define MONITOR_HAS_VOLATILE_CH( mp ) \ @@ -183,8 +183,8 @@ struct monitorsubsys { /* update existing dynamic entry and subentries */ int ( *mss_update )( struct monitorinfo *, Entry * ); /* create new dynamic subentries */ - int ( *mss_create )( struct monitorinfo *, const char *ndn, - Entry *, Entry ** ); + int ( *mss_create )( struct monitorinfo *, + struct berval *ndn, Entry *, Entry ** ); /* modify entry and subentries */ int ( *mss_modify )( struct monitorinfo *, Entry *, Modifications *modlist ); @@ -201,8 +201,8 @@ extern AttributeDescription *monitor_ad_desc; extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 )); extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 )); extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e )); -extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry **ep )); -extern int monitor_cache_dn2entry LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry **ep, Entry **matched )); +extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep )); +extern int monitor_cache_dn2entry LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep, Entry **matched )); extern int monitor_cache_lock LDAP_P(( Entry *e )); extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e )); @@ -211,7 +211,7 @@ extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e )); */ extern int monitor_entry_update LDAP_P(( struct monitorinfo *mi, Entry *e )); -extern int monitor_entry_create LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry *e_parent, Entry **ep )); +extern int monitor_entry_create LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry *e_parent, Entry **ep )); extern int monitor_entry_modify LDAP_P(( struct monitorinfo *mi, Entry *e, Modifications *modlist )); LDAP_END_DECL diff --git a/servers/slapd/back-monitor/backend.c b/servers/slapd/back-monitor/backend.c index a357957e31..63b1f4818a 100644 --- a/servers/slapd/back-monitor/backend.c +++ b/servers/slapd/back-monitor/backend.c @@ -65,12 +65,12 @@ monitor_subsys_backend_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_backend_init: " "unable to get entry '%s'\n", - monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_backend_init: " "unable to get entry '%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn, + monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -96,7 +96,7 @@ monitor_subsys_backend_init( #endif /* !SLAPD_MONITORSUBENTRY */ "cn: %d\n", i, - monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn, + monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn->bv_val, i ); e = str2entry( buf ); @@ -106,13 +106,13 @@ monitor_subsys_backend_init( "monitor_subsys_backend_init: " "unable to create entry 'cn=%d,%s'\n", i, - monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_backend_init: " "unable to create entry 'cn=%d,%s'\n%s", i, - monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn, + monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn->bv_val, "" ); #endif return( -1 ); @@ -138,13 +138,13 @@ monitor_subsys_backend_init( "monitor_subsys_backend_init: " "unable to add entry 'cn=%d,%s'\n", i, - monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_backend_init: " "unable to add entry 'cn=%d,%s'\n%s", i, - monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn, + monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn->bv_val, "" ); #endif return( -1 ); diff --git a/servers/slapd/back-monitor/bind.c b/servers/slapd/back-monitor/bind.c index 83558eba31..eb95bd872a 100644 --- a/servers/slapd/back-monitor/bind.c +++ b/servers/slapd/back-monitor/bind.c @@ -58,7 +58,9 @@ monitor_back_bind( ) { +#if 0 /* not used yet */ struct monitorinfo *mi = (struct monitorinfo *) be->be_private; +#endif #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, diff --git a/servers/slapd/back-monitor/cache.c b/servers/slapd/back-monitor/cache.c index b6fdabe738..6f8c4b82e6 100644 --- a/servers/slapd/back-monitor/cache.c +++ b/servers/slapd/back-monitor/cache.c @@ -51,13 +51,15 @@ monitor_cache_cmp( const void *c2 ) { - struct monitorcache *cc1 = ( struct monitorcache * )c1; - struct monitorcache *cc2 = ( struct monitorcache * )c2; + struct monitorcache *cc1 = ( struct monitorcache * )c1; + struct monitorcache *cc2 = ( struct monitorcache * )c2; + + int d = cc1->mc_ndn->bv_len - cc2->mc_ndn->bv_len; /* * case sensitive, because the dn MUST be normalized */ - return strcmp( cc1->mc_ndn, cc2->mc_ndn ); + return d != 0 ? d : strcmp( cc1->mc_ndn->bv_val, cc2->mc_ndn->bv_val ); } /* @@ -71,11 +73,15 @@ monitor_cache_dup( { struct monitorcache *cc1 = ( struct monitorcache * )c1; struct monitorcache *cc2 = ( struct monitorcache * )c2; + + int d = cc1->mc_ndn->bv_len - cc2->mc_ndn->bv_len; + int cmp; /* * case sensitive, because the dn MUST be normalized */ - return ( strcmp( cc1->mc_ndn, cc2->mc_ndn ) == 0 ) ? -1 : 0; + cmp = d != 0 ? d : strcmp( cc1->mc_ndn->bv_val, cc2->mc_ndn->bv_val ); + return cmp == 0 ? -1 : 0; } /* @@ -98,7 +104,7 @@ monitor_cache_add( ldap_pvt_thread_mutex_init( &mp->mp_mutex ); mc = ( struct monitorcache * )ch_malloc( sizeof( struct monitorcache ) ); - mc->mc_ndn = e->e_ndn; + mc->mc_ndn = &e->e_nname; mc->mc_e = e; ldap_pvt_thread_mutex_lock( &mi->mi_cache_mutex ); rc = avl_insert( &mi->mi_cache, ( caddr_t )mc, @@ -134,7 +140,7 @@ monitor_cache_lock( int monitor_cache_get( struct monitorinfo *mi, - const char *ndn, + struct berval *ndn, Entry **ep ) { @@ -144,7 +150,7 @@ monitor_cache_get( assert( ndn != NULL ); assert( ep != NULL ); - tmp_mc.mc_ndn = ( char * )ndn; + tmp_mc.mc_ndn = ndn; ldap_pvt_thread_mutex_lock( &mi->mi_cache_mutex ); mc = ( struct monitorcache * )avl_find( mi->mi_cache, ( caddr_t )&tmp_mc, monitor_cache_cmp ); @@ -173,15 +179,15 @@ monitor_cache_get( int monitor_cache_dn2entry( struct monitorinfo *mi, - const char *ndn, + struct berval *ndn, Entry **ep, Entry **matched ) { - int rc; + int rc; - char *p_ndn; - Entry *e_parent; + struct berval p_ndn = { 0L, NULL }; + Entry *e_parent; struct monitorentrypriv *mp; assert( mi != NULL ); @@ -197,8 +203,17 @@ monitor_cache_dn2entry( } /* try with parent/ancestors */ - p_ndn = dn_parent( NULL, ndn ); - rc = monitor_cache_dn2entry( mi, p_ndn, &e_parent, matched ); + if ( ndn && ndn->bv_len ) { + p_ndn.bv_val = dn_parent( NULL, ndn->bv_val ); + } + if ( p_ndn.bv_val == NULL ) { + p_ndn.bv_val = ""; + p_ndn.bv_len = 0; + } else { + p_ndn.bv_len = ndn->bv_len + - ( ber_len_t ) ( p_ndn.bv_val - ndn->bv_val ); + } + rc = monitor_cache_dn2entry( mi, &p_ndn, &e_parent, matched ); if ( rc || e_parent == NULL) { return( -1 ); } diff --git a/servers/slapd/back-monitor/compare.c b/servers/slapd/back-monitor/compare.c index 9e82f0c33b..b615f18f50 100644 --- a/servers/slapd/back-monitor/compare.c +++ b/servers/slapd/back-monitor/compare.c @@ -56,7 +56,7 @@ monitor_back_compare( Attribute *a; /* get entry with reader lock */ - monitor_cache_dn2entry( mi, ndn->bv_val, &e, &matched ); + monitor_cache_dn2entry( mi, ndn, &e, &matched ); if ( e == NULL ) { send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched ? matched->e_dn : NULL, diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index f5fad1a0f2..56ad47960a 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -63,12 +63,12 @@ monitor_subsys_conn_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_conn_init: " "unable to get entry '%s'\n", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_conn_init: " "unable to get entry '%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -89,7 +89,7 @@ monitor_subsys_conn_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: Total\n", - monitor_subsys[SLAPD_MONITOR_CONN].mss_dn ); + monitor_subsys[SLAPD_MONITOR_CONN].mss_dn->bv_val ); e = str2entry( buf ); if ( e == NULL ) { @@ -97,12 +97,12 @@ monitor_subsys_conn_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_conn_init: " "unable to create entry 'cn=Total,%s'\n", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_conn_init: " "unable to create entry 'cn=Total,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -126,12 +126,12 @@ monitor_subsys_conn_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_conn_init: " "unable to add entry 'cn=Total,%s'\n", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_conn_init: " "unable to add entry 'cn=Total,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -152,7 +152,7 @@ monitor_subsys_conn_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: Current\n", - monitor_subsys[SLAPD_MONITOR_CONN].mss_dn ); + monitor_subsys[SLAPD_MONITOR_CONN].mss_dn->bv_val ); e = str2entry( buf ); if ( e == NULL ) { @@ -160,12 +160,12 @@ monitor_subsys_conn_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_conn_init: " "unable to create entry 'cn=Current,%s'\n", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_conn_init: " "unable to create entry 'cn=Current,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -185,12 +185,12 @@ monitor_subsys_conn_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_conn_init: " "unable to add entry 'cn=Current,%s'\n", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_conn_init: " "unable to add entry 'cn=Current,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, + monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -280,7 +280,7 @@ conn_create( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: %ld\n", - c->c_connid, monitor_subsys[SLAPD_MONITOR_CONN].mss_dn, + c->c_connid, monitor_subsys[SLAPD_MONITOR_CONN].mss_dn->bv_val, c->c_connid ); e = str2entry( buf ); @@ -291,14 +291,14 @@ conn_create( "unable to create entry " "'cn=%ld,%s' entry\n", c->c_connid, - monitor_subsys[SLAPD_MONITOR_CONN].mss_dn )); + monitor_subsys[SLAPD_MONITOR_CONN].mss_dn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_conn_create: " "unable to create entry " - "'cn=%ld,%s' entry\n%s", + "'cn=%ld,%s' entry\n", c->c_connid, - monitor_subsys[SLAPD_MONITOR_CONN].mss_dn, "" ); + monitor_subsys[SLAPD_MONITOR_CONN].mss_dn->bv_val, 0 ); #endif return( -1 ); } @@ -364,7 +364,7 @@ conn_create( int monitor_subsys_conn_create( struct monitorinfo *mi, - const char *ndn, + struct berval *ndn, Entry *e_parent, Entry **ep ) @@ -397,16 +397,30 @@ monitor_subsys_conn_create( connection_done(c); *ep = e; + } else { - /* create exactly the required entry */ - char *rdn, *value; - unsigned long connid; + char **values; + struct berval *rdn; + unsigned long connid; - rdn = dn_rdn( NULL, ndn ); - value = rdn_attr_value( rdn ); - connid = atol( value ); - free( value ); - free( rdn ); + /* create exactly the required entry */ + + if ( dnExtractRdn( ndn->bv_val, &rdn ) != LDAP_SUCCESS ) { + return( -1 ); + } + + if ( rdn_attrs( rdn->bv_val, NULL, &values ) != LDAP_SUCCESS ) { + ber_bvfree( rdn ); + return( -1 ); + } + ber_bvfree( rdn ); + + assert( values ); + assert( values[ 0 ] ); + + connid = atol( values[ 0 ] ); + + ldap_value_free( values ); for ( c = connection_first( &connindex ); c != NULL; diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index 030db2c5dd..11de1b5757 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -65,12 +65,12 @@ monitor_subsys_database_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_database_init: " "unable to get entry '%s'\n", - monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_database_init: " "unable to get entry '%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn, + monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -94,7 +94,7 @@ monitor_subsys_database_init( #endif /* !SLAPD_MONITORSUBENTRY */ "cn: %d\n", i, - monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn, + monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn->bv_val, i ); e = str2entry( buf ); @@ -104,13 +104,13 @@ monitor_subsys_database_init( "monitor_subsys_database_init: " "unable to create entry 'cn=%d,%s'\n", i, - monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_database_init: " "unable to create entry 'cn=%d,%s'\n%s", i, - monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn, + monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn->bv_val, "" ); #endif return( -1 ); @@ -141,14 +141,14 @@ monitor_subsys_database_init( "monitor_subsys_database_init: " "unable to add entry 'cn=%d,%s'\n", i, - monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_database_init: " - "unable to add entry 'cn=%d,%s'\n%s", + "unable to add entry 'cn=%d,%s'\n", i, - monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn, - "" ); + monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn->bv_val, + 0 ); #endif return( -1 ); } diff --git a/servers/slapd/back-monitor/entry.c b/servers/slapd/back-monitor/entry.c index a4cdafd085..5da85d8427 100644 --- a/servers/slapd/back-monitor/entry.c +++ b/servers/slapd/back-monitor/entry.c @@ -64,7 +64,7 @@ monitor_entry_update( int monitor_entry_create( struct monitorinfo *mi, - const char *ndn, + struct berval *ndn, Entry *e_parent, Entry **ep ) diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 862683641f..0b9e500ca7 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -220,7 +220,7 @@ monitor_back_db_init( struct monitorentrypriv *mp; int i, rc; char buf[1024], *end_of_line; - struct berval dn, *ndn; + struct berval dn, *ndn; const char *text; struct berval val, *bv[2] = { &val, NULL }; @@ -259,6 +259,7 @@ monitor_back_db_init( return -1; } + ber_bvecadd( &be->be_suffix, ber_bvdup( &dn ) ); ber_bvecadd( &be->be_nsuffix, ndn ); mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 ); @@ -281,24 +282,70 @@ monitor_back_db_init( */ e_tmp = NULL; for ( i = 0; monitor_subsys[ i ].mss_name != NULL; i++ ) { - int len = strlen( monitor_subsys[ i ].mss_name ); - - monitor_subsys[ i ].mss_rdn = ch_calloc( sizeof( char ), - 4 + len ); - strcpy( monitor_subsys[ i ].mss_rdn, "cn=" ); - strcat( monitor_subsys[ i ].mss_rdn, - monitor_subsys[ i ].mss_name ); - - monitor_subsys[ i ].mss_dn = ch_calloc( sizeof( char ), - 4 + len + sizeof( SLAPD_MONITOR_DN ) ); - strcpy( monitor_subsys[ i ].mss_dn, - monitor_subsys[ i ].mss_rdn ); - strcat( monitor_subsys[ i ].mss_dn, "," ); - strcat( monitor_subsys[ i ].mss_dn, SLAPD_MONITOR_DN ); + int len = strlen( monitor_subsys[ i ].mss_name ); + struct berval dn, *pdn; + int rc; + + dn.bv_len = len + sizeof( "cn=" ) - 1; + dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 ); + strcpy( dn.bv_val, "cn=" ); + strcat( dn.bv_val, monitor_subsys[ i ].mss_name ); + pdn = NULL; + rc = dnPretty( NULL, &dn, &pdn ); + if ( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "monitor RDN \"%s\" is invalid\n", + dn.bv_val )); +#else + Debug( LDAP_DEBUG_ANY, + "monitor RDN \"%s\" is invalid\n", + dn.bv_val, 0, 0 ); +#endif + free( dn.bv_val ); + return( -1 ); + } + free( dn.bv_val ); + monitor_subsys[ i ].mss_rdn = pdn; + + dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */ + dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 ); + strcpy( dn.bv_val , monitor_subsys[ i ].mss_rdn->bv_val ); + strcat( dn.bv_val, "," SLAPD_MONITOR_DN ); + pdn = NULL; + rc = dnPretty( NULL, &dn, &pdn ); + if ( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "monitor DN \"%s\" is invalid\n", + dn.bv_val )); +#else + Debug( LDAP_DEBUG_ANY, + "monitor DN \"%s\" is invalid\n", + dn.bv_val, 0, 0 ); +#endif + free( dn.bv_val ); + return( -1 ); + } + monitor_subsys[ i ].mss_dn = pdn; - monitor_subsys[ i ].mss_ndn - = ch_strdup( monitor_subsys[ i ].mss_dn ); - dn_normalize( monitor_subsys[ i ].mss_ndn ); + pdn = NULL; + dnNormalize( NULL, &dn, &pdn ); + if ( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "monitor DN \"%s\" is invalid\n", + dn.bv_val )); +#else + Debug( LDAP_DEBUG_ANY, + "monitor DN \"%s\" is invalid\n", + dn.bv_val, 0, 0 ); +#endif + free( dn.bv_val ); + return( -1 ); + } + free( dn.bv_val ); + monitor_subsys[ i ].mss_ndn = pdn; snprintf( buf, sizeof( buf ), "dn: %s\n" @@ -310,7 +357,7 @@ monitor_back_db_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: %s\n", - monitor_subsys[ i ].mss_dn, + monitor_subsys[ i ].mss_dn->bv_val, monitor_subsys[ i ].mss_name ); e = str2entry( buf ); @@ -319,11 +366,11 @@ monitor_back_db_init( #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "unable to create '%s' entry\n", - monitor_subsys[ i ].mss_dn )); + monitor_subsys[ i ].mss_dn->bv_val )); #else Debug( LDAP_DEBUG_ANY, - "unable to create '%s' entry\n%s%s", - monitor_subsys[ i ].mss_dn, "", "" ); + "unable to create '%s' entry\n", + monitor_subsys[ i ].mss_dn->bv_val, 0, 0 ); #endif return( -1 ); } @@ -339,11 +386,11 @@ monitor_back_db_init( #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "unable to add entry '%s' to cache\n", - monitor_subsys[ i ].mss_dn )); + monitor_subsys[ i ].mss_dn->bv_val )); #else Debug( LDAP_DEBUG_ANY, - "unable to add entry '%s' to cache\n%s%s", - monitor_subsys[ i ].mss_dn, "", "" ); + "unable to add entry '%s' to cache\n", + monitor_subsys[ i ].mss_dn->bv_val, 0, 0 ); #endif return -1; } diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 58f8d358fd..902fae1b14 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -101,12 +101,12 @@ monitor_subsys_log_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_log_init: " "unable to get entry '%s'\n", - monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_log_init: " "unable to get entry '%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn, + monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -379,8 +379,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) { int i, j, k, found, rc, nl = 0; Attribute *a; - char *desc = mod->sm_desc->ad_cname.bv_val; - MatchingRule *mr = mod->sm_desc->ad_type->sat_equality; + MatchingRule *mr = mod->sm_desc->ad_type->sat_equality; rc = check_constraints( mod, &nl ); if ( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-monitor/modify.c b/servers/slapd/back-monitor/modify.c index faf38b73fd..2748945511 100644 --- a/servers/slapd/back-monitor/modify.c +++ b/servers/slapd/back-monitor/modify.c @@ -68,7 +68,7 @@ monitor_back_modify( #endif /* acquire and lock entry */ - monitor_cache_dn2entry( mi, ndn->bv_val, &e, &matched ); + monitor_cache_dn2entry( mi, ndn, &e, &matched ); if ( e == NULL ) { send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched ? matched->e_dn : NULL, diff --git a/servers/slapd/back-monitor/operation.c b/servers/slapd/back-monitor/operation.c index 6e617f19b2..7108669e8f 100644 --- a/servers/slapd/back-monitor/operation.c +++ b/servers/slapd/back-monitor/operation.c @@ -63,12 +63,12 @@ monitor_subsys_ops_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_ops_init: " "unable to get entry '%s'\n", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_ops_init: " "unable to get entry '%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -89,7 +89,7 @@ monitor_subsys_ops_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: Initiated\n", - monitor_subsys[SLAPD_MONITOR_OPS].mss_dn ); + monitor_subsys[SLAPD_MONITOR_OPS].mss_dn->bv_val ); e = str2entry( buf ); if ( e == NULL ) { @@ -97,12 +97,12 @@ monitor_subsys_ops_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_ops_init: " "unable to create entry 'cn=Initiated,%s'\n", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_ops_init: " "unable to create entry 'cn=Initiated,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -125,12 +125,12 @@ monitor_subsys_ops_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_ops_init: " "unable to add entry 'cn=Initiated,%s'\n", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_ops_init: " "unable to add entry 'cn=Initiated,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -151,7 +151,7 @@ monitor_subsys_ops_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: Completed\n", - monitor_subsys[SLAPD_MONITOR_OPS].mss_dn ); + monitor_subsys[SLAPD_MONITOR_OPS].mss_dn->bv_val ); e = str2entry( buf ); if ( e == NULL ) { @@ -159,12 +159,12 @@ monitor_subsys_ops_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_ops_init: " "unable to create entry 'cn=Completed,%s'\n", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_ops_init: " "unable to create entry 'cn=Completed,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -187,12 +187,12 @@ monitor_subsys_ops_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_ops_init: " "unable to add entry 'cn=Completed,%s'\n", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_ops_init: " "unable to add entry 'cn=Completed,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, + monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn->bv_val, "", "" ); #endif return( -1 ); diff --git a/servers/slapd/back-monitor/proto-back-monitor.h b/servers/slapd/back-monitor/proto-back-monitor.h index e9c4e8fa90..d1701ed957 100644 --- a/servers/slapd/back-monitor/proto-back-monitor.h +++ b/servers/slapd/back-monitor/proto-back-monitor.h @@ -68,7 +68,7 @@ int monitor_subsys_thread_update LDAP_P(( struct monitorinfo *mi, Entry *e )); */ int monitor_subsys_conn_init LDAP_P(( BackendDB *be )); int monitor_subsys_conn_update LDAP_P(( struct monitorinfo *mi, Entry *e )); -int monitor_subsys_conn_create LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry *e_parent, Entry **ep )); +int monitor_subsys_conn_create LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry *e_parent, Entry **ep )); /* * read waiters @@ -99,4 +99,5 @@ int monitor_subsys_sent_init LDAP_P(( BackendDB *be )); int monitor_subsys_sent_update LDAP_P(( struct monitorinfo *mi, Entry *e )); LDAP_END_DECL + #endif diff --git a/servers/slapd/back-monitor/search.c b/servers/slapd/back-monitor/search.c index 57d7fa5d0a..ff38ca0754 100644 --- a/servers/slapd/back-monitor/search.c +++ b/servers/slapd/back-monitor/search.c @@ -51,7 +51,7 @@ monitor_send_children( Connection *conn, Operation *op, Filter *filter, - struct berval **attrs, + struct berval **attrs, int attrsonly, Entry *e_parent, int sub, @@ -67,6 +67,7 @@ monitor_send_children( mp = ( struct monitorentrypriv * )e_parent->e_private; e = mp->mp_children; + e_ch = NULL; if ( MONITOR_HAS_VOLATILE_CH( mp ) ) { monitor_entry_create( mi, NULL, e_parent, &e_ch ); } @@ -167,7 +168,7 @@ monitor_back_search( /* get entry with reader lock */ - monitor_cache_dn2entry( mi, nbase->bv_val, &e, &matched ); + monitor_cache_dn2entry( mi, nbase, &e, &matched ); if ( e == NULL ) { send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched ? matched->e_dn : NULL, diff --git a/servers/slapd/back-monitor/sent.c b/servers/slapd/back-monitor/sent.c index 72e84bba13..4e6fb54d72 100644 --- a/servers/slapd/back-monitor/sent.c +++ b/servers/slapd/back-monitor/sent.c @@ -63,12 +63,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to get entry '%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to get entry '%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -89,7 +89,7 @@ monitor_subsys_sent_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: Entries\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_dn ); + monitor_subsys[SLAPD_MONITOR_SENT].mss_dn->bv_val ); e = str2entry( buf ); if ( e == NULL ) { @@ -97,12 +97,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to create entry 'cn=Entries,%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to create entry 'cn=Entries,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -125,12 +125,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to add entry 'cn=Entries,%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to add entry 'cn=Entries,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -151,7 +151,7 @@ monitor_subsys_sent_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: Referrals\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_dn ); + monitor_subsys[SLAPD_MONITOR_SENT].mss_dn->bv_val ); e = str2entry( buf ); if ( e == NULL ) { @@ -159,12 +159,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to create entry 'cn=Referrals,%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to create entry 'cn=Referrals,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -187,12 +187,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to add entry 'cn=Referrals,%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to add entry 'cn=Referrals,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -213,7 +213,7 @@ monitor_subsys_sent_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: PDU\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_dn ); + monitor_subsys[SLAPD_MONITOR_SENT].mss_dn->bv_val ); e = str2entry( buf ); if ( e == NULL ) { @@ -221,12 +221,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to create entry 'cn=PDU,%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to create entry 'cn=PDU,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -249,12 +249,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to add entry 'cn=PDU,%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to add entry 'cn=PDU,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -275,7 +275,7 @@ monitor_subsys_sent_init( "objectClass: extensibleObject\n" #endif /* !SLAPD_MONITORSUBENTRY */ "cn: Bytes\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_dn ); + monitor_subsys[SLAPD_MONITOR_SENT].mss_dn->bv_val ); e = str2entry( buf ); if ( e == NULL ) { @@ -283,12 +283,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to create entry 'cn=Bytes,%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to create entry 'cn=Bytes,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); @@ -311,12 +311,12 @@ monitor_subsys_sent_init( LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_sent_init: " "unable to add entry 'cn=Bytes,%s'\n", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_sent_init: " "unable to add entry 'cn=Bytes,%s'\n%s%s", - monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, + monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, "", "" ); #endif return( -1 ); diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index 838d41ca2b..3fff3238f4 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -62,11 +62,12 @@ monitor_subsys_thread_init( #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, "monitor_subsys_thread_init: unable to get entry '%s'\n", - monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn )); + monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn->bv_val )); #else Debug( LDAP_DEBUG_ANY, "monitor_subsys_thread_init: unable to get entry '%s'\n", - monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn, 0, 0 ); + monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn->bv_val, + 0, 0 ); #endif return( -1 ); } -- 2.39.5