/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2001-2005 The OpenLDAP Foundation.
+ * Copyright 2001-2006 The OpenLDAP Foundation.
* Portions Copyright 2001-2003 Pierangelo Masarati.
* All rights reserved.
*
monitor_back_initialize(
BackendInfo *bi )
{
- monitor_subsys_t *ms;
static char *controls[] = {
LDAP_CONTROL_MANAGEDSAIT,
NULL
};
- monitor_info_t *mi = &monitor_info;
- int i;
- const char *text;
+
+ static ConfigTable monitorcfg[] = {
+ { NULL, NULL, 0, 0, 0, ARG_IGNORED,
+ NULL, NULL, NULL, NULL }
+ };
+
+ static ConfigOCs monitorocs[] = {
+ { "( OLcfgDbOc:4.1 "
+ "NAME 'olcMonitorConfig' "
+ "DESC 'Monitor backend configuration' "
+ "SUP olcDatabaseConfig "
+ ")",
+ Cft_Database, monitorcfg },
+ { NULL, 0, NULL }
+ };
struct m_s {
char *name;
offsetof(monitor_info_t, mi_ad_monitorRuntimeConfig) },
{ NULL, NULL, 0, -1 }
};
- static ConfigTable monitorcfg[] = {
- { NULL, NULL, 0, 0, 0, ARG_IGNORED,
- NULL, NULL, NULL, NULL }
- };
- static ConfigOCs monitorocs[] = {
- { "( OLcfgDbOc:4.1 "
- "NAME 'olcMonitorConfig' "
- "DESC 'Monitor backend configuration' "
- "SUP olcDatabaseConfig "
- ")",
- Cft_Database, monitorcfg },
- { NULL, 0, NULL }
- };
- int rc;
-
- bi->bi_controls = controls;
-
- bi->bi_init = 0;
- bi->bi_open = 0;
- bi->bi_config = monitor_back_config;
- bi->bi_close = 0;
- bi->bi_destroy = 0;
-
- bi->bi_db_init = monitor_back_db_init;
- bi->bi_db_config = monitor_back_db_config;
- bi->bi_db_open = monitor_back_db_open;
- bi->bi_db_close = 0;
- bi->bi_db_destroy = monitor_back_db_destroy;
- bi->bi_op_bind = monitor_back_bind;
- bi->bi_op_unbind = 0;
- bi->bi_op_search = monitor_back_search;
- bi->bi_op_compare = monitor_back_compare;
- bi->bi_op_modify = monitor_back_modify;
- bi->bi_op_modrdn = 0;
- bi->bi_op_add = 0;
- bi->bi_op_delete = 0;
- bi->bi_op_abandon = 0;
-
- bi->bi_extended = 0;
-
- bi->bi_entry_release_rw = 0;
- bi->bi_chk_referrals = 0;
- bi->bi_operational = monitor_back_operational;
-
- /*
- * hooks for slap tools
- */
- bi->bi_tool_entry_open = 0;
- bi->bi_tool_entry_close = 0;
- bi->bi_tool_entry_first = 0;
- bi->bi_tool_entry_next = 0;
- bi->bi_tool_entry_get = 0;
- bi->bi_tool_entry_put = 0;
- bi->bi_tool_entry_reindex = 0;
- bi->bi_tool_sync = 0;
- bi->bi_tool_dn2id_get = 0;
- bi->bi_tool_id2entry_get = 0;
- bi->bi_tool_entry_modify = 0;
-
- bi->bi_connection_init = 0;
- bi->bi_connection_destroy = 0;
-
- /*
- * configuration objectClasses (fake)
- */
- bi->bi_cf_ocs = monitorocs;
-
- rc = config_register_schema( monitorcfg, monitorocs );
- if ( rc ) {
- return rc;
- }
-
- /*
- * register subsys
- */
- for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) {
- if ( monitor_back_register_subsys( ms ) ) {
- return -1;
- }
- }
+ int i, rc;
+ const char *text;
+ monitor_info_t *mi = &monitor_info;
/* schema integration */
for ( i = 0; mat[ i ].name; i++ ) {
((ObjectClass **)&(((char *)mi)[ moc[ i ].offset ]))[ 0 ] = Oc;
}
+ bi->bi_controls = controls;
+
+ bi->bi_init = 0;
+ bi->bi_open = 0;
+ bi->bi_config = monitor_back_config;
+ bi->bi_close = 0;
+ bi->bi_destroy = 0;
+
+ bi->bi_db_init = monitor_back_db_init;
+#if 0
+ bi->bi_db_config = monitor_back_db_config;
+#endif
+ bi->bi_db_open = monitor_back_db_open;
+ bi->bi_db_close = 0;
+ bi->bi_db_destroy = monitor_back_db_destroy;
+
+ bi->bi_op_bind = monitor_back_bind;
+ bi->bi_op_unbind = 0;
+ bi->bi_op_search = monitor_back_search;
+ bi->bi_op_compare = monitor_back_compare;
+ bi->bi_op_modify = monitor_back_modify;
+ bi->bi_op_modrdn = 0;
+ bi->bi_op_add = 0;
+ bi->bi_op_delete = 0;
+ bi->bi_op_abandon = 0;
+
+ bi->bi_extended = 0;
+
+ bi->bi_entry_release_rw = 0;
+ bi->bi_chk_referrals = 0;
+ bi->bi_operational = monitor_back_operational;
+
+ /*
+ * hooks for slap tools
+ */
+ bi->bi_tool_entry_open = 0;
+ bi->bi_tool_entry_close = 0;
+ bi->bi_tool_entry_first = 0;
+ bi->bi_tool_entry_next = 0;
+ bi->bi_tool_entry_get = 0;
+ bi->bi_tool_entry_put = 0;
+ bi->bi_tool_entry_reindex = 0;
+ bi->bi_tool_sync = 0;
+ bi->bi_tool_dn2id_get = 0;
+ bi->bi_tool_id2entry_get = 0;
+ bi->bi_tool_entry_modify = 0;
+
+ bi->bi_connection_init = 0;
+ bi->bi_connection_destroy = 0;
+
+ /*
+ * configuration objectClasses (fake)
+ */
+ bi->bi_cf_ocs = monitorocs;
+
+ rc = config_register_schema( monitorcfg, monitorocs );
+ if ( rc ) {
+ return rc;
+ }
+
return 0;
}
monitor_back_db_init(
BackendDB *be )
{
- int rc;
- struct berval dn = BER_BVC( SLAPD_MONITOR_DN ),
- pdn,
- ndn;
- BackendDB *be2;
+ int rc;
+ struct berval dn = BER_BVC( SLAPD_MONITOR_DN ),
+ pdn,
+ ndn;
+ BackendDB *be2;
+
+ monitor_subsys_t *ms;
+
+ /*
+ * register subsys
+ */
+ for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) {
+ if ( monitor_back_register_subsys( ms ) ) {
+ return -1;
+ }
+ }
/*
* database monitor can be defined once only
{
monitor_info_t *mi = (monitor_info_t *)be->be_private;
struct monitor_subsys_t **ms;
- Entry *e, **ep;
+ Entry *e, **ep, *root;
monitor_entry_t *mp;
int i;
- char buf[ BACKMONITOR_BUFSIZE ];
- struct berval bv;
+ struct berval bv, rdn = BER_BVC(SLAPD_MONITOR_DN);
struct tm *tms;
#ifdef HAVE_GMTIME_R
struct tm tm_buf;
#endif
static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+ struct berval desc[] = {
+ BER_BVC("This subtree contains monitoring/managing objects."),
+ BER_BVC("This object contains information about this server."),
+ BER_BVC("Most of the information is held in operational"
+ " attributes, which must be explicitly requested."),
+ BER_BVNULL };
assert( be_monitor != NULL );
if ( be != be_monitor ) {
if ( BER_BVISEMPTY( &be->be_rootdn ) ) {
BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS );
+ BER_BVSTR( &mi->mi_ncreatorsName, SLAPD_ANONYMOUS );
} else {
mi->mi_creatorsName = be->be_rootdn;
+ mi->mi_ncreatorsName = be->be_rootndn;
}
/*
* creates the "cn=Monitor" entry
*/
- snprintf( buf, sizeof( buf ),
- "dn: %s\n"
- "objectClass: %s\n"
- "structuralObjectClass: %s\n"
- "cn: Monitor\n"
- "description: This subtree contains monitoring/managing objects.\n"
- "description: This object contains information about this server.\n"
- "description: Most of the information is held in operational"
- " attributeTypes, which must be explicitly requested.\n"
- "creatorsName: %s\n"
- "modifiersName: %s\n"
- "createTimestamp: %s\n"
- "modifyTimestamp: %s\n",
- SLAPD_MONITOR_DN,
- mi->mi_oc_monitorServer->soc_cname.bv_val,
- mi->mi_oc_monitorServer->soc_cname.bv_val,
- mi->mi_creatorsName.bv_val,
- mi->mi_creatorsName.bv_val,
- mi->mi_startTime.bv_val,
- mi->mi_startTime.bv_val );
-
- e = str2entry( buf );
+ e = monitor_entry_stub( NULL, NULL, &rdn, mi->mi_oc_monitorServer, mi,
+ NULL, NULL );
+
if ( e == NULL) {
Debug( LDAP_DEBUG_ANY,
"unable to create \"%s\" entry\n",
return( -1 );
}
+ attr_merge_normalize( e, slap_schema.si_ad_description, desc, NULL );
+
bv.bv_val = strchr( (char *) Versionstr, '$' );
if ( bv.bv_val != NULL ) {
char *end;
SLAPD_MONITOR_DN, 0, 0 );
return -1;
}
+ root = e;
/*
* Create all the subsystem specific entries
return( -1 );
}
- dn.bv_len += sizeof( SLAPD_MONITOR_DN ); /* 1 for the , */
- dn.bv_val = ch_malloc( dn.bv_len + 1 );
- strcpy( dn.bv_val , monitor_subsys[ i ]->mss_rdn.bv_val );
- strcat( dn.bv_val, "," SLAPD_MONITOR_DN );
- rc = dnPrettyNormal( NULL, &dn, &monitor_subsys[ i ]->mss_dn,
- &monitor_subsys[ i ]->mss_ndn, NULL );
- free( dn.bv_val );
- if ( rc != LDAP_SUCCESS ) {
- Debug( LDAP_DEBUG_ANY,
- "monitor DN \"%s\" is invalid\n",
- dn.bv_val, 0, 0 );
- return( -1 );
- }
+ e = monitor_entry_stub( &root->e_name, &root->e_nname,
+ &monitor_subsys[ i ]->mss_rdn, mi->mi_oc_monitorContainer, mi,
+ NULL, NULL );
- snprintf( buf, sizeof( buf ),
- "dn: %s\n"
- "objectClass: %s\n"
- "structuralObjectClass: %s\n"
- "cn: %s\n"
- "creatorsName: %s\n"
- "modifiersName: %s\n"
- "createTimestamp: %s\n"
- "modifyTimestamp: %s\n",
- monitor_subsys[ i ]->mss_dn.bv_val,
- mi->mi_oc_monitorContainer->soc_cname.bv_val,
- mi->mi_oc_monitorContainer->soc_cname.bv_val,
- monitor_subsys[ i ]->mss_name,
- mi->mi_creatorsName.bv_val,
- mi->mi_creatorsName.bv_val,
- mi->mi_startTime.bv_val,
- mi->mi_startTime.bv_val );
-
- e = str2entry( buf );
-
if ( e == NULL) {
Debug( LDAP_DEBUG_ANY,
"unable to create \"%s\" entry\n",
monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
return( -1 );
}
+ monitor_subsys[i]->mss_dn = e->e_name;
+ monitor_subsys[i]->mss_ndn = e->e_nname;
if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_desc[ 0 ] ) ) {
attr_merge_normalize( e, slap_schema.si_ad_description,
return SLAP_CONF_UNKNOWN;
}
+#if 0
int
monitor_back_db_config(
Backend *be,
int argc,
char **argv )
{
-#if 0
monitor_info_t *mi = ( monitor_info_t * )be->be_private;
-#endif
/*
* eventually, will hold database specific configuration parameters
*/
return SLAP_CONF_UNKNOWN;
}
+#endif
int
monitor_back_db_destroy(