#include "slap.h"
#include "back-monitor.h"
-/*
- * database monitor can be defined once only
- */
-static int monitor_defined = 0;
-
/*
* used by many functions to add description to entries
*/
Entry *e, *e_tmp;
struct monitorentrypriv *mp;
int i;
- char buf[1024], *ndn;
+ char buf[1024], *ndn, *end_of_line;
const char *text;
+ struct berval val, *bv[2] = { &val, NULL };
+
+ /*
+ * database monitor can be defined once only
+ */
+ static int monitor_defined = 0;
if ( monitor_defined ) {
#ifdef NEW_LOGGING
charray_add( &be->be_suffix, ndn );
dn_normalize( ndn );
ber_bvecadd( &be->be_nsuffix, ber_bvstr( ndn ) );
- ch_free( ndn );
mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
#endif
return( -1 );
}
-
+
+ /*
+ * Create all the subsystem specific entries
+ */
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=" );
/*
* creates the "cn=Monitor" entry
- * and all the subsystem specific entries
*/
snprintf( buf, sizeof( buf ),
"dn: %s\n"
#else /* !SLAPD_MONITORSUBENTRY */
"objectClass: extensibleObject\n"
#endif /* !SLAPD_MONITORSUBENTRY */
- "cn: Monitor\n"
- "description: %s",
- SLAPD_MONITOR_DN,
- /* (char *) Versionstr */ "slapd 2.0"
+ "cn: Monitor",
+ SLAPD_MONITOR_DN
);
e = str2entry( buf );
if ( e == NULL) {
#endif
return( -1 );
}
+ val.bv_val = (char *) Versionstr;
+ end_of_line = strchr( Versionstr, '\n' );
+ if ( end_of_line ) {
+ val.bv_len = end_of_line - Versionstr;
+ } else {
+ val.bv_len = strlen( Versionstr );
+ }
+ if ( attr_merge( e, monitor_ad_desc, bv ) ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+ "unable to add description to '%s' entry\n",
+ SLAPD_MONITOR_DN ));
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "unable to add description to '%s' entry\n%s%s",
+ SLAPD_MONITOR_DN, "", "" );
+#endif
+ return( -1 );
+ }
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;