2001-07-15 01:34:24 +08:00
|
|
|
/* init.c - initialize monitor backend */
|
2003-11-27 10:35:20 +08:00
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2007-01-03 04:00:42 +08:00
|
|
|
* Copyright 2001-2007 The OpenLDAP Foundation.
|
2003-12-09 01:41:40 +08:00
|
|
|
* Portions Copyright 2001-2003 Pierangelo Masarati.
|
2003-11-27 10:35:20 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was initially developed by Pierangelo Masarati for inclusion
|
|
|
|
* in OpenLDAP Software.
|
|
|
|
*/
|
2001-07-15 01:34:24 +08:00
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2001-12-25 11:03:03 +08:00
|
|
|
#include <ac/string.h>
|
2001-07-15 01:34:24 +08:00
|
|
|
|
2003-05-15 09:19:30 +08:00
|
|
|
#include <lutil.h>
|
2001-07-15 01:34:24 +08:00
|
|
|
#include "slap.h"
|
2005-07-23 23:29:16 +08:00
|
|
|
#include "config.h"
|
2002-08-29 18:32:48 +08:00
|
|
|
#include "lber_pvt.h"
|
2001-07-15 01:34:24 +08:00
|
|
|
#include "back-monitor.h"
|
|
|
|
|
2006-11-15 09:18:37 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-05-18 08:15:28 +08:00
|
|
|
#undef INTEGRATE_CORE_SCHEMA
|
2003-05-18 01:19:16 +08:00
|
|
|
|
2001-07-15 01:34:24 +08:00
|
|
|
/*
|
|
|
|
* used by many functions to add description to entries
|
2004-11-12 20:54:42 +08:00
|
|
|
*
|
|
|
|
* WARNING: be_monitor may change as new databases are added,
|
|
|
|
* so it should not be used outside monitor_back_db_init()
|
|
|
|
* until monitor_back_db_open is called.
|
2001-07-15 01:34:24 +08:00
|
|
|
*/
|
2005-04-30 04:29:59 +08:00
|
|
|
BackendDB *be_monitor;
|
2001-07-15 01:34:24 +08:00
|
|
|
|
2005-04-30 04:29:59 +08:00
|
|
|
static struct monitor_subsys_t **monitor_subsys;
|
|
|
|
static int monitor_subsys_opened;
|
|
|
|
static monitor_info_t monitor_info;
|
2006-09-13 19:38:51 +08:00
|
|
|
static const monitor_extra_t monitor_extra = {
|
|
|
|
monitor_back_is_configured,
|
|
|
|
monitor_back_get_subsys,
|
|
|
|
monitor_back_get_subsys_by_dn,
|
|
|
|
|
|
|
|
monitor_back_register_subsys,
|
2007-03-22 06:35:37 +08:00
|
|
|
monitor_back_register_backend,
|
|
|
|
monitor_back_register_database,
|
|
|
|
monitor_back_register_overlay_info,
|
|
|
|
monitor_back_register_overlay,
|
2006-09-13 19:38:51 +08:00
|
|
|
monitor_back_register_entry,
|
|
|
|
monitor_back_register_entry_parent,
|
|
|
|
monitor_back_register_entry_attrs,
|
|
|
|
monitor_back_register_entry_callback,
|
|
|
|
|
|
|
|
monitor_back_unregister_entry,
|
|
|
|
monitor_back_unregister_entry_parent,
|
|
|
|
monitor_back_unregister_entry_attrs,
|
|
|
|
monitor_back_unregister_entry_callback
|
|
|
|
};
|
|
|
|
|
2004-11-08 19:33:53 +08:00
|
|
|
|
2001-07-15 01:34:24 +08:00
|
|
|
/*
|
|
|
|
* subsystem data
|
2004-11-08 19:33:53 +08:00
|
|
|
*
|
|
|
|
* the known subsystems are added to the subsystems
|
|
|
|
* array at backend initialization; other subsystems
|
|
|
|
* may be added by calling monitor_back_register_subsys()
|
|
|
|
* before the database is opened (e.g. by other backends
|
|
|
|
* or by overlays or modules).
|
2001-07-15 01:34:24 +08:00
|
|
|
*/
|
2004-11-09 02:52:27 +08:00
|
|
|
static struct monitor_subsys_t known_monitor_subsys[] = {
|
2001-07-15 01:34:24 +08:00
|
|
|
{
|
2004-09-13 06:12:58 +08:00
|
|
|
SLAPD_MONITOR_BACKEND_NAME,
|
2002-08-29 18:32:48 +08:00
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about available backends." ),
|
|
|
|
BER_BVNULL },
|
2001-07-15 01:34:24 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
|
|
|
monitor_subsys_backend_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
2001-07-15 01:34:24 +08:00
|
|
|
NULL, /* update */
|
2001-12-10 17:50:06 +08:00
|
|
|
NULL, /* create */
|
|
|
|
NULL /* modify */
|
2001-07-15 01:34:24 +08:00
|
|
|
}, {
|
2004-09-13 06:12:58 +08:00
|
|
|
SLAPD_MONITOR_CONN_NAME,
|
2002-08-29 18:32:48 +08:00
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about connections." ),
|
|
|
|
BER_BVNULL },
|
2001-07-15 01:34:24 +08:00
|
|
|
MONITOR_F_VOLATILE_CH,
|
|
|
|
monitor_subsys_conn_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
|
|
|
NULL, /* update */
|
|
|
|
NULL, /* create */
|
2001-12-10 17:50:06 +08:00
|
|
|
NULL /* modify */
|
2001-07-15 01:34:24 +08:00
|
|
|
}, {
|
2004-09-13 06:12:58 +08:00
|
|
|
SLAPD_MONITOR_DATABASE_NAME,
|
2002-08-29 18:32:48 +08:00
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about configured databases." ),
|
|
|
|
BER_BVNULL },
|
2003-04-13 01:41:49 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
2004-09-13 06:12:58 +08:00
|
|
|
monitor_subsys_database_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
2004-09-13 06:12:58 +08:00
|
|
|
NULL, /* update */
|
|
|
|
NULL, /* create */
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL /* modify */
|
2004-09-13 06:12:58 +08:00
|
|
|
}, {
|
|
|
|
SLAPD_MONITOR_LISTENER_NAME,
|
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about active listeners." ),
|
|
|
|
BER_BVNULL },
|
2004-09-13 06:12:58 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
|
|
|
monitor_subsys_listener_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
2004-09-13 06:12:58 +08:00
|
|
|
NULL, /* update */
|
|
|
|
NULL, /* create */
|
2001-12-10 17:50:06 +08:00
|
|
|
NULL /* modify */
|
|
|
|
}, {
|
2004-09-13 06:12:58 +08:00
|
|
|
SLAPD_MONITOR_LOG_NAME,
|
2002-08-29 18:32:48 +08:00
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about logging." ),
|
|
|
|
BER_BVC( "Set the attribute \"managedInfo\" to the desired log levels." ),
|
|
|
|
BER_BVNULL },
|
2001-12-10 17:50:06 +08:00
|
|
|
MONITOR_F_NONE,
|
|
|
|
monitor_subsys_log_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
2001-12-10 17:50:06 +08:00
|
|
|
NULL, /* update */
|
|
|
|
NULL, /* create */
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* modify */
|
2001-12-23 03:14:10 +08:00
|
|
|
}, {
|
2004-09-13 06:12:58 +08:00
|
|
|
SLAPD_MONITOR_OPS_NAME,
|
2002-08-29 18:32:48 +08:00
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about performed operations." ),
|
|
|
|
BER_BVNULL },
|
2002-01-29 20:15:13 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
2001-12-23 03:14:10 +08:00
|
|
|
monitor_subsys_ops_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
|
|
|
NULL, /* update */
|
2001-12-23 03:14:10 +08:00
|
|
|
NULL, /* create */
|
|
|
|
NULL, /* modify */
|
|
|
|
}, {
|
2004-09-13 06:12:58 +08:00
|
|
|
SLAPD_MONITOR_OVERLAY_NAME,
|
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about available overlays." ),
|
|
|
|
BER_BVNULL },
|
2004-09-13 06:12:58 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
|
|
|
monitor_subsys_overlay_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
2004-09-13 06:12:58 +08:00
|
|
|
NULL, /* update */
|
|
|
|
NULL, /* create */
|
|
|
|
NULL, /* modify */
|
|
|
|
}, {
|
|
|
|
SLAPD_MONITOR_SASL_NAME,
|
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about SASL." ),
|
|
|
|
BER_BVNULL },
|
2004-09-13 06:12:58 +08:00
|
|
|
MONITOR_F_NONE,
|
|
|
|
NULL, /* init */
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
2004-09-13 06:12:58 +08:00
|
|
|
NULL, /* update */
|
|
|
|
NULL, /* create */
|
|
|
|
NULL /* modify */
|
|
|
|
}, {
|
|
|
|
SLAPD_MONITOR_SENT_NAME,
|
2002-08-29 18:32:48 +08:00
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains statistics." ),
|
|
|
|
BER_BVNULL },
|
2002-01-29 20:15:13 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
2001-12-23 03:14:10 +08:00
|
|
|
monitor_subsys_sent_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
|
|
|
NULL, /* update */
|
2001-12-23 03:14:10 +08:00
|
|
|
NULL, /* create */
|
|
|
|
NULL, /* modify */
|
2002-01-29 20:15:13 +08:00
|
|
|
}, {
|
2004-09-13 06:12:58 +08:00
|
|
|
SLAPD_MONITOR_THREAD_NAME,
|
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about threads." ),
|
|
|
|
BER_BVNULL },
|
2004-09-13 06:12:58 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
|
|
|
monitor_subsys_thread_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
|
|
|
NULL, /* update */
|
2004-09-13 06:12:58 +08:00
|
|
|
NULL, /* create */
|
|
|
|
NULL /* modify */
|
|
|
|
}, {
|
|
|
|
SLAPD_MONITOR_TIME_NAME,
|
2002-08-29 18:32:48 +08:00
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about time." ),
|
|
|
|
BER_BVNULL },
|
2002-01-29 20:15:13 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
|
|
|
monitor_subsys_time_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
|
|
|
NULL, /* update */
|
2002-01-29 20:15:13 +08:00
|
|
|
NULL, /* create */
|
|
|
|
NULL, /* modify */
|
2004-03-17 05:58:29 +08:00
|
|
|
}, {
|
2004-09-13 06:12:58 +08:00
|
|
|
SLAPD_MONITOR_TLS_NAME,
|
2004-03-17 05:58:29 +08:00
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about TLS." ),
|
|
|
|
BER_BVNULL },
|
2004-09-13 06:12:58 +08:00
|
|
|
MONITOR_F_NONE,
|
|
|
|
NULL, /* init */
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
2004-09-13 06:12:58 +08:00
|
|
|
NULL, /* update */
|
2004-03-17 05:58:29 +08:00
|
|
|
NULL, /* create */
|
2004-09-13 06:12:58 +08:00
|
|
|
NULL /* modify */
|
|
|
|
}, {
|
|
|
|
SLAPD_MONITOR_RWW_NAME,
|
|
|
|
BER_BVNULL, BER_BVNULL, BER_BVNULL,
|
2005-04-30 04:29:59 +08:00
|
|
|
{ BER_BVC( "This subsystem contains information about read/write waiters." ),
|
|
|
|
BER_BVNULL },
|
2004-09-13 06:12:58 +08:00
|
|
|
MONITOR_F_PERSISTENT_CH,
|
|
|
|
monitor_subsys_rww_init,
|
2005-08-09 04:45:10 +08:00
|
|
|
NULL, /* destroy */
|
|
|
|
NULL, /* update */
|
2004-09-13 06:12:58 +08:00
|
|
|
NULL, /* create */
|
|
|
|
NULL /* modify */
|
|
|
|
}, { NULL }
|
2001-07-15 01:34:24 +08:00
|
|
|
};
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
int
|
|
|
|
monitor_subsys_is_opened( void )
|
|
|
|
{
|
|
|
|
return monitor_subsys_opened;
|
|
|
|
}
|
|
|
|
|
2004-11-08 18:10:15 +08:00
|
|
|
int
|
2005-04-28 05:30:35 +08:00
|
|
|
monitor_back_register_subsys(
|
|
|
|
monitor_subsys_t *ms )
|
2004-11-08 18:10:15 +08:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if ( monitor_subsys ) {
|
|
|
|
for ( ; monitor_subsys[ i ] != NULL; i++ )
|
|
|
|
/* just count'em */ ;
|
|
|
|
}
|
|
|
|
|
|
|
|
monitor_subsys = ch_realloc( monitor_subsys,
|
2004-11-09 02:52:27 +08:00
|
|
|
( 2 + i ) * sizeof( monitor_subsys_t * ) );
|
2004-11-08 18:10:15 +08:00
|
|
|
|
|
|
|
if ( monitor_subsys == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
monitor_subsys[ i ] = ms;
|
|
|
|
monitor_subsys[ i + 1 ] = NULL;
|
|
|
|
|
2004-11-08 19:33:53 +08:00
|
|
|
/* if a subsystem is registered __AFTER__ subsystem
|
|
|
|
* initialization (depending on the sequence the databases
|
|
|
|
* are listed in slapd.conf), init it */
|
2007-03-22 07:22:49 +08:00
|
|
|
if ( monitor_subsys_is_opened() ) {
|
2004-11-08 19:33:53 +08:00
|
|
|
|
|
|
|
/* FIXME: this should only be possible
|
|
|
|
* if be_monitor is already initialized */
|
2005-07-18 14:22:33 +08:00
|
|
|
assert( be_monitor != NULL );
|
2004-11-08 19:33:53 +08:00
|
|
|
|
|
|
|
if ( ms->mss_open && ( *ms->mss_open )( be_monitor, ms ) ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ms->mss_flags |= MONITOR_F_OPENED;
|
|
|
|
}
|
|
|
|
|
2004-11-08 18:10:15 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
enum {
|
|
|
|
LIMBO_ENTRY,
|
2005-04-27 10:43:38 +08:00
|
|
|
LIMBO_ENTRY_PARENT,
|
2004-11-12 20:54:42 +08:00
|
|
|
LIMBO_ATTRS,
|
2007-03-22 07:22:49 +08:00
|
|
|
LIMBO_CB,
|
|
|
|
LIMBO_BACKEND,
|
|
|
|
LIMBO_DATABASE,
|
|
|
|
LIMBO_OVERLAY_INFO,
|
|
|
|
LIMBO_OVERLAY,
|
|
|
|
|
|
|
|
LIMBO_LAST
|
2004-11-12 20:54:42 +08:00
|
|
|
};
|
|
|
|
|
2004-11-09 02:52:27 +08:00
|
|
|
typedef struct entry_limbo_t {
|
2004-11-12 20:54:42 +08:00
|
|
|
int el_type;
|
2007-03-22 07:22:49 +08:00
|
|
|
BackendInfo *el_bi;
|
|
|
|
BackendDB *el_be;
|
|
|
|
slap_overinst *el_on;
|
2004-11-09 02:52:27 +08:00
|
|
|
Entry *el_e;
|
2004-11-12 20:54:42 +08:00
|
|
|
Attribute *el_a;
|
2007-09-15 23:34:49 +08:00
|
|
|
struct berval *el_ndn;
|
2006-09-09 06:02:32 +08:00
|
|
|
struct berval el_nbase;
|
2004-11-12 20:54:42 +08:00
|
|
|
int el_scope;
|
|
|
|
struct berval el_filter;
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_callback_t *el_cb;
|
2006-09-09 06:02:32 +08:00
|
|
|
monitor_subsys_t *el_mss;
|
|
|
|
unsigned long el_flags;
|
2004-11-09 02:52:27 +08:00
|
|
|
struct entry_limbo_t *el_next;
|
|
|
|
} entry_limbo_t;
|
|
|
|
|
2005-09-08 22:23:35 +08:00
|
|
|
int
|
|
|
|
monitor_back_is_configured( void )
|
|
|
|
{
|
|
|
|
return be_monitor != NULL;
|
|
|
|
}
|
|
|
|
|
2007-03-22 06:35:37 +08:00
|
|
|
int
|
|
|
|
monitor_back_register_backend(
|
|
|
|
BackendInfo *bi )
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_register_overlay_info(
|
|
|
|
slap_overinst *on )
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_register_overlay(
|
|
|
|
BackendDB *be )
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
int
|
|
|
|
monitor_back_register_backend_limbo(
|
|
|
|
BackendInfo *bi )
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_register_database_limbo(
|
2007-09-15 23:34:49 +08:00
|
|
|
BackendDB *be,
|
|
|
|
struct berval *ndn )
|
2007-03-22 07:22:49 +08:00
|
|
|
{
|
|
|
|
entry_limbo_t **elpp, el = { 0 };
|
|
|
|
monitor_info_t *mi;
|
|
|
|
|
|
|
|
if ( be_monitor == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_database_limbo: "
|
|
|
|
"monitor database not configured.\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi = ( monitor_info_t * )be_monitor->be_private;
|
|
|
|
|
|
|
|
|
|
|
|
el.el_type = LIMBO_DATABASE;
|
|
|
|
|
|
|
|
el.el_be = be;
|
2007-09-15 23:34:49 +08:00
|
|
|
el.el_ndn = ndn;
|
2007-03-22 07:22:49 +08:00
|
|
|
|
2007-06-16 02:24:01 +08:00
|
|
|
for ( elpp = &mi->mi_entry_limbo;
|
2007-03-22 07:22:49 +08:00
|
|
|
*elpp;
|
|
|
|
elpp = &(*elpp)->el_next )
|
|
|
|
/* go to last */;
|
|
|
|
|
|
|
|
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
|
|
|
|
|
|
|
|
el.el_next = NULL;
|
|
|
|
**elpp = el;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_register_overlay_info_limbo(
|
|
|
|
slap_overinst *on )
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_register_overlay_limbo(
|
|
|
|
BackendDB *be )
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-11-09 02:52:27 +08:00
|
|
|
int
|
|
|
|
monitor_back_register_entry(
|
2005-04-28 05:30:35 +08:00
|
|
|
Entry *e,
|
2006-09-09 06:02:32 +08:00
|
|
|
monitor_callback_t *cb,
|
|
|
|
monitor_subsys_t *mss,
|
|
|
|
unsigned long flags )
|
2004-11-09 02:52:27 +08:00
|
|
|
{
|
2005-09-08 22:23:35 +08:00
|
|
|
monitor_info_t *mi;
|
|
|
|
|
|
|
|
if ( be_monitor == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
2005-09-08 22:32:09 +08:00
|
|
|
"monitor database not configured.\n",
|
2005-09-08 22:23:35 +08:00
|
|
|
e->e_name.bv_val, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi = ( monitor_info_t * )be_monitor->be_private;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
|
|
|
assert( mi != NULL );
|
|
|
|
assert( e != NULL );
|
|
|
|
assert( e->e_private == NULL );
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
if ( monitor_subsys_is_opened() ) {
|
2004-11-12 20:54:42 +08:00
|
|
|
Entry *e_parent = NULL,
|
|
|
|
*e_new = NULL,
|
|
|
|
**ep = NULL;
|
|
|
|
struct berval pdn = BER_BVNULL;
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_entry_t *mp = NULL,
|
2004-11-12 20:54:42 +08:00
|
|
|
*mp_parent = NULL;
|
|
|
|
int rc = 0;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
if ( monitor_cache_get( mi, &e->e_nname, &e_parent ) == 0 ) {
|
2004-11-09 02:52:27 +08:00
|
|
|
/* entry exists */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"entry exists\n",
|
|
|
|
e->e_name.bv_val, 0, 0 );
|
2004-11-12 20:54:42 +08:00
|
|
|
monitor_cache_release( mi, e_parent );
|
2004-11-09 02:52:27 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
dnParent( &e->e_nname, &pdn );
|
2004-11-12 20:54:42 +08:00
|
|
|
if ( monitor_cache_get( mi, &pdn, &e_parent ) != 0 ) {
|
2004-11-09 02:52:27 +08:00
|
|
|
/* parent does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"parent \"%s\" not found\n",
|
|
|
|
e->e_name.bv_val, pdn.bv_val, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
assert( e_parent->e_private != NULL );
|
|
|
|
mp_parent = ( monitor_entry_t * )e_parent->e_private;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
if ( mp_parent->mp_flags & MONITOR_F_VOLATILE ) {
|
2004-11-09 02:52:27 +08:00
|
|
|
/* entry is volatile; cannot append children */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"parent \"%s\" is volatile\n",
|
2004-11-12 20:54:42 +08:00
|
|
|
e->e_name.bv_val, e_parent->e_name.bv_val, 0 );
|
|
|
|
rc = -1;
|
|
|
|
goto done;
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
mp = monitor_entrypriv_create();
|
|
|
|
if ( mp == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
2004-11-12 20:54:42 +08:00
|
|
|
"monitor_entrypriv_create() failed\n",
|
2004-11-09 02:52:27 +08:00
|
|
|
e->e_name.bv_val, 0, 0 );
|
2004-11-12 20:54:42 +08:00
|
|
|
rc = -1;
|
|
|
|
goto done;
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
e_new = entry_dup( e );
|
2005-04-27 10:43:38 +08:00
|
|
|
if ( e_new == NULL ) {
|
2004-11-12 20:54:42 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"entry_dup() failed\n",
|
|
|
|
e->e_name.bv_val, 0, 0 );
|
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
e_new->e_private = ( void * )mp;
|
2006-09-09 06:02:32 +08:00
|
|
|
if ( mss != NULL ) {
|
|
|
|
mp->mp_info = mss;
|
|
|
|
mp->mp_flags = flags;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
mp->mp_info = mp_parent->mp_info;
|
|
|
|
mp->mp_flags = mp_parent->mp_flags | MONITOR_F_SUB;
|
|
|
|
}
|
2005-04-27 10:43:38 +08:00
|
|
|
mp->mp_cb = cb;
|
2004-11-12 20:54:42 +08:00
|
|
|
|
|
|
|
ep = &mp_parent->mp_children;
|
2004-11-09 02:52:27 +08:00
|
|
|
for ( ; *ep; ) {
|
2004-11-12 20:54:42 +08:00
|
|
|
mp_parent = ( monitor_entry_t * )(*ep)->e_private;
|
|
|
|
ep = &mp_parent->mp_next;
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
2004-11-12 20:54:42 +08:00
|
|
|
*ep = e_new;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
if ( monitor_cache_add( mi, e_new ) ) {
|
2004-11-09 02:52:27 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"unable to add entry\n",
|
|
|
|
e->e_name.bv_val, 0, 0 );
|
2004-11-12 20:54:42 +08:00
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:;
|
|
|
|
if ( rc ) {
|
|
|
|
if ( mp ) {
|
|
|
|
ch_free( mp );
|
|
|
|
}
|
|
|
|
if ( e_new ) {
|
|
|
|
e_new->e_private = NULL;
|
|
|
|
entry_free( e_new );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( e_parent ) {
|
|
|
|
monitor_cache_release( mi, e_parent );
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2005-04-27 10:43:38 +08:00
|
|
|
entry_limbo_t **elpp, el = { 0 };
|
2004-11-12 20:54:42 +08:00
|
|
|
|
|
|
|
el.el_type = LIMBO_ENTRY;
|
|
|
|
|
|
|
|
el.el_e = entry_dup( e );
|
|
|
|
if ( el.el_e == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"entry_dup() failed\n",
|
|
|
|
e->e_name.bv_val, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
el.el_cb = cb;
|
2006-09-09 06:02:32 +08:00
|
|
|
el.el_mss = mss;
|
|
|
|
el.el_flags = flags;
|
2004-11-12 20:54:42 +08:00
|
|
|
|
2007-06-16 02:24:01 +08:00
|
|
|
for ( elpp = &mi->mi_entry_limbo;
|
2005-04-27 10:43:38 +08:00
|
|
|
*elpp;
|
|
|
|
elpp = &(*elpp)->el_next )
|
|
|
|
/* go to last */;
|
|
|
|
|
|
|
|
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
|
|
|
|
if ( *elpp == NULL ) {
|
|
|
|
el.el_e->e_private = NULL;
|
|
|
|
entry_free( el.el_e );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
el.el_next = NULL;
|
|
|
|
**elpp = el;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_register_entry_parent(
|
2005-04-28 05:30:35 +08:00
|
|
|
Entry *e,
|
|
|
|
monitor_callback_t *cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
monitor_subsys_t *mss,
|
|
|
|
unsigned long flags,
|
|
|
|
struct berval *nbase,
|
2005-04-28 05:30:35 +08:00
|
|
|
int scope,
|
|
|
|
struct berval *filter )
|
2005-04-27 10:43:38 +08:00
|
|
|
{
|
2005-09-08 22:23:35 +08:00
|
|
|
monitor_info_t *mi;
|
2005-04-27 10:43:38 +08:00
|
|
|
struct berval ndn = BER_BVNULL;
|
|
|
|
|
2005-09-08 22:23:35 +08:00
|
|
|
if ( be_monitor == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry_parent(base=\"%s\" scope=%s filter=\"%s\"): "
|
2005-09-08 22:32:09 +08:00
|
|
|
"monitor database not configured.\n",
|
2006-09-09 06:02:32 +08:00
|
|
|
BER_BVISNULL( nbase ) ? "" : nbase->bv_val,
|
2006-09-06 20:06:42 +08:00
|
|
|
ldap_pvt_scope2str( scope ),
|
2005-09-08 22:23:35 +08:00
|
|
|
BER_BVISNULL( filter ) ? "" : filter->bv_val );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi = ( monitor_info_t * )be_monitor->be_private;
|
|
|
|
|
2005-04-27 10:43:38 +08:00
|
|
|
assert( mi != NULL );
|
|
|
|
assert( e != NULL );
|
|
|
|
assert( e->e_private == NULL );
|
|
|
|
|
|
|
|
if ( BER_BVISNULL( filter ) ) {
|
|
|
|
/* need a filter */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry_parent(\"\"): "
|
|
|
|
"need a valid filter\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
if ( monitor_subsys_is_opened() ) {
|
2005-04-27 10:43:38 +08:00
|
|
|
Entry *e_parent = NULL,
|
|
|
|
*e_new = NULL,
|
|
|
|
**ep = NULL;
|
|
|
|
struct berval e_name = BER_BVNULL,
|
|
|
|
e_nname = BER_BVNULL;
|
|
|
|
monitor_entry_t *mp = NULL,
|
|
|
|
*mp_parent = NULL;
|
|
|
|
int rc = 0;
|
|
|
|
|
2006-09-09 10:35:58 +08:00
|
|
|
if ( monitor_search2ndn( nbase, scope, filter, &ndn ) ) {
|
2005-04-27 10:43:38 +08:00
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2005-04-29 09:42:24 +08:00
|
|
|
"monitor_back_register_entry_parent(\"\"): "
|
2006-09-15 08:16:35 +08:00
|
|
|
"base=\"%s\" scope=%s filter=\"%s\": "
|
2005-04-27 10:43:38 +08:00
|
|
|
"unable to find entry\n",
|
2006-09-09 06:02:32 +08:00
|
|
|
nbase->bv_val ? nbase->bv_val : "\"\"",
|
2006-09-15 08:16:35 +08:00
|
|
|
ldap_pvt_scope2str( scope ),
|
|
|
|
filter->bv_val );
|
2005-04-27 10:43:38 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( monitor_cache_get( mi, &ndn, &e_parent ) != 0 ) {
|
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry_parent(\"%s\"): "
|
|
|
|
"parent entry does not exist\n",
|
|
|
|
ndn.bv_val, 0, 0 );
|
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert( e_parent->e_private != NULL );
|
|
|
|
mp_parent = ( monitor_entry_t * )e_parent->e_private;
|
|
|
|
|
|
|
|
if ( mp_parent->mp_flags & MONITOR_F_VOLATILE ) {
|
|
|
|
/* entry is volatile; cannot append callback */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2005-04-29 09:42:24 +08:00
|
|
|
"monitor_back_register_entry_parent(\"%s\"): "
|
2005-04-27 10:43:38 +08:00
|
|
|
"entry is volatile\n",
|
|
|
|
e_parent->e_name.bv_val, 0, 0 );
|
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
build_new_dn( &e_name, &e_parent->e_name, &e->e_name, NULL );
|
|
|
|
build_new_dn( &e_nname, &e_parent->e_nname, &e->e_nname, NULL );
|
|
|
|
|
|
|
|
if ( monitor_cache_get( mi, &e_nname, &e_new ) == 0 ) {
|
|
|
|
/* entry already exists */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry_parent(\"%s\"): "
|
|
|
|
"entry already exists\n",
|
|
|
|
e_name.bv_val, 0, 0 );
|
|
|
|
monitor_cache_release( mi, e_new );
|
2006-09-09 10:35:58 +08:00
|
|
|
e_new = NULL;
|
2005-04-27 10:43:38 +08:00
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
mp = monitor_entrypriv_create();
|
|
|
|
if ( mp == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry_parent(\"%s\"): "
|
|
|
|
"monitor_entrypriv_create() failed\n",
|
|
|
|
e->e_name.bv_val, 0, 0 );
|
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
e_new = entry_dup( e );
|
|
|
|
if ( e_new == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"entry_dup() failed\n",
|
|
|
|
e->e_name.bv_val, 0, 0 );
|
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ch_free( e_new->e_name.bv_val );
|
|
|
|
ch_free( e_new->e_nname.bv_val );
|
|
|
|
e_new->e_name = e_name;
|
|
|
|
e_new->e_nname = e_nname;
|
|
|
|
|
|
|
|
e_new->e_private = ( void * )mp;
|
2006-09-09 06:02:32 +08:00
|
|
|
if ( mss != NULL ) {
|
|
|
|
mp->mp_info = mss;
|
|
|
|
mp->mp_flags = flags;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
mp->mp_info = mp_parent->mp_info;
|
|
|
|
mp->mp_flags = mp_parent->mp_flags | MONITOR_F_SUB;
|
|
|
|
}
|
2005-04-27 10:43:38 +08:00
|
|
|
mp->mp_cb = cb;
|
|
|
|
|
|
|
|
ep = &mp_parent->mp_children;
|
|
|
|
for ( ; *ep; ) {
|
|
|
|
mp_parent = ( monitor_entry_t * )(*ep)->e_private;
|
|
|
|
ep = &mp_parent->mp_next;
|
|
|
|
}
|
|
|
|
*ep = e_new;
|
|
|
|
|
|
|
|
if ( monitor_cache_add( mi, e_new ) ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"unable to add entry\n",
|
|
|
|
e->e_name.bv_val, 0, 0 );
|
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:;
|
|
|
|
if ( !BER_BVISNULL( &ndn ) ) {
|
|
|
|
ch_free( ndn.bv_val );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rc ) {
|
|
|
|
if ( mp ) {
|
|
|
|
ch_free( mp );
|
|
|
|
}
|
|
|
|
if ( e_new ) {
|
|
|
|
e_new->e_private = NULL;
|
|
|
|
entry_free( e_new );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( e_parent ) {
|
|
|
|
monitor_cache_release( mi, e_parent );
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2006-09-09 06:02:32 +08:00
|
|
|
entry_limbo_t **elpp = NULL, el = { 0 };
|
2005-04-27 10:43:38 +08:00
|
|
|
|
|
|
|
el.el_type = LIMBO_ENTRY_PARENT;
|
|
|
|
|
|
|
|
el.el_e = entry_dup( e );
|
|
|
|
if ( el.el_e == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry(\"%s\"): "
|
|
|
|
"entry_dup() failed\n",
|
|
|
|
e->e_name.bv_val, 0, 0 );
|
2006-09-09 06:02:32 +08:00
|
|
|
goto done_limbo;
|
2005-04-27 10:43:38 +08:00
|
|
|
}
|
|
|
|
|
2006-09-09 06:02:32 +08:00
|
|
|
if ( !BER_BVISNULL( nbase ) ) {
|
|
|
|
ber_dupbv( &el.el_nbase, nbase );
|
2005-04-27 10:43:38 +08:00
|
|
|
}
|
2006-09-09 06:02:32 +08:00
|
|
|
|
2005-04-27 10:43:38 +08:00
|
|
|
el.el_scope = scope;
|
|
|
|
if ( !BER_BVISNULL( filter ) ) {
|
2006-09-09 10:35:58 +08:00
|
|
|
ber_dupbv( &el.el_filter, filter );
|
2005-04-27 10:43:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
el.el_cb = cb;
|
2006-09-09 06:02:32 +08:00
|
|
|
el.el_mss = mss;
|
|
|
|
el.el_flags = flags;
|
2005-04-27 10:43:38 +08:00
|
|
|
|
2007-06-16 02:24:01 +08:00
|
|
|
for ( elpp = &mi->mi_entry_limbo;
|
2005-04-27 10:43:38 +08:00
|
|
|
*elpp;
|
|
|
|
elpp = &(*elpp)->el_next )
|
|
|
|
/* go to last */;
|
|
|
|
|
|
|
|
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
|
|
|
|
if ( *elpp == NULL ) {
|
2006-09-09 06:02:32 +08:00
|
|
|
goto done_limbo;
|
|
|
|
}
|
|
|
|
|
|
|
|
done_limbo:;
|
|
|
|
if ( *elpp != NULL ) {
|
|
|
|
el.el_next = NULL;
|
|
|
|
**elpp = el;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if ( !BER_BVISNULL( &el.el_filter ) ) {
|
|
|
|
ch_free( el.el_filter.bv_val );
|
|
|
|
}
|
|
|
|
if ( !BER_BVISNULL( &el.el_nbase ) ) {
|
|
|
|
ch_free( el.el_nbase.bv_val );
|
|
|
|
}
|
2004-11-12 20:54:42 +08:00
|
|
|
entry_free( el.el_e );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
static int
|
2006-09-09 10:35:58 +08:00
|
|
|
monitor_search2ndn_cb( Operation *op, SlapReply *rs )
|
2004-11-12 20:54:42 +08:00
|
|
|
{
|
|
|
|
if ( rs->sr_type == REP_SEARCH ) {
|
|
|
|
struct berval *ndn = op->o_callback->sc_private;
|
2006-09-09 10:35:58 +08:00
|
|
|
|
|
|
|
if ( !BER_BVISNULL( ndn ) ) {
|
|
|
|
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
|
|
|
|
ch_free( ndn->bv_val );
|
|
|
|
BER_BVZERO( ndn );
|
|
|
|
return rs->sr_err;
|
|
|
|
}
|
2004-11-12 20:54:42 +08:00
|
|
|
|
|
|
|
ber_dupbv( ndn, &rs->sr_entry->e_nname );
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-09-09 10:35:58 +08:00
|
|
|
monitor_search2ndn(
|
2006-09-09 06:02:32 +08:00
|
|
|
struct berval *nbase,
|
2005-04-28 05:30:35 +08:00
|
|
|
int scope,
|
|
|
|
struct berval *filter,
|
|
|
|
struct berval *ndn )
|
2004-11-12 20:54:42 +08:00
|
|
|
{
|
|
|
|
Connection conn = { 0 };
|
2005-10-13 07:17:28 +08:00
|
|
|
OperationBuffer opbuf;
|
2004-11-27 08:57:37 +08:00
|
|
|
Operation *op;
|
2007-01-25 18:01:51 +08:00
|
|
|
void *thrctx;
|
2004-11-12 20:54:42 +08:00
|
|
|
SlapReply rs = { 0 };
|
2006-09-09 10:35:58 +08:00
|
|
|
slap_callback cb = { NULL, monitor_search2ndn_cb, NULL, NULL };
|
2004-11-12 20:54:42 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
BER_BVZERO( ndn );
|
|
|
|
|
|
|
|
if ( be_monitor == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-01-25 18:01:51 +08:00
|
|
|
thrctx = ldap_pvt_thread_pool_context();
|
2007-05-19 07:54:26 +08:00
|
|
|
connection_fake_init( &conn, &opbuf, thrctx );
|
|
|
|
op = &opbuf.ob_op;
|
2004-11-12 20:54:42 +08:00
|
|
|
|
2004-11-27 08:57:37 +08:00
|
|
|
op->o_tag = LDAP_REQ_SEARCH;
|
2004-11-12 20:54:42 +08:00
|
|
|
|
2007-01-28 02:38:24 +08:00
|
|
|
/* use global malloc for now */
|
|
|
|
if ( op->o_tmpmemctx ) {
|
|
|
|
op->o_tmpmemctx = NULL;
|
|
|
|
}
|
|
|
|
op->o_tmpmfuncs = &ch_mfuncs;
|
|
|
|
|
2004-11-27 08:57:37 +08:00
|
|
|
op->o_bd = be_monitor;
|
2006-09-09 06:02:32 +08:00
|
|
|
if ( nbase == NULL || BER_BVISNULL( nbase ) ) {
|
2004-11-27 08:57:37 +08:00
|
|
|
ber_dupbv_x( &op->o_req_dn, &op->o_bd->be_suffix[ 0 ],
|
|
|
|
op->o_tmpmemctx );
|
|
|
|
ber_dupbv_x( &op->o_req_ndn, &op->o_bd->be_nsuffix[ 0 ],
|
|
|
|
op->o_tmpmemctx );
|
2004-11-12 20:54:42 +08:00
|
|
|
|
|
|
|
} else {
|
2006-09-09 06:02:32 +08:00
|
|
|
if ( dnPrettyNormal( NULL, nbase, &op->o_req_dn, &op->o_req_ndn,
|
2004-11-27 08:57:37 +08:00
|
|
|
op->o_tmpmemctx ) ) {
|
2005-07-19 22:39:43 +08:00
|
|
|
return -1;
|
2004-11-12 20:54:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-27 08:57:37 +08:00
|
|
|
op->o_callback = &cb;
|
2004-11-12 20:54:42 +08:00
|
|
|
cb.sc_private = (void *)ndn;
|
|
|
|
|
2004-11-27 08:57:37 +08:00
|
|
|
op->ors_scope = scope;
|
|
|
|
op->ors_filter = str2filter_x( op, filter->bv_val );
|
2006-09-06 23:12:36 +08:00
|
|
|
if ( op->ors_filter == NULL ) {
|
|
|
|
rc = LDAP_OTHER;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
ber_dupbv_x( &op->ors_filterstr, filter, op->o_tmpmemctx );
|
2005-04-27 10:43:38 +08:00
|
|
|
op->ors_attrs = slap_anlist_no_attrs;
|
2004-11-27 08:57:37 +08:00
|
|
|
op->ors_attrsonly = 0;
|
|
|
|
op->ors_tlimit = SLAP_NO_LIMIT;
|
|
|
|
op->ors_slimit = 1;
|
|
|
|
op->ors_limit = NULL;
|
|
|
|
op->ors_deref = LDAP_DEREF_NEVER;
|
2004-11-12 20:54:42 +08:00
|
|
|
|
2004-11-27 08:57:37 +08:00
|
|
|
op->o_nocaching = 1;
|
|
|
|
op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
|
2004-11-12 20:54:42 +08:00
|
|
|
|
2005-04-29 09:42:24 +08:00
|
|
|
op->o_dn = be_monitor->be_rootdn;
|
|
|
|
op->o_ndn = be_monitor->be_rootndn;
|
|
|
|
|
2004-11-27 08:57:37 +08:00
|
|
|
rc = op->o_bd->be_search( op, &rs );
|
2004-11-12 20:54:42 +08:00
|
|
|
|
2006-09-06 23:12:36 +08:00
|
|
|
cleanup:;
|
|
|
|
if ( op->ors_filter != NULL ) {
|
|
|
|
filter_free_x( op, op->ors_filter );
|
|
|
|
}
|
|
|
|
if ( !BER_BVISNULL( &op->ors_filterstr ) ) {
|
|
|
|
op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
|
|
|
|
}
|
2007-01-25 18:33:28 +08:00
|
|
|
if ( !BER_BVISNULL( &op->o_req_dn ) ) {
|
|
|
|
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
|
|
|
|
}
|
2007-01-28 02:38:24 +08:00
|
|
|
if ( !BER_BVISNULL( &op->o_req_ndn ) ) {
|
|
|
|
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
|
|
|
|
}
|
2004-11-12 20:54:42 +08:00
|
|
|
|
|
|
|
if ( rc != 0 ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( rs.sr_err ) {
|
|
|
|
case LDAP_SUCCESS:
|
|
|
|
if ( BER_BVISNULL( ndn ) ) {
|
|
|
|
rc = -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_SIZELIMIT_EXCEEDED:
|
|
|
|
default:
|
|
|
|
if ( !BER_BVISNULL( ndn ) ) {
|
|
|
|
ber_memfree( ndn->bv_val );
|
|
|
|
BER_BVZERO( ndn );
|
|
|
|
}
|
|
|
|
rc = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_register_entry_attrs(
|
2005-04-28 05:30:35 +08:00
|
|
|
struct berval *ndn_in,
|
|
|
|
Attribute *a,
|
|
|
|
monitor_callback_t *cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
struct berval *nbase,
|
2005-04-28 05:30:35 +08:00
|
|
|
int scope,
|
|
|
|
struct berval *filter )
|
2004-11-09 02:52:27 +08:00
|
|
|
{
|
2005-09-08 22:23:35 +08:00
|
|
|
monitor_info_t *mi;
|
2004-11-12 20:54:42 +08:00
|
|
|
struct berval ndn = BER_BVNULL;
|
2005-09-08 22:23:35 +08:00
|
|
|
char *fname = ( a == NULL ? "callback" : "attrs" );
|
|
|
|
|
|
|
|
if ( be_monitor == NULL ) {
|
|
|
|
char buf[ SLAP_TEXT_BUFLEN ];
|
|
|
|
|
|
|
|
snprintf( buf, sizeof( buf ),
|
|
|
|
"monitor_back_register_entry_%s(base=\"%s\" scope=%s filter=\"%s\"): "
|
2005-09-08 22:32:09 +08:00
|
|
|
"monitor database not configured.\n",
|
2005-09-08 22:23:35 +08:00
|
|
|
fname,
|
2006-09-09 06:02:32 +08:00
|
|
|
BER_BVISNULL( nbase ) ? "" : nbase->bv_val,
|
2006-09-06 20:06:42 +08:00
|
|
|
ldap_pvt_scope2str( scope ),
|
2005-09-08 22:23:35 +08:00
|
|
|
BER_BVISNULL( filter ) ? "" : filter->bv_val );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s\n", buf, 0, 0 );
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi = ( monitor_info_t * )be_monitor->be_private;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
|
|
|
assert( mi != NULL );
|
2004-11-12 20:54:42 +08:00
|
|
|
|
|
|
|
if ( ndn_in != NULL ) {
|
|
|
|
ndn = *ndn_in;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( a == NULL && cb == NULL ) {
|
|
|
|
/* nothing to do */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( ndn_in == NULL || BER_BVISNULL( &ndn ) )
|
|
|
|
&& BER_BVISNULL( filter ) )
|
|
|
|
{
|
|
|
|
/* need a filter */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2005-09-08 22:23:35 +08:00
|
|
|
"monitor_back_register_entry_%s(\"\"): "
|
2004-11-12 20:54:42 +08:00
|
|
|
"need a valid filter\n",
|
2005-09-08 22:23:35 +08:00
|
|
|
fname, 0, 0 );
|
2004-11-12 20:54:42 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
if ( monitor_subsys_is_opened() ) {
|
2004-11-09 02:52:27 +08:00
|
|
|
Entry *e = NULL;
|
2004-11-12 20:54:42 +08:00
|
|
|
Attribute **atp = NULL;
|
|
|
|
monitor_entry_t *mp = NULL;
|
|
|
|
monitor_callback_t **mcp = NULL;
|
|
|
|
int rc = 0;
|
|
|
|
int freeit = 0;
|
|
|
|
|
|
|
|
if ( BER_BVISNULL( &ndn ) ) {
|
2006-09-09 10:35:58 +08:00
|
|
|
if ( monitor_search2ndn( nbase, scope, filter, &ndn ) ) {
|
2005-09-08 22:23:35 +08:00
|
|
|
char buf[ SLAP_TEXT_BUFLEN ];
|
|
|
|
|
|
|
|
snprintf( buf, sizeof( buf ),
|
|
|
|
"monitor_back_register_entry_%s(\"\"): "
|
2006-09-15 08:16:35 +08:00
|
|
|
"base=\"%s\" scope=%s filter=\"%s\": "
|
2004-11-12 20:54:42 +08:00
|
|
|
"unable to find entry\n",
|
2005-09-08 22:23:35 +08:00
|
|
|
fname,
|
2006-09-09 06:02:32 +08:00
|
|
|
nbase->bv_val ? nbase->bv_val : "\"\"",
|
2006-09-15 08:16:35 +08:00
|
|
|
ldap_pvt_scope2str( scope ),
|
|
|
|
filter->bv_val );
|
2005-09-08 22:23:35 +08:00
|
|
|
|
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s\n", buf, 0, 0 );
|
2004-11-12 20:54:42 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
freeit = 1;
|
|
|
|
}
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
if ( monitor_cache_get( mi, &ndn, &e ) != 0 ) {
|
2004-11-09 02:52:27 +08:00
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2005-09-08 22:23:35 +08:00
|
|
|
"monitor_back_register_entry_%s(\"%s\"): "
|
2004-11-09 02:52:27 +08:00
|
|
|
"entry does not exist\n",
|
2005-09-08 22:23:35 +08:00
|
|
|
fname, ndn.bv_val, 0 );
|
2004-11-12 20:54:42 +08:00
|
|
|
rc = -1;
|
|
|
|
goto done;
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
assert( e->e_private != NULL );
|
|
|
|
mp = ( monitor_entry_t * )e->e_private;
|
|
|
|
|
|
|
|
if ( mp->mp_flags & MONITOR_F_VOLATILE ) {
|
|
|
|
/* entry is volatile; cannot append callback */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2005-09-08 22:23:35 +08:00
|
|
|
"monitor_back_register_entry_%s(\"%s\"): "
|
2004-11-09 02:52:27 +08:00
|
|
|
"entry is volatile\n",
|
2005-09-08 22:23:35 +08:00
|
|
|
fname, e->e_name.bv_val, 0 );
|
2004-11-12 20:54:42 +08:00
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( a ) {
|
|
|
|
for ( atp = &e->e_attrs; *atp; atp = &(*atp)->a_next )
|
|
|
|
/* just get to last */ ;
|
|
|
|
|
2006-09-06 09:54:54 +08:00
|
|
|
for ( ; a != NULL; a = a->a_next ) {
|
|
|
|
assert( a->a_desc != NULL );
|
|
|
|
assert( a->a_vals != NULL );
|
|
|
|
|
|
|
|
if ( attr_find( e->e_attrs, a->a_desc ) ) {
|
|
|
|
attr_merge( e, a->a_desc, a->a_vals,
|
|
|
|
a->a_nvals == a->a_vals ? NULL : a->a_nvals );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
*atp = attr_dup( a );
|
|
|
|
if ( *atp == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_register_entry_%s(\"%s\"): "
|
|
|
|
"attr_dup() failed\n",
|
|
|
|
fname, e->e_name.bv_val, 0 );
|
|
|
|
rc = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
atp = &(*atp)->a_next;
|
|
|
|
}
|
2004-11-12 20:54:42 +08:00
|
|
|
}
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
if ( cb ) {
|
|
|
|
for ( mcp = &mp->mp_cb; *mcp; mcp = &(*mcp)->mc_next )
|
|
|
|
/* go to tail */ ;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
/* NOTE: we do not clear cb->mc_next, so this function
|
|
|
|
* can be used to append a list of callbacks */
|
|
|
|
(*mcp) = cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:;
|
|
|
|
if ( rc ) {
|
2006-03-31 18:45:23 +08:00
|
|
|
if ( atp && *atp ) {
|
2004-11-12 20:54:42 +08:00
|
|
|
attrs_free( *atp );
|
|
|
|
*atp = NULL;
|
|
|
|
}
|
|
|
|
}
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
if ( freeit ) {
|
|
|
|
ber_memfree( ndn.bv_val );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( e ) {
|
|
|
|
monitor_cache_release( mi, e );
|
|
|
|
}
|
2004-11-09 02:52:27 +08:00
|
|
|
|
|
|
|
} else {
|
2005-04-27 10:43:38 +08:00
|
|
|
entry_limbo_t **elpp, el = { 0 };
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
el.el_type = LIMBO_ATTRS;
|
2007-09-15 23:34:49 +08:00
|
|
|
el.el_ndn = ndn_in;
|
2006-09-09 06:02:32 +08:00
|
|
|
if ( !BER_BVISNULL( nbase ) ) {
|
|
|
|
ber_dupbv( &el.el_nbase, nbase);
|
2004-11-12 20:54:42 +08:00
|
|
|
}
|
|
|
|
el.el_scope = scope;
|
|
|
|
if ( !BER_BVISNULL( filter ) ) {
|
2006-09-09 10:35:58 +08:00
|
|
|
ber_dupbv( &el.el_filter, filter );
|
2004-11-12 20:54:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
el.el_a = attrs_dup( a );
|
|
|
|
el.el_cb = cb;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2007-06-16 02:24:01 +08:00
|
|
|
for ( elpp = &mi->mi_entry_limbo;
|
2005-04-27 10:43:38 +08:00
|
|
|
*elpp;
|
|
|
|
elpp = &(*elpp)->el_next )
|
|
|
|
/* go to last */;
|
|
|
|
|
|
|
|
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) );
|
|
|
|
if ( *elpp == NULL ) {
|
|
|
|
el.el_e->e_private = NULL;
|
|
|
|
entry_free( el.el_e );
|
2004-11-12 20:54:42 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-09-09 06:02:32 +08:00
|
|
|
if ( *elpp != NULL ) {
|
|
|
|
el.el_next = NULL;
|
|
|
|
**elpp = el;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if ( !BER_BVISNULL( &el.el_filter ) ) {
|
|
|
|
ch_free( el.el_filter.bv_val );
|
|
|
|
}
|
|
|
|
if ( el.el_a != NULL ) {
|
|
|
|
attrs_free( el.el_a );
|
|
|
|
}
|
|
|
|
if ( !BER_BVISNULL( &el.el_nbase ) ) {
|
|
|
|
ch_free( &el.el_nbase.bv_val );
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
int
|
|
|
|
monitor_back_register_entry_callback(
|
2005-04-28 05:30:35 +08:00
|
|
|
struct berval *ndn,
|
|
|
|
monitor_callback_t *cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
struct berval *nbase,
|
2005-04-28 05:30:35 +08:00
|
|
|
int scope,
|
|
|
|
struct berval *filter )
|
2004-11-12 20:54:42 +08:00
|
|
|
{
|
|
|
|
return monitor_back_register_entry_attrs( ndn, NULL, cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
nbase, scope, filter );
|
2004-11-12 20:54:42 +08:00
|
|
|
}
|
|
|
|
|
2006-09-06 09:54:54 +08:00
|
|
|
/*
|
|
|
|
* TODO: add corresponding calls to remove installed callbacks, entries
|
|
|
|
* and so, in case the entity that installed them is removed (e.g. a
|
|
|
|
* database, via back-config)
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
monitor_back_unregister_entry(
|
2006-09-09 06:02:32 +08:00
|
|
|
struct berval *ndn )
|
2006-09-06 09:54:54 +08:00
|
|
|
{
|
2006-09-06 20:06:42 +08:00
|
|
|
monitor_info_t *mi;
|
2006-09-06 09:54:54 +08:00
|
|
|
|
2006-09-06 20:06:42 +08:00
|
|
|
if ( be_monitor == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_unregister_entry(\"%s\"): "
|
|
|
|
"monitor database not configured.\n",
|
2006-09-09 06:02:32 +08:00
|
|
|
ndn->bv_val, 0, 0 );
|
2006-09-06 20:06:42 +08:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-09-10 00:25:32 +08:00
|
|
|
/* entry will be regularly freed, and resources released
|
|
|
|
* according to callbacks */
|
|
|
|
if ( slapd_shutdown ) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-06 20:06:42 +08:00
|
|
|
mi = ( monitor_info_t * )be_monitor->be_private;
|
|
|
|
|
|
|
|
assert( mi != NULL );
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
if ( monitor_subsys_is_opened() ) {
|
2006-09-06 20:06:42 +08:00
|
|
|
Entry *e = NULL;
|
|
|
|
monitor_entry_t *mp = NULL;
|
|
|
|
monitor_callback_t *cb = NULL;
|
|
|
|
|
2006-09-09 06:02:32 +08:00
|
|
|
if ( monitor_cache_remove( mi, ndn, &e ) != 0 ) {
|
2006-09-06 20:06:42 +08:00
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_unregister_entry(\"%s\"): "
|
|
|
|
"entry removal failed.\n",
|
2006-09-09 06:02:32 +08:00
|
|
|
ndn->bv_val, 0, 0 );
|
2006-09-06 20:06:42 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mp = (monitor_entry_t *)e->e_private;
|
|
|
|
assert( mp != NULL );
|
|
|
|
|
|
|
|
for ( cb = mp->mp_cb; cb != NULL; ) {
|
|
|
|
monitor_callback_t *next = cb->mc_next;
|
|
|
|
|
|
|
|
if ( cb->mc_free ) {
|
2006-12-24 23:44:56 +08:00
|
|
|
(void)cb->mc_free( e, &cb->mc_private );
|
2006-09-06 20:06:42 +08:00
|
|
|
}
|
|
|
|
ch_free( cb );
|
|
|
|
|
|
|
|
cb = next;
|
|
|
|
}
|
|
|
|
|
2006-09-09 06:02:32 +08:00
|
|
|
ch_free( mp );
|
|
|
|
e->e_private = NULL;
|
|
|
|
entry_free( e );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
entry_limbo_t **elpp;
|
|
|
|
|
2007-06-16 02:24:01 +08:00
|
|
|
for ( elpp = &mi->mi_entry_limbo;
|
2006-09-09 06:02:32 +08:00
|
|
|
*elpp;
|
|
|
|
elpp = &(*elpp)->el_next )
|
|
|
|
{
|
|
|
|
entry_limbo_t *elp = *elpp;
|
|
|
|
|
|
|
|
if ( elp->el_type == LIMBO_ENTRY
|
|
|
|
&& dn_match( ndn, &elp->el_e->e_nname ) )
|
|
|
|
{
|
|
|
|
monitor_callback_t *cb, *next;
|
|
|
|
|
|
|
|
for ( cb = elp->el_cb; cb; cb = next ) {
|
|
|
|
/* FIXME: call callbacks? */
|
|
|
|
next = cb->mc_next;
|
2007-08-27 15:12:12 +08:00
|
|
|
if ( cb->mc_dispose ) {
|
|
|
|
cb->mc_dispose( &cb->mc_private );
|
|
|
|
}
|
2006-09-09 06:02:32 +08:00
|
|
|
ch_free( cb );
|
|
|
|
}
|
|
|
|
assert( elp->el_e != NULL );
|
|
|
|
elp->el_e->e_private = NULL;
|
|
|
|
entry_free( elp->el_e );
|
|
|
|
*elpp = elp->el_next;
|
|
|
|
ch_free( elp );
|
|
|
|
elpp = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( elpp != NULL ) {
|
|
|
|
/* not found! where did it go? */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_unregister_entry_parent(
|
|
|
|
struct berval *nrdn,
|
|
|
|
monitor_callback_t *target_cb,
|
|
|
|
struct berval *nbase,
|
|
|
|
int scope,
|
|
|
|
struct berval *filter )
|
|
|
|
{
|
|
|
|
monitor_info_t *mi;
|
|
|
|
struct berval ndn = BER_BVNULL;
|
|
|
|
|
|
|
|
if ( be_monitor == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_unregister_entry_parent(base=\"%s\" scope=%s filter=\"%s\"): "
|
|
|
|
"monitor database not configured.\n",
|
|
|
|
BER_BVISNULL( nbase ) ? "" : nbase->bv_val,
|
|
|
|
ldap_pvt_scope2str( scope ),
|
|
|
|
BER_BVISNULL( filter ) ? "" : filter->bv_val );
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-09-10 00:25:32 +08:00
|
|
|
/* entry will be regularly freed, and resources released
|
|
|
|
* according to callbacks */
|
|
|
|
if ( slapd_shutdown ) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-09 06:02:32 +08:00
|
|
|
mi = ( monitor_info_t * )be_monitor->be_private;
|
|
|
|
|
|
|
|
assert( mi != NULL );
|
|
|
|
|
|
|
|
if ( ( nrdn == NULL || BER_BVISNULL( nrdn ) )
|
|
|
|
&& BER_BVISNULL( filter ) )
|
|
|
|
{
|
|
|
|
/* need a filter */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_unregister_entry_parent(\"\"): "
|
|
|
|
"need a valid filter\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
if ( monitor_subsys_is_opened() ) {
|
2006-09-09 06:02:32 +08:00
|
|
|
Entry *e = NULL;
|
|
|
|
monitor_entry_t *mp = NULL;
|
|
|
|
|
2006-09-09 10:35:58 +08:00
|
|
|
if ( monitor_search2ndn( nbase, scope, filter, &ndn ) ) {
|
2006-09-09 06:02:32 +08:00
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_unregister_entry_parent(\"\"): "
|
|
|
|
"base=\"%s\" scope=%s filter=\"%s\": "
|
|
|
|
"unable to find entry\n",
|
|
|
|
nbase->bv_val ? nbase->bv_val : "\"\"",
|
|
|
|
ldap_pvt_scope2str( scope ),
|
|
|
|
filter->bv_val );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( monitor_cache_remove( mi, &ndn, &e ) != 0 ) {
|
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_unregister_entry(\"%s\"): "
|
|
|
|
"entry removal failed.\n",
|
|
|
|
ndn.bv_val, 0, 0 );
|
|
|
|
ber_memfree( ndn.bv_val );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ber_memfree( ndn.bv_val );
|
|
|
|
|
|
|
|
mp = (monitor_entry_t *)e->e_private;
|
|
|
|
assert( mp != NULL );
|
|
|
|
|
|
|
|
if ( target_cb != NULL ) {
|
|
|
|
monitor_callback_t **cbp;
|
|
|
|
|
|
|
|
for ( cbp = &mp->mp_cb; *cbp != NULL; cbp = &(*cbp)->mc_next ) {
|
|
|
|
if ( *cbp == target_cb ) {
|
|
|
|
if ( (*cbp)->mc_free ) {
|
2006-12-24 23:44:56 +08:00
|
|
|
(void)(*cbp)->mc_free( e, &(*cbp)->mc_private );
|
2006-09-09 06:02:32 +08:00
|
|
|
}
|
|
|
|
*cbp = (*cbp)->mc_next;
|
|
|
|
ch_free( target_cb );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ch_free( mp );
|
|
|
|
e->e_private = NULL;
|
|
|
|
entry_free( e );
|
|
|
|
|
2006-09-06 20:06:42 +08:00
|
|
|
} else {
|
2006-09-09 06:02:32 +08:00
|
|
|
entry_limbo_t **elpp;
|
|
|
|
|
2007-06-16 02:24:01 +08:00
|
|
|
for ( elpp = &mi->mi_entry_limbo;
|
2006-09-09 06:02:32 +08:00
|
|
|
*elpp;
|
|
|
|
elpp = &(*elpp)->el_next )
|
|
|
|
{
|
|
|
|
entry_limbo_t *elp = *elpp;
|
|
|
|
|
|
|
|
if ( elp->el_type == LIMBO_ENTRY_PARENT
|
|
|
|
&& dn_match( nrdn, &elp->el_e->e_nname )
|
|
|
|
&& dn_match( nbase, &elp->el_nbase )
|
|
|
|
&& scope == elp->el_scope
|
|
|
|
&& bvmatch( filter, &elp->el_filter ) )
|
|
|
|
{
|
|
|
|
monitor_callback_t *cb, *next;
|
|
|
|
|
|
|
|
for ( cb = elp->el_cb; cb; cb = next ) {
|
|
|
|
/* FIXME: call callbacks? */
|
|
|
|
next = cb->mc_next;
|
2007-08-27 15:12:12 +08:00
|
|
|
if ( cb->mc_dispose ) {
|
|
|
|
cb->mc_dispose( &cb->mc_private );
|
|
|
|
}
|
2006-09-09 06:02:32 +08:00
|
|
|
ch_free( cb );
|
|
|
|
}
|
|
|
|
assert( elp->el_e != NULL );
|
|
|
|
elp->el_e->e_private = NULL;
|
|
|
|
entry_free( elp->el_e );
|
|
|
|
if ( !BER_BVISNULL( &elp->el_nbase ) ) {
|
|
|
|
ch_free( elp->el_nbase.bv_val );
|
|
|
|
}
|
|
|
|
if ( !BER_BVISNULL( &elp->el_filter ) ) {
|
|
|
|
ch_free( elp->el_filter.bv_val );
|
|
|
|
}
|
|
|
|
*elpp = elp->el_next;
|
|
|
|
ch_free( elp );
|
|
|
|
elpp = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( elpp != NULL ) {
|
|
|
|
/* not found! where did it go? */
|
|
|
|
return 1;
|
|
|
|
}
|
2006-09-06 20:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2006-09-06 09:54:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_unregister_entry_attrs(
|
2006-09-06 20:06:42 +08:00
|
|
|
struct berval *ndn_in,
|
|
|
|
Attribute *target_a,
|
|
|
|
monitor_callback_t *target_cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
struct berval *nbase,
|
2006-09-06 09:54:54 +08:00
|
|
|
int scope,
|
|
|
|
struct berval *filter )
|
|
|
|
{
|
2006-09-06 20:06:42 +08:00
|
|
|
monitor_info_t *mi;
|
|
|
|
struct berval ndn = BER_BVNULL;
|
|
|
|
char *fname = ( target_a == NULL ? "callback" : "attrs" );
|
|
|
|
|
|
|
|
if ( be_monitor == NULL ) {
|
|
|
|
char buf[ SLAP_TEXT_BUFLEN ];
|
|
|
|
|
|
|
|
snprintf( buf, sizeof( buf ),
|
|
|
|
"monitor_back_unregister_entry_%s(base=\"%s\" scope=%s filter=\"%s\"): "
|
|
|
|
"monitor database not configured.\n",
|
|
|
|
fname,
|
2006-09-09 06:02:32 +08:00
|
|
|
BER_BVISNULL( nbase ) ? "" : nbase->bv_val,
|
|
|
|
ldap_pvt_scope2str( scope ),
|
2006-09-06 20:06:42 +08:00
|
|
|
BER_BVISNULL( filter ) ? "" : filter->bv_val );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s\n", buf, 0, 0 );
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-09-10 00:25:32 +08:00
|
|
|
/* entry will be regularly freed, and resources released
|
|
|
|
* according to callbacks */
|
|
|
|
if ( slapd_shutdown ) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-06 20:06:42 +08:00
|
|
|
mi = ( monitor_info_t * )be_monitor->be_private;
|
|
|
|
|
|
|
|
assert( mi != NULL );
|
|
|
|
|
|
|
|
if ( ndn_in != NULL ) {
|
|
|
|
ndn = *ndn_in;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( target_a == NULL && target_cb == NULL ) {
|
|
|
|
/* nothing to do */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( ndn_in == NULL || BER_BVISNULL( &ndn ) )
|
|
|
|
&& BER_BVISNULL( filter ) )
|
|
|
|
{
|
|
|
|
/* need a filter */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_unregister_entry_%s(\"\"): "
|
|
|
|
"need a valid filter\n",
|
|
|
|
fname, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
if ( monitor_subsys_is_opened() ) {
|
2006-09-06 20:06:42 +08:00
|
|
|
Entry *e = NULL;
|
|
|
|
monitor_entry_t *mp = NULL;
|
|
|
|
int freeit = 0;
|
|
|
|
|
|
|
|
if ( BER_BVISNULL( &ndn ) ) {
|
2006-09-09 10:35:58 +08:00
|
|
|
if ( monitor_search2ndn( nbase, scope, filter, &ndn ) ) {
|
2006-09-06 20:06:42 +08:00
|
|
|
char buf[ SLAP_TEXT_BUFLEN ];
|
|
|
|
|
|
|
|
snprintf( buf, sizeof( buf ),
|
|
|
|
"monitor_back_unregister_entry_%s(\"\"): "
|
|
|
|
"base=\"%s\" scope=%d filter=\"%s\": "
|
|
|
|
"unable to find entry\n",
|
|
|
|
fname,
|
2006-09-09 06:02:32 +08:00
|
|
|
nbase->bv_val ? nbase->bv_val : "\"\"",
|
2006-09-06 20:06:42 +08:00
|
|
|
scope, filter->bv_val );
|
|
|
|
|
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s\n", buf, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
freeit = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( monitor_cache_get( mi, &ndn, &e ) != 0 ) {
|
|
|
|
/* entry does not exist */
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_unregister_entry(\"%s\"): "
|
|
|
|
"entry removal failed.\n",
|
|
|
|
ndn.bv_val, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mp = (monitor_entry_t *)e->e_private;
|
|
|
|
assert( mp != NULL );
|
|
|
|
|
|
|
|
if ( target_cb != NULL ) {
|
|
|
|
monitor_callback_t **cbp;
|
|
|
|
|
|
|
|
for ( cbp = &mp->mp_cb; *cbp != NULL; cbp = &(*cbp)->mc_next ) {
|
|
|
|
if ( *cbp == target_cb ) {
|
|
|
|
if ( (*cbp)->mc_free ) {
|
2006-12-24 23:44:56 +08:00
|
|
|
(void)(*cbp)->mc_free( e, &(*cbp)->mc_private );
|
2006-09-06 20:06:42 +08:00
|
|
|
}
|
|
|
|
*cbp = (*cbp)->mc_next;
|
|
|
|
ch_free( target_cb );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( target_a != NULL ) {
|
|
|
|
Attribute *a;
|
|
|
|
|
|
|
|
for ( a = target_a; a != NULL; a = a->a_next ) {
|
|
|
|
Modification mod = { 0 };
|
|
|
|
const char *text;
|
|
|
|
char textbuf[ SLAP_TEXT_BUFLEN ];
|
|
|
|
|
|
|
|
mod.sm_op = LDAP_MOD_DELETE;
|
|
|
|
mod.sm_desc = a->a_desc;
|
|
|
|
mod.sm_values = a->a_vals;
|
|
|
|
mod.sm_nvalues = a->a_nvals;
|
|
|
|
|
|
|
|
(void)modify_delete_values( e, &mod, 1,
|
|
|
|
&text, textbuf, sizeof( textbuf ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( freeit ) {
|
|
|
|
ber_memfree( ndn.bv_val );
|
|
|
|
}
|
|
|
|
|
2007-05-08 22:17:21 +08:00
|
|
|
monitor_cache_release( mi, e );
|
2006-09-06 20:06:42 +08:00
|
|
|
|
|
|
|
} else {
|
2006-09-09 06:02:32 +08:00
|
|
|
entry_limbo_t **elpp;
|
|
|
|
|
2007-06-16 02:24:01 +08:00
|
|
|
for ( elpp = &mi->mi_entry_limbo;
|
2006-09-09 06:02:32 +08:00
|
|
|
*elpp;
|
|
|
|
elpp = &(*elpp)->el_next )
|
|
|
|
{
|
|
|
|
entry_limbo_t *elp = *elpp;
|
|
|
|
|
|
|
|
if ( elp->el_type == LIMBO_ATTRS
|
|
|
|
&& dn_match( nbase, &elp->el_nbase )
|
|
|
|
&& scope == elp->el_scope
|
|
|
|
&& bvmatch( filter, &elp->el_filter ) )
|
|
|
|
{
|
|
|
|
monitor_callback_t *cb, *next;
|
|
|
|
|
|
|
|
for ( cb = elp->el_cb; cb; cb = next ) {
|
|
|
|
/* FIXME: call callbacks? */
|
|
|
|
next = cb->mc_next;
|
2007-08-27 15:12:12 +08:00
|
|
|
if ( cb->mc_dispose ) {
|
|
|
|
cb->mc_dispose( &cb->mc_private );
|
|
|
|
}
|
2006-09-09 06:02:32 +08:00
|
|
|
ch_free( cb );
|
|
|
|
}
|
|
|
|
assert( elp->el_e == NULL );
|
|
|
|
if ( elp->el_a != NULL ) {
|
|
|
|
attrs_free( elp->el_a );
|
|
|
|
}
|
|
|
|
if ( !BER_BVISNULL( &elp->el_nbase ) ) {
|
|
|
|
ch_free( elp->el_nbase.bv_val );
|
|
|
|
}
|
|
|
|
if ( !BER_BVISNULL( &elp->el_filter ) ) {
|
|
|
|
ch_free( elp->el_filter.bv_val );
|
|
|
|
}
|
|
|
|
*elpp = elp->el_next;
|
|
|
|
ch_free( elp );
|
|
|
|
elpp = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( elpp != NULL ) {
|
|
|
|
/* not found! where did it go? */
|
|
|
|
return 1;
|
|
|
|
}
|
2006-09-06 20:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2006-09-06 09:54:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_unregister_entry_callback(
|
|
|
|
struct berval *ndn,
|
2006-09-06 20:06:42 +08:00
|
|
|
monitor_callback_t *cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
struct berval *nbase,
|
2006-09-06 09:54:54 +08:00
|
|
|
int scope,
|
|
|
|
struct berval *filter )
|
|
|
|
{
|
2006-09-06 20:06:42 +08:00
|
|
|
/* TODO: lookup entry (by ndn, if not NULL, and/or by callback);
|
|
|
|
* unregister the callback; if a is not null, unregister the
|
|
|
|
* given attrs. In any case, call cb->cb_free */
|
|
|
|
return monitor_back_unregister_entry_attrs( ndn,
|
2006-09-09 06:02:32 +08:00
|
|
|
NULL, cb, nbase, scope, filter );
|
2006-09-06 09:54:54 +08:00
|
|
|
}
|
|
|
|
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_subsys_t *
|
2004-11-08 18:10:15 +08:00
|
|
|
monitor_back_get_subsys( const char *name )
|
|
|
|
{
|
|
|
|
if ( monitor_subsys != NULL ) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
|
|
|
|
if ( strcasecmp( monitor_subsys[ i ]->mss_name, name ) == 0 ) {
|
|
|
|
return monitor_subsys[ i ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_subsys_t *
|
2005-04-28 05:30:35 +08:00
|
|
|
monitor_back_get_subsys_by_dn(
|
|
|
|
struct berval *ndn,
|
|
|
|
int sub )
|
2004-11-08 18:10:15 +08:00
|
|
|
{
|
|
|
|
if ( monitor_subsys != NULL ) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ( sub ) {
|
|
|
|
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
|
|
|
|
if ( dnIsSuffix( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
|
|
|
|
return monitor_subsys[ i ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
|
|
|
|
if ( dn_match( ndn, &monitor_subsys[ i ]->mss_ndn ) ) {
|
|
|
|
return monitor_subsys[ i ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-07-15 01:34:24 +08:00
|
|
|
int
|
|
|
|
monitor_back_initialize(
|
2005-04-28 05:30:35 +08:00
|
|
|
BackendInfo *bi )
|
2001-07-15 01:34:24 +08:00
|
|
|
{
|
2004-11-09 02:52:27 +08:00
|
|
|
static char *controls[] = {
|
2001-07-15 01:34:24 +08:00
|
|
|
LDAP_CONTROL_MANAGEDSAIT,
|
|
|
|
NULL
|
|
|
|
};
|
2005-11-15 03:28:28 +08:00
|
|
|
|
|
|
|
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 }
|
|
|
|
};
|
|
|
|
|
2003-04-12 08:30:47 +08:00
|
|
|
struct m_s {
|
|
|
|
char *schema;
|
2003-06-01 05:46:33 +08:00
|
|
|
slap_mask_t flags;
|
2003-04-12 08:30:47 +08:00
|
|
|
int offset;
|
|
|
|
} moc[] = {
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.3.16.1 "
|
2003-04-13 01:41:49 +08:00
|
|
|
"NAME 'monitor' "
|
|
|
|
"DESC 'OpenLDAP system monitoring' "
|
|
|
|
"SUP top STRUCTURAL "
|
|
|
|
"MUST cn "
|
|
|
|
"MAY ( "
|
|
|
|
"description "
|
|
|
|
"$ seeAlso "
|
2004-03-18 06:37:40 +08:00
|
|
|
"$ labeledURI "
|
2003-04-13 01:41:49 +08:00
|
|
|
"$ monitoredInfo "
|
2003-04-13 02:16:05 +08:00
|
|
|
"$ managedInfo "
|
2004-03-16 09:22:34 +08:00
|
|
|
"$ monitorOverlay "
|
2003-06-01 05:46:33 +08:00
|
|
|
") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_oc_monitor) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.3.16.2 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorServer' "
|
|
|
|
"DESC 'Server monitoring root entry' "
|
2003-06-01 05:46:33 +08:00
|
|
|
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_oc_monitorServer) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.3.16.3 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorContainer' "
|
|
|
|
"DESC 'monitor container class' "
|
2003-06-01 05:46:33 +08:00
|
|
|
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_oc_monitorContainer) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.3.16.4 "
|
2003-04-13 01:41:49 +08:00
|
|
|
"NAME 'monitorCounterObject' "
|
2003-04-12 08:30:47 +08:00
|
|
|
"DESC 'monitor counter class' "
|
2003-06-01 05:46:33 +08:00
|
|
|
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_oc_monitorCounterObject) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.3.16.5 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorOperation' "
|
|
|
|
"DESC 'monitor operation class' "
|
2003-06-01 05:46:33 +08:00
|
|
|
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_oc_monitorOperation) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.3.16.6 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorConnection' "
|
|
|
|
"DESC 'monitor connection class' "
|
2003-06-01 05:46:33 +08:00
|
|
|
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_oc_monitorConnection) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.3.16.7 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'managedObject' "
|
|
|
|
"DESC 'monitor managed entity class' "
|
2003-06-01 05:46:33 +08:00
|
|
|
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_oc_managedObject) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.3.16.8 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitoredObject' "
|
|
|
|
"DESC 'monitor monitored entity class' "
|
2003-06-01 05:46:33 +08:00
|
|
|
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_oc_monitoredObject) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ NULL, 0, -1 }
|
2003-04-12 08:30:47 +08:00
|
|
|
}, mat[] = {
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.1 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitoredInfo' "
|
|
|
|
"DESC 'monitored info' "
|
2003-04-12 18:02:31 +08:00
|
|
|
/* "SUP name " */
|
|
|
|
"EQUALITY caseIgnoreMatch "
|
|
|
|
"SUBSTR caseIgnoreSubstringsMatch "
|
|
|
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitoredInfo) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.2 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'managedInfo' "
|
|
|
|
"DESC 'monitor managed info' "
|
2003-06-01 05:46:33 +08:00
|
|
|
"SUP name )", SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_managedInfo) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.3 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorCounter' "
|
|
|
|
"DESC 'monitor counter' "
|
|
|
|
"EQUALITY integerMatch "
|
2003-04-12 11:19:43 +08:00
|
|
|
"ORDERING integerOrderingMatch "
|
2003-04-12 08:48:16 +08:00
|
|
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 "
|
2003-04-12 18:02:31 +08:00
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorCounter) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.4 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorOpCompleted' "
|
|
|
|
"DESC 'monitor completed operations' "
|
2003-04-12 18:02:31 +08:00
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorOpCompleted) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.5 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorOpInitiated' "
|
|
|
|
"DESC 'monitor initiated operations' "
|
2003-04-12 18:02:31 +08:00
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorOpInitiated) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.6 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorConnectionNumber' "
|
|
|
|
"DESC 'monitor connection number' "
|
2003-04-12 18:02:31 +08:00
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionNumber) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.7 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorConnectionAuthzDN' "
|
|
|
|
"DESC 'monitor connection authorization DN' "
|
2003-04-12 18:02:31 +08:00
|
|
|
/* "SUP distinguishedName " */
|
|
|
|
"EQUALITY distinguishedNameMatch "
|
|
|
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionAuthzDN) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.8 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorConnectionLocalAddress' "
|
|
|
|
"DESC 'monitor connection local address' "
|
2003-04-12 18:02:31 +08:00
|
|
|
"SUP monitoredInfo "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionLocalAddress) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.9 "
|
2003-04-12 08:30:47 +08:00
|
|
|
"NAME 'monitorConnectionPeerAddress' "
|
|
|
|
"DESC 'monitor connection peer address' "
|
2003-04-12 18:02:31 +08:00
|
|
|
"SUP monitoredInfo "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionPeerAddress) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.10 "
|
2003-05-15 09:19:30 +08:00
|
|
|
"NAME 'monitorTimestamp' "
|
|
|
|
"DESC 'monitor timestamp' "
|
|
|
|
"EQUALITY generalizedTimeMatch "
|
|
|
|
"ORDERING generalizedTimeOrderingMatch "
|
|
|
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
|
2003-05-20 02:54:15 +08:00
|
|
|
"SINGLE-VALUE "
|
2003-05-18 01:19:16 +08:00
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorTimestamp) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.11 "
|
2004-03-16 09:22:34 +08:00
|
|
|
"NAME 'monitorOverlay' "
|
2005-04-27 10:43:38 +08:00
|
|
|
"DESC 'name of overlays defined for a given database' "
|
2004-03-16 09:22:34 +08:00
|
|
|
"SUP monitoredInfo "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorOverlay) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.12 "
|
2004-04-27 09:56:38 +08:00
|
|
|
"NAME 'readOnly' "
|
|
|
|
"DESC 'read/write status of a given database' "
|
|
|
|
"EQUALITY booleanMatch "
|
|
|
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
|
|
|
|
"SINGLE-VALUE "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_readOnly) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.13 "
|
2004-05-02 02:55:52 +08:00
|
|
|
"NAME 'restrictedOperation' "
|
|
|
|
"DESC 'name of restricted operation for a given database' "
|
|
|
|
"SUP managedInfo )", SLAP_AT_HIDE,
|
2004-11-09 02:52:27 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_restrictedOperation ) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.14 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionProtocol' "
|
|
|
|
"DESC 'monitor connection protocol' "
|
|
|
|
"SUP monitoredInfo "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionProtocol) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.15 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionOpsReceived' "
|
|
|
|
"DESC 'monitor number of operations received by the connection' "
|
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsReceived) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.16 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionOpsExecuting' "
|
|
|
|
"DESC 'monitor number of operations in execution within the connection' "
|
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsExecuting) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.17 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionOpsPending' "
|
|
|
|
"DESC 'monitor number of pending operations within the connection' "
|
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsPending) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.18 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionOpsCompleted' "
|
|
|
|
"DESC 'monitor number of operations completed within the connection' "
|
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsCompleted) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.19 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionGet' "
|
2005-04-28 02:33:22 +08:00
|
|
|
"DESC 'number of times connection_get() was called so far' "
|
2005-04-28 01:51:54 +08:00
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionGet) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.20 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionRead' "
|
2005-04-28 02:33:22 +08:00
|
|
|
"DESC 'number of times connection_read() was called so far' "
|
2005-04-28 01:51:54 +08:00
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionRead) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.21 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionWrite' "
|
2005-04-28 02:33:22 +08:00
|
|
|
"DESC 'number of times connection_write() was called so far' "
|
2005-04-28 01:51:54 +08:00
|
|
|
"SUP monitorCounter "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionWrite) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.22 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionMask' "
|
|
|
|
"DESC 'monitor connection mask' "
|
|
|
|
"SUP monitoredInfo "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionMask) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.23 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionListener' "
|
|
|
|
"DESC 'monitor connection listener' "
|
|
|
|
"SUP monitoredInfo "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionListener) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.24 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionPeerDomain' "
|
|
|
|
"DESC 'monitor connection peer domain' "
|
|
|
|
"SUP monitoredInfo "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionPeerDomain) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.25 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionStartTime' "
|
|
|
|
"DESC 'monitor connection start time' "
|
|
|
|
"SUP monitorTimestamp "
|
|
|
|
"SINGLE-VALUE "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionStartTime) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.26 "
|
2005-04-28 01:51:54 +08:00
|
|
|
"NAME 'monitorConnectionActivityTime' "
|
|
|
|
"DESC 'monitor connection activity time' "
|
|
|
|
"SUP monitorTimestamp "
|
|
|
|
"SINGLE-VALUE "
|
|
|
|
"NO-USER-MODIFICATION "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
|
2005-04-28 01:51:54 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorConnectionActivityTime) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.27 "
|
2005-05-04 17:27:22 +08:00
|
|
|
"NAME 'monitorIsShadow' "
|
|
|
|
"DESC 'TRUE if the database is shadow' "
|
|
|
|
"EQUALITY booleanMatch "
|
|
|
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
|
|
|
|
"SINGLE-VALUE "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_HIDE,
|
2005-05-04 17:27:22 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorIsShadow) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.28 "
|
2005-05-21 22:54:11 +08:00
|
|
|
"NAME 'monitorUpdateRef' "
|
|
|
|
"DESC 'update referral for shadow databases' "
|
|
|
|
"SUP monitoredInfo "
|
|
|
|
"SINGLE-VALUE "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_HIDE,
|
2005-05-21 22:54:11 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorUpdateRef) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ "( 1.3.6.1.4.1.4203.666.1.55.29 "
|
2005-07-23 23:29:16 +08:00
|
|
|
"NAME 'monitorRuntimeConfig' "
|
|
|
|
"DESC 'TRUE if component allows runtime configuration' "
|
|
|
|
"EQUALITY booleanMatch "
|
|
|
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
|
|
|
|
"SINGLE-VALUE "
|
2006-12-08 10:30:11 +08:00
|
|
|
"USAGE dSAOperation )", SLAP_AT_HIDE,
|
2005-07-23 23:29:16 +08:00
|
|
|
offsetof(monitor_info_t, mi_ad_monitorRuntimeConfig) },
|
2006-09-13 21:05:19 +08:00
|
|
|
{ NULL, 0, -1 }
|
2003-04-12 08:30:47 +08:00
|
|
|
};
|
2005-07-23 23:29:16 +08:00
|
|
|
|
2006-09-07 00:06:49 +08:00
|
|
|
static struct {
|
|
|
|
char *name;
|
|
|
|
char *oid;
|
|
|
|
} s_oid[] = {
|
|
|
|
{ "olmAttributes", "1.3.6.1.4.1.4203.666.1.55" },
|
|
|
|
{ "olmSubSystemAttributes", "olmAttributes:0" },
|
|
|
|
{ "olmGenericAttributes", "olmSubSystemAttributes:0" },
|
|
|
|
{ "olmDatabaseAttributes", "olmSubSystemAttributes:1" },
|
|
|
|
|
|
|
|
/* for example, back-bdb specific attrs
|
|
|
|
* are in "olmDatabaseAttributes:1"
|
|
|
|
*
|
|
|
|
* NOTE: developers, please record here OID assignments
|
|
|
|
* for other modules */
|
|
|
|
|
|
|
|
{ "olmObjectClasses", "1.3.6.1.4.1.4203.666.3.16" },
|
|
|
|
{ "olmSubSystemObjectClasses", "olmObjectClasses:0" },
|
|
|
|
{ "olmGenericObjectClasses", "olmSubSystemObjectClasses:0" },
|
|
|
|
{ "olmDatabaseObjectClasses", "olmSubSystemObjectClasses:1" },
|
|
|
|
|
|
|
|
/* for example, back-bdb specific objectClasses
|
|
|
|
* are in "olmDatabaseObjectClasses:1"
|
|
|
|
*
|
|
|
|
* NOTE: developers, please record here OID assignments
|
|
|
|
* for other modules */
|
|
|
|
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2005-11-16 08:49:54 +08:00
|
|
|
int i, rc;
|
|
|
|
monitor_info_t *mi = &monitor_info;
|
2006-11-15 09:18:37 +08:00
|
|
|
ConfigArgs c;
|
|
|
|
char *argv[ 3 ];
|
|
|
|
|
|
|
|
argv[ 0 ] = "monitor";
|
|
|
|
c.argv = argv;
|
|
|
|
c.argc = 3;
|
|
|
|
c.fname = argv[0];
|
2003-05-18 01:19:16 +08:00
|
|
|
|
2006-09-07 00:06:49 +08:00
|
|
|
for ( i = 0; s_oid[ i ].name; i++ ) {
|
|
|
|
argv[ 1 ] = s_oid[ i ].name;
|
|
|
|
argv[ 2 ] = s_oid[ i ].oid;
|
|
|
|
|
2006-11-15 09:18:37 +08:00
|
|
|
if ( parse_oidm( &c, 0, NULL ) != 0 ) {
|
2006-09-07 00:06:49 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_back_initialize: unable to add "
|
|
|
|
"objectIdentifier \"%s=%s\"\n",
|
|
|
|
s_oid[ i ].name, s_oid[ i ].oid, 0 );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-18 01:19:16 +08:00
|
|
|
/* schema integration */
|
2006-09-13 21:05:19 +08:00
|
|
|
for ( i = 0; mat[ i ].schema; i++ ) {
|
2003-05-15 09:19:30 +08:00
|
|
|
int code;
|
2006-09-13 21:05:19 +08:00
|
|
|
AttributeDescription **ad =
|
|
|
|
((AttributeDescription **)&(((char *)mi)[ mat[ i ].offset ]));
|
2001-07-15 01:34:24 +08:00
|
|
|
|
2006-09-13 21:05:19 +08:00
|
|
|
*ad = NULL;
|
|
|
|
code = register_at( mat[ i ].schema, ad, 0 );
|
2002-01-12 02:26:17 +08:00
|
|
|
|
2003-04-13 01:41:49 +08:00
|
|
|
if ( code ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2006-09-13 21:05:19 +08:00
|
|
|
"monitor_back_db_init: register_at failed\n", 0, 0, 0 );
|
2003-04-13 01:41:49 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2004-11-08 18:55:33 +08:00
|
|
|
(*ad)->ad_type->sat_flags |= mat[ i ].flags;
|
2003-04-13 01:41:49 +08:00
|
|
|
}
|
|
|
|
|
2006-09-13 21:05:19 +08:00
|
|
|
for ( i = 0; moc[ i ].schema; i++ ) {
|
2003-04-12 08:30:47 +08:00
|
|
|
int code;
|
2006-09-13 21:05:19 +08:00
|
|
|
ObjectClass **Oc =
|
|
|
|
((ObjectClass **)&(((char *)mi)[ moc[ i ].offset ]));
|
2003-04-12 08:30:47 +08:00
|
|
|
|
2006-09-13 21:05:19 +08:00
|
|
|
code = register_oc( moc[ i ].schema, Oc, 0 );
|
2003-04-12 08:30:47 +08:00
|
|
|
if ( code ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2006-09-13 21:05:19 +08:00
|
|
|
"monitor_back_db_init: register_oc failed\n", 0, 0, 0 );
|
2003-04-12 08:30:47 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2006-09-13 21:05:19 +08:00
|
|
|
(*Oc)->soc_flags |= moc[ i ].flags;
|
2001-07-15 01:34:24 +08:00
|
|
|
}
|
2001-12-11 19:31:38 +08:00
|
|
|
|
2005-11-16 08:49:54 +08:00
|
|
|
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;
|
2005-11-27 07:35:45 +08:00
|
|
|
#if 0
|
2005-11-16 08:49:54 +08:00
|
|
|
bi->bi_db_config = monitor_back_db_config;
|
2005-11-27 07:35:45 +08:00
|
|
|
#endif
|
2005-11-16 08:49:54 +08:00
|
|
|
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_entry_modify = 0;
|
|
|
|
|
|
|
|
bi->bi_connection_init = 0;
|
|
|
|
bi->bi_connection_destroy = 0;
|
|
|
|
|
2006-09-13 19:38:51 +08:00
|
|
|
bi->bi_extra = (void *)&monitor_extra;
|
|
|
|
|
2005-11-16 08:49:54 +08:00
|
|
|
/*
|
|
|
|
* configuration objectClasses (fake)
|
|
|
|
*/
|
|
|
|
bi->bi_cf_ocs = monitorocs;
|
|
|
|
|
|
|
|
rc = config_register_schema( monitorcfg, monitorocs );
|
|
|
|
if ( rc ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_db_init(
|
2007-07-26 01:21:05 +08:00
|
|
|
BackendDB *be,
|
2007-08-03 20:02:07 +08:00
|
|
|
ConfigReply *c)
|
2005-11-16 08:49:54 +08:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct berval dn = BER_BVC( SLAPD_MONITOR_DN ),
|
|
|
|
pdn,
|
|
|
|
ndn;
|
|
|
|
BackendDB *be2;
|
|
|
|
|
|
|
|
monitor_subsys_t *ms;
|
|
|
|
|
2005-04-30 04:29:59 +08:00
|
|
|
/*
|
|
|
|
* database monitor can be defined once only
|
|
|
|
*/
|
|
|
|
if ( be_monitor != NULL ) {
|
2007-07-26 01:21:05 +08:00
|
|
|
if (c) {
|
|
|
|
snprintf(c->msg, sizeof(c->msg),"only one monitor database allowed");
|
|
|
|
}
|
2005-04-30 04:29:59 +08:00
|
|
|
return( -1 );
|
|
|
|
}
|
|
|
|
be_monitor = be;
|
|
|
|
|
2007-04-05 01:14:09 +08:00
|
|
|
/*
|
|
|
|
* register subsys
|
|
|
|
*/
|
|
|
|
for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) {
|
|
|
|
if ( monitor_back_register_subsys( ms ) ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-30 04:29:59 +08:00
|
|
|
/* indicate system schema supported */
|
|
|
|
SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR;
|
|
|
|
|
2005-08-30 18:38:11 +08:00
|
|
|
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
|
2005-04-30 04:29:59 +08:00
|
|
|
if( rc != LDAP_SUCCESS ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2005-08-30 18:38:11 +08:00
|
|
|
"unable to normalize/pretty monitor DN \"%s\" (%d)\n",
|
2005-08-07 05:03:26 +08:00
|
|
|
dn.bv_val, rc, 0 );
|
2005-04-30 04:29:59 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2005-08-30 18:38:11 +08:00
|
|
|
ber_bvarray_add( &be->be_suffix, &pdn );
|
2005-04-30 04:29:59 +08:00
|
|
|
ber_bvarray_add( &be->be_nsuffix, &ndn );
|
|
|
|
|
|
|
|
/* NOTE: only one monitor database is allowed,
|
|
|
|
* so we use static storage */
|
2005-08-07 05:03:26 +08:00
|
|
|
ldap_pvt_thread_mutex_init( &monitor_info.mi_cache_mutex );
|
2005-04-30 04:29:59 +08:00
|
|
|
|
2005-08-07 05:03:26 +08:00
|
|
|
be->be_private = &monitor_info;
|
2005-04-30 04:29:59 +08:00
|
|
|
|
2007-07-13 11:18:20 +08:00
|
|
|
be2 = select_backend( &ndn, 0 );
|
2005-08-30 18:38:11 +08:00
|
|
|
if ( be2 != be ) {
|
|
|
|
char *type = be2->bd_info->bi_type;
|
|
|
|
|
|
|
|
if ( overlay_is_over( be2 ) ) {
|
|
|
|
slap_overinfo *oi = (slap_overinfo *)be2->bd_info->bi_private;
|
|
|
|
type = oi->oi_orig->bi_type;
|
|
|
|
}
|
|
|
|
|
2007-07-26 01:21:05 +08:00
|
|
|
if (c) {
|
2007-08-01 23:42:18 +08:00
|
|
|
snprintf(c->msg, sizeof(c->msg),
|
2007-07-26 01:21:05 +08:00
|
|
|
"\"monitor\" database serving namingContext \"%s\" "
|
|
|
|
"is hidden by \"%s\" database serving namingContext \"%s\".\n",
|
|
|
|
pdn.bv_val, type, be2->be_nsuffix[ 0 ].bv_val );
|
|
|
|
}
|
2005-08-30 18:38:11 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2005-04-30 04:29:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-27 15:12:12 +08:00
|
|
|
static void
|
|
|
|
monitor_back_destroy_limbo_entry(
|
|
|
|
entry_limbo_t *el,
|
|
|
|
int dispose )
|
|
|
|
{
|
|
|
|
if ( el->el_e ) {
|
|
|
|
entry_free( el->el_e );
|
|
|
|
}
|
|
|
|
if ( el->el_a ) {
|
|
|
|
attrs_free( el->el_a );
|
|
|
|
}
|
|
|
|
if ( !BER_BVISNULL( &el->el_nbase ) ) {
|
|
|
|
ber_memfree( el->el_nbase.bv_val );
|
|
|
|
}
|
|
|
|
if ( !BER_BVISNULL( &el->el_filter ) ) {
|
|
|
|
ber_memfree( el->el_filter.bv_val );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: callbacks are not copied; so only free them
|
|
|
|
* if disposing of */
|
|
|
|
if ( el->el_cb && dispose != 0 ) {
|
|
|
|
monitor_callback_t *next;
|
|
|
|
|
|
|
|
for ( ; el->el_cb; el->el_cb = next ) {
|
|
|
|
next = el->el_cb->mc_next;
|
|
|
|
if ( el->el_cb->mc_dispose ) {
|
|
|
|
el->el_cb->mc_dispose( &el->el_cb->mc_private );
|
|
|
|
}
|
|
|
|
ch_free( el->el_cb );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ch_free( el );
|
|
|
|
}
|
|
|
|
|
2004-04-27 20:04:46 +08:00
|
|
|
int
|
|
|
|
monitor_back_db_open(
|
2007-07-26 01:21:05 +08:00
|
|
|
BackendDB *be,
|
2007-08-03 20:02:07 +08:00
|
|
|
ConfigReply *cr)
|
2004-04-27 20:04:46 +08:00
|
|
|
{
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_info_t *mi = (monitor_info_t *)be->be_private;
|
|
|
|
struct monitor_subsys_t **ms;
|
2006-01-12 16:40:09 +08:00
|
|
|
Entry *e, **ep, *root;
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_entry_t *mp;
|
2004-04-27 20:04:46 +08:00
|
|
|
int i;
|
2006-01-12 16:40:09 +08:00
|
|
|
struct berval bv, rdn = BER_BVC(SLAPD_MONITOR_DN);
|
2004-04-27 20:04:46 +08:00
|
|
|
struct tm *tms;
|
|
|
|
#ifdef HAVE_GMTIME_R
|
|
|
|
struct tm tm_buf;
|
|
|
|
#endif
|
|
|
|
static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
|
2006-01-12 16:40:09 +08:00
|
|
|
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 };
|
2004-04-27 20:04:46 +08:00
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
int retcode = 0;
|
|
|
|
|
2005-07-18 14:22:33 +08:00
|
|
|
assert( be_monitor != NULL );
|
2004-11-12 20:54:42 +08:00
|
|
|
if ( be != be_monitor ) {
|
|
|
|
be_monitor = be;
|
|
|
|
}
|
|
|
|
|
2004-04-27 20:04:46 +08:00
|
|
|
/*
|
|
|
|
* Start
|
|
|
|
*/
|
|
|
|
#ifndef HAVE_GMTIME_R
|
2004-10-06 13:51:38 +08:00
|
|
|
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
|
2004-04-27 20:04:46 +08:00
|
|
|
#endif
|
|
|
|
#ifdef HACK_LOCAL_TIME
|
|
|
|
# ifdef HAVE_LOCALTIME_R
|
2004-10-06 13:51:38 +08:00
|
|
|
tms = localtime_r( &starttime, &tm_buf );
|
2004-04-27 20:04:46 +08:00
|
|
|
# else
|
2004-10-06 13:51:38 +08:00
|
|
|
tms = localtime( &starttime );
|
2004-04-27 20:04:46 +08:00
|
|
|
# endif /* HAVE_LOCALTIME_R */
|
|
|
|
lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
|
|
|
|
#else /* !HACK_LOCAL_TIME */
|
|
|
|
# ifdef HAVE_GMTIME_R
|
2004-10-06 13:51:38 +08:00
|
|
|
tms = gmtime_r( &starttime, &tm_buf );
|
2004-04-27 20:04:46 +08:00
|
|
|
# else
|
2004-10-06 13:51:38 +08:00
|
|
|
tms = gmtime( &starttime );
|
2004-04-27 20:04:46 +08:00
|
|
|
# endif /* HAVE_GMTIME_R */
|
|
|
|
lutil_gentime( tmbuf, sizeof(tmbuf), tms );
|
|
|
|
#endif /* !HACK_LOCAL_TIME */
|
|
|
|
#ifndef HAVE_GMTIME_R
|
2004-10-06 13:51:38 +08:00
|
|
|
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
|
2004-04-27 20:04:46 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
mi->mi_startTime.bv_val = tmbuf;
|
|
|
|
mi->mi_startTime.bv_len = strlen( tmbuf );
|
|
|
|
|
2004-07-20 05:42:11 +08:00
|
|
|
if ( BER_BVISEMPTY( &be->be_rootdn ) ) {
|
|
|
|
BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS );
|
2006-01-12 16:40:09 +08:00
|
|
|
BER_BVSTR( &mi->mi_ncreatorsName, SLAPD_ANONYMOUS );
|
2004-07-20 05:42:11 +08:00
|
|
|
} else {
|
|
|
|
mi->mi_creatorsName = be->be_rootdn;
|
2006-01-12 16:40:09 +08:00
|
|
|
mi->mi_ncreatorsName = be->be_rootndn;
|
2004-07-20 05:42:11 +08:00
|
|
|
}
|
|
|
|
|
2004-09-13 06:12:58 +08:00
|
|
|
/*
|
|
|
|
* creates the "cn=Monitor" entry
|
|
|
|
*/
|
2006-01-12 16:40:09 +08:00
|
|
|
e = monitor_entry_stub( NULL, NULL, &rdn, mi->mi_oc_monitorServer, mi,
|
|
|
|
NULL, NULL );
|
|
|
|
|
2004-09-13 06:12:58 +08:00
|
|
|
if ( e == NULL) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"unable to create \"%s\" entry\n",
|
|
|
|
SLAPD_MONITOR_DN, 0, 0 );
|
|
|
|
return( -1 );
|
|
|
|
}
|
|
|
|
|
2006-01-12 16:40:09 +08:00
|
|
|
attr_merge_normalize( e, slap_schema.si_ad_description, desc, NULL );
|
|
|
|
|
2005-05-07 01:11:40 +08:00
|
|
|
bv.bv_val = strchr( (char *) Versionstr, '$' );
|
|
|
|
if ( bv.bv_val != NULL ) {
|
|
|
|
char *end;
|
2004-09-13 06:12:58 +08:00
|
|
|
|
2005-05-07 01:11:40 +08:00
|
|
|
bv.bv_val++;
|
|
|
|
for ( ; bv.bv_val[ 0 ] == ' '; bv.bv_val++ )
|
|
|
|
;
|
|
|
|
|
|
|
|
end = strchr( bv.bv_val, '$' );
|
|
|
|
if ( end != NULL ) {
|
|
|
|
end--;
|
|
|
|
|
|
|
|
for ( ; end > bv.bv_val && end[ 0 ] == ' '; end-- )
|
|
|
|
;
|
|
|
|
|
|
|
|
end++;
|
|
|
|
|
|
|
|
bv.bv_len = end - bv.bv_val;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
bv.bv_len = strlen( bv.bv_val );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
|
|
|
|
&bv, NULL ) ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"unable to add monitoredInfo to \"%s\" entry\n",
|
|
|
|
SLAPD_MONITOR_DN, 0, 0 );
|
|
|
|
return( -1 );
|
|
|
|
}
|
2004-09-13 06:12:58 +08:00
|
|
|
}
|
|
|
|
|
2004-11-08 18:55:33 +08:00
|
|
|
mp = monitor_entrypriv_create();
|
|
|
|
if ( mp == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
2004-09-13 06:12:58 +08:00
|
|
|
e->e_private = ( void * )mp;
|
|
|
|
ep = &mp->mp_children;
|
|
|
|
|
|
|
|
if ( monitor_cache_add( mi, e ) ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"unable to add entry \"%s\" to cache\n",
|
|
|
|
SLAPD_MONITOR_DN, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
2006-01-12 16:40:09 +08:00
|
|
|
root = e;
|
2004-09-13 06:12:58 +08:00
|
|
|
|
2001-12-11 19:31:38 +08:00
|
|
|
/*
|
|
|
|
* Create all the subsystem specific entries
|
|
|
|
*/
|
2004-11-08 18:10:15 +08:00
|
|
|
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
|
|
|
|
int len = strlen( monitor_subsys[ i ]->mss_name );
|
2001-12-29 12:48:00 +08:00
|
|
|
struct berval dn;
|
2001-12-27 23:16:12 +08:00
|
|
|
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=" );
|
2004-11-08 18:10:15 +08:00
|
|
|
strcat( dn.bv_val, monitor_subsys[ i ]->mss_name );
|
|
|
|
rc = dnPretty( NULL, &dn, &monitor_subsys[ i ]->mss_rdn, NULL );
|
2001-12-29 12:48:00 +08:00
|
|
|
free( dn.bv_val );
|
2001-12-27 23:16:12 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor RDN \"%s\" is invalid\n",
|
|
|
|
dn.bv_val, 0, 0 );
|
|
|
|
return( -1 );
|
|
|
|
}
|
|
|
|
|
2006-01-12 16:40:09 +08:00
|
|
|
e = monitor_entry_stub( &root->e_name, &root->e_nname,
|
|
|
|
&monitor_subsys[ i ]->mss_rdn, mi->mi_oc_monitorContainer, mi,
|
|
|
|
NULL, NULL );
|
2001-07-15 01:34:24 +08:00
|
|
|
|
|
|
|
if ( e == NULL) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2004-09-13 06:12:58 +08:00
|
|
|
"unable to create \"%s\" entry\n",
|
2004-11-08 18:10:15 +08:00
|
|
|
monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
|
2001-07-15 01:34:24 +08:00
|
|
|
return( -1 );
|
|
|
|
}
|
2006-01-12 16:40:09 +08:00
|
|
|
monitor_subsys[i]->mss_dn = e->e_name;
|
|
|
|
monitor_subsys[i]->mss_ndn = e->e_nname;
|
2001-07-15 01:34:24 +08:00
|
|
|
|
2005-04-30 04:29:59 +08:00
|
|
|
if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_desc[ 0 ] ) ) {
|
|
|
|
attr_merge_normalize( e, slap_schema.si_ad_description,
|
|
|
|
monitor_subsys[ i ]->mss_desc, NULL );
|
|
|
|
}
|
|
|
|
|
2004-11-08 18:55:33 +08:00
|
|
|
mp = monitor_entrypriv_create();
|
|
|
|
if ( mp == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
2001-07-15 01:34:24 +08:00
|
|
|
e->e_private = ( void * )mp;
|
2004-11-08 18:10:15 +08:00
|
|
|
mp->mp_info = monitor_subsys[ i ];
|
|
|
|
mp->mp_flags = monitor_subsys[ i ]->mss_flags;
|
2001-07-15 01:34:24 +08:00
|
|
|
|
|
|
|
if ( monitor_cache_add( mi, e ) ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
2004-09-13 06:12:58 +08:00
|
|
|
"unable to add entry \"%s\" to cache\n",
|
2004-11-08 18:10:15 +08:00
|
|
|
monitor_subsys[ i ]->mss_dn.bv_val, 0, 0 );
|
2001-07-15 01:34:24 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-09-13 06:12:58 +08:00
|
|
|
*ep = e;
|
|
|
|
ep = &mp->mp_next;
|
2001-07-15 01:34:24 +08:00
|
|
|
}
|
|
|
|
|
2005-07-18 14:22:33 +08:00
|
|
|
assert( be != NULL );
|
2001-07-15 01:34:24 +08:00
|
|
|
|
|
|
|
be->be_private = mi;
|
|
|
|
|
|
|
|
/*
|
2004-11-08 18:10:15 +08:00
|
|
|
* opens the monitor backend subsystems
|
2001-07-15 01:34:24 +08:00
|
|
|
*/
|
2004-11-08 18:10:15 +08:00
|
|
|
for ( ms = monitor_subsys; ms[ 0 ] != NULL; ms++ ) {
|
|
|
|
if ( ms[ 0 ]->mss_open && ( *ms[ 0 ]->mss_open )( be, ms[ 0 ] ) )
|
|
|
|
{
|
2001-07-15 01:34:24 +08:00
|
|
|
return( -1 );
|
|
|
|
}
|
2004-11-08 19:33:53 +08:00
|
|
|
ms[ 0 ]->mss_flags |= MONITOR_F_OPENED;
|
2001-07-15 01:34:24 +08:00
|
|
|
}
|
|
|
|
|
2004-11-08 19:33:53 +08:00
|
|
|
monitor_subsys_opened = 1;
|
|
|
|
|
2004-11-09 02:52:27 +08:00
|
|
|
if ( mi->mi_entry_limbo ) {
|
2007-06-16 02:24:01 +08:00
|
|
|
entry_limbo_t *el = mi->mi_entry_limbo;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
|
|
|
for ( ; el; ) {
|
|
|
|
entry_limbo_t *tmp;
|
2006-12-24 23:44:56 +08:00
|
|
|
int rc;
|
2004-11-09 02:52:27 +08:00
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
switch ( el->el_type ) {
|
|
|
|
case LIMBO_ENTRY:
|
2006-12-24 23:44:56 +08:00
|
|
|
rc = monitor_back_register_entry(
|
2004-11-12 20:54:42 +08:00
|
|
|
el->el_e,
|
2006-09-09 06:02:32 +08:00
|
|
|
el->el_cb,
|
|
|
|
el->el_mss,
|
|
|
|
el->el_flags );
|
2004-11-12 20:54:42 +08:00
|
|
|
break;
|
|
|
|
|
2005-04-27 10:43:38 +08:00
|
|
|
case LIMBO_ENTRY_PARENT:
|
2006-12-24 23:44:56 +08:00
|
|
|
rc = monitor_back_register_entry_parent(
|
2005-04-27 10:43:38 +08:00
|
|
|
el->el_e,
|
|
|
|
el->el_cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
el->el_mss,
|
|
|
|
el->el_flags,
|
|
|
|
&el->el_nbase,
|
2005-04-27 10:43:38 +08:00
|
|
|
el->el_scope,
|
|
|
|
&el->el_filter );
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
case LIMBO_ATTRS:
|
2006-12-24 23:44:56 +08:00
|
|
|
rc = monitor_back_register_entry_attrs(
|
2007-09-15 23:34:49 +08:00
|
|
|
el->el_ndn,
|
2004-11-12 20:54:42 +08:00
|
|
|
el->el_a,
|
|
|
|
el->el_cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
&el->el_nbase,
|
2004-11-12 20:54:42 +08:00
|
|
|
el->el_scope,
|
|
|
|
&el->el_filter );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIMBO_CB:
|
2006-12-24 23:44:56 +08:00
|
|
|
rc = monitor_back_register_entry_callback(
|
2007-09-15 23:34:49 +08:00
|
|
|
el->el_ndn,
|
2004-11-12 20:54:42 +08:00
|
|
|
el->el_cb,
|
2006-09-09 06:02:32 +08:00
|
|
|
&el->el_nbase,
|
2004-11-12 20:54:42 +08:00
|
|
|
el->el_scope,
|
|
|
|
&el->el_filter );
|
|
|
|
break;
|
|
|
|
|
2007-03-22 07:22:49 +08:00
|
|
|
case LIMBO_BACKEND:
|
|
|
|
rc = monitor_back_register_backend( el->el_bi );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIMBO_DATABASE:
|
2007-09-15 23:34:49 +08:00
|
|
|
rc = monitor_back_register_database( el->el_be, el->el_ndn );
|
2007-03-22 07:22:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LIMBO_OVERLAY_INFO:
|
|
|
|
rc = monitor_back_register_overlay_info( el->el_on );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LIMBO_OVERLAY:
|
|
|
|
rc = monitor_back_register_overlay( el->el_be );
|
|
|
|
break;
|
|
|
|
|
2004-11-12 20:54:42 +08:00
|
|
|
default:
|
|
|
|
assert( 0 );
|
|
|
|
}
|
2004-11-09 02:52:27 +08:00
|
|
|
|
|
|
|
tmp = el;
|
|
|
|
el = el->el_next;
|
2007-08-27 15:12:12 +08:00
|
|
|
monitor_back_destroy_limbo_entry( tmp, rc );
|
2007-06-09 22:11:16 +08:00
|
|
|
|
|
|
|
if ( rc != 0 ) {
|
|
|
|
/* try all, but report error at end */
|
|
|
|
retcode = 1;
|
|
|
|
}
|
2004-11-09 02:52:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
mi->mi_entry_limbo = NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-09 22:11:16 +08:00
|
|
|
return retcode;
|
2001-07-15 01:34:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_config(
|
|
|
|
BackendInfo *bi,
|
|
|
|
const char *fname,
|
|
|
|
int lineno,
|
|
|
|
int argc,
|
2005-04-28 05:30:35 +08:00
|
|
|
char **argv )
|
2001-07-15 01:34:24 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* eventually, will hold backend specific configuration parameters
|
|
|
|
*/
|
2003-12-07 15:07:00 +08:00
|
|
|
return SLAP_CONF_UNKNOWN;
|
2001-07-15 01:34:24 +08:00
|
|
|
}
|
|
|
|
|
2005-11-27 07:35:45 +08:00
|
|
|
#if 0
|
2001-07-15 01:34:24 +08:00
|
|
|
int
|
|
|
|
monitor_back_db_config(
|
|
|
|
Backend *be,
|
|
|
|
const char *fname,
|
|
|
|
int lineno,
|
|
|
|
int argc,
|
2005-04-28 05:30:35 +08:00
|
|
|
char **argv )
|
2001-07-15 01:34:24 +08:00
|
|
|
{
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_info_t *mi = ( monitor_info_t * )be->be_private;
|
2003-04-13 01:41:49 +08:00
|
|
|
|
2002-08-29 18:32:48 +08:00
|
|
|
/*
|
|
|
|
* eventually, will hold database specific configuration parameters
|
|
|
|
*/
|
2005-04-30 04:29:59 +08:00
|
|
|
return SLAP_CONF_UNKNOWN;
|
2001-07-15 01:34:24 +08:00
|
|
|
}
|
2005-11-27 07:35:45 +08:00
|
|
|
#endif
|
2001-07-15 01:34:24 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
monitor_back_db_destroy(
|
2007-07-26 01:21:05 +08:00
|
|
|
BackendDB *be,
|
2007-08-03 20:02:07 +08:00
|
|
|
ConfigReply *cr)
|
2001-07-15 01:34:24 +08:00
|
|
|
{
|
2005-04-30 04:29:59 +08:00
|
|
|
monitor_info_t *mi = ( monitor_info_t * )be->be_private;
|
|
|
|
|
2005-08-09 06:49:54 +08:00
|
|
|
if ( mi == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2001-07-15 01:34:24 +08:00
|
|
|
/*
|
|
|
|
* FIXME: destroys all the data
|
|
|
|
*/
|
2005-04-30 04:29:59 +08:00
|
|
|
/* NOTE: mi points to static storage; don't free it */
|
|
|
|
|
2005-07-20 22:59:56 +08:00
|
|
|
(void)monitor_cache_destroy( mi );
|
|
|
|
|
|
|
|
if ( monitor_subsys ) {
|
2005-08-09 04:01:04 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
|
2005-08-09 04:45:10 +08:00
|
|
|
if ( monitor_subsys[ i ]->mss_destroy ) {
|
|
|
|
monitor_subsys[ i ]->mss_destroy( be, monitor_subsys[ i ] );
|
|
|
|
}
|
|
|
|
|
2005-08-09 04:01:04 +08:00
|
|
|
if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_rdn ) ) {
|
|
|
|
ch_free( monitor_subsys[ i ]->mss_rdn.bv_val );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-20 22:59:56 +08:00
|
|
|
ch_free( monitor_subsys );
|
|
|
|
}
|
2007-08-27 15:12:12 +08:00
|
|
|
|
|
|
|
if ( mi->mi_entry_limbo ) {
|
|
|
|
entry_limbo_t *el = mi->mi_entry_limbo;
|
|
|
|
|
|
|
|
for ( ; el; ) {
|
|
|
|
entry_limbo_t *tmp = el;
|
|
|
|
el = el->el_next;
|
|
|
|
monitor_back_destroy_limbo_entry( tmp, 1 );
|
|
|
|
}
|
|
|
|
}
|
2005-07-20 22:59:56 +08:00
|
|
|
|
2005-08-09 05:29:13 +08:00
|
|
|
ldap_pvt_thread_mutex_destroy( &monitor_info.mi_cache_mutex );
|
|
|
|
|
2005-08-09 06:49:54 +08:00
|
|
|
be->be_private = NULL;
|
|
|
|
|
2001-07-15 01:34:24 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-11-14 02:52:44 +08:00
|
|
|
#if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
|
|
|
|
|
2004-11-16 03:45:49 +08:00
|
|
|
/* conditionally define the init_module() function */
|
|
|
|
SLAP_BACKEND_INIT_MODULE( monitor )
|
2004-11-14 02:52:44 +08:00
|
|
|
|
2004-11-16 03:45:49 +08:00
|
|
|
#endif /* SLAPD_MONITOR == SLAPD_MOD_DYNAMIC */
|
2004-11-14 02:52:44 +08:00
|
|
|
|