]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/init.c
Add validation.
[openldap] / servers / slapd / back-monitor / init.c
index 70bd84804c5008e0932f2f6f93256452a1b4e4b6..94ab4b675856db93e490f9e4c79fcda392f21731 100644 (file)
@@ -43,6 +43,7 @@
  * used by many functions to add description to entries
  */
 AttributeDescription *monitor_ad_desc = NULL;
+BackendDB *be_monitor = NULL;
 
 /*
  * subsystem data
@@ -51,8 +52,8 @@ struct monitorsubsys monitor_subsys[] = {
        { 
                SLAPD_MONITOR_LISTENER, SLAPD_MONITOR_LISTENER_NAME,    
                { 0L, NULL }, { 0L, NULL }, { 0L, NULL },
-               MONITOR_F_NONE,
-               NULL,   /* init */
+               MONITOR_F_PERSISTENT_CH,
+               monitor_subsys_listener_init,
                NULL,   /* update */
                NULL,   /* create */
                NULL    /* modify */
@@ -131,7 +132,7 @@ struct monitorsubsys monitor_subsys[] = {
                }, { 
                SLAPD_MONITOR_OPS, SLAPD_MONITOR_OPS_NAME,
                { 0L, NULL }, { 0L, NULL }, { 0L, NULL },
-               MONITOR_F_NONE,
+               MONITOR_F_PERSISTENT_CH,
                monitor_subsys_ops_init,
                monitor_subsys_ops_update,
                NULL,   /* create */
@@ -139,11 +140,19 @@ struct monitorsubsys monitor_subsys[] = {
                }, { 
                SLAPD_MONITOR_SENT, SLAPD_MONITOR_SENT_NAME,
                { 0L, NULL }, { 0L, NULL }, { 0L, NULL },
-               MONITOR_F_NONE,
+               MONITOR_F_PERSISTENT_CH,
                monitor_subsys_sent_init,
                monitor_subsys_sent_update,
                NULL,   /* create */
                NULL,   /* modify */
+               }, { 
+               SLAPD_MONITOR_TIME, SLAPD_MONITOR_TIME_NAME,
+               { 0L, NULL }, { 0L, NULL }, { 0L, NULL },
+               MONITOR_F_PERSISTENT_CH,
+               monitor_subsys_time_init,
+               monitor_subsys_time_update,
+               NULL,   /* create */
+               NULL,   /* modify */
        }, { -1, NULL }
 };
 
@@ -224,9 +233,7 @@ monitor_back_db_init(
        /*
         * database monitor can be defined once only
         */
-       static int              monitor_defined = 0;
-
-       if ( monitor_defined ) {
+       if ( be_monitor ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
                        "only one monitor backend is allowed\n" ));
@@ -237,7 +244,10 @@ monitor_back_db_init(
 #endif
                return( -1 );
        }
-       monitor_defined++;
+       be_monitor = be;
+
+       /* indicate system schema supported */
+       be->be_flags |= SLAP_BFLAG_MONITOR;
 
        ndn = NULL;
        dn.bv_val = SLAPD_MONITOR_DN;
@@ -256,7 +266,7 @@ monitor_back_db_init(
                return -1;
        }
 
-       ber_bvecadd( &be->be_suffix, ber_bvdup( &dn ) );
+       ber_bvecadd( &be->be_suffix, ber_dupbv( NULL, &dn ) );
        ber_bvecadd( &be->be_nsuffix, ndn );
 
        mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
@@ -324,13 +334,7 @@ monitor_back_db_init(
 
                snprintf( buf, sizeof( buf ),
                                "dn: %s\n"
-                               "objectClass: top\n"
-                               "objectClass: LDAPsubEntry\n"
-#ifdef SLAPD_MONITORSUBENTRY
-                               "objectClass: monitorSubEntry\n"
-#else /* !SLAPD_MONITORSUBENTRY */
-                               "objectClass: extensibleObject\n"
-#endif /* !SLAPD_MONITORSUBENTRY */
+                               SLAPD_MONITOR_OBJECTCLASSES 
                                "cn: %s\n",
                                monitor_subsys[ i ].mss_dn.bv_val,
                                monitor_subsys[ i ].mss_name );
@@ -379,12 +383,9 @@ monitor_back_db_init(
        snprintf( buf, sizeof( buf ), 
                        "dn: " SLAPD_MONITOR_DN "\n"
                        "objectClass: top\n"
-                       "objectClass: LDAPsubEntry\n"
-#ifdef SLAPD_MONITORSUBENTRY
-                       "objectClass: monitorSubEntry\n"
-#else /* !SLAPD_MONITORSUBENTRY */
+                       "objectClass: monitor\n"
                        "objectClass: extensibleObject\n"
-#endif /* !SLAPD_MONITORSUBENTRY */
+                       "structuralObjectClass: monitor\n"
                        "cn: Monitor" );
 
        e = str2entry( buf );