mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-29 19:19:35 -05:00
add basic monitoring support to back-ldap/slapo-chain (slapo-chain needs work)
This commit is contained in:
parent
b890f60e36
commit
6e18cdb5fd
4 changed files with 131 additions and 34 deletions
|
|
@ -24,10 +24,26 @@
|
|||
#ifndef SLAPD_LDAP_H
|
||||
#define SLAPD_LDAP_H
|
||||
|
||||
#include "../back-monitor/back-monitor.h"
|
||||
|
||||
LDAP_BEGIN_DECL
|
||||
|
||||
struct ldapinfo_t;
|
||||
|
||||
/* stuff required for monitoring */
|
||||
typedef struct ldap_monitor_info_t {
|
||||
monitor_subsys_t lmi_mss;
|
||||
struct ldapinfo_t *lmi_li;
|
||||
|
||||
struct berval lmi_rdn;
|
||||
struct berval lmi_nrdn;
|
||||
monitor_callback_t *lmi_cb;
|
||||
struct berval lmi_base;
|
||||
int lmi_scope;
|
||||
struct berval lmi_filter;
|
||||
struct berval lmi_more_filter;
|
||||
} ldap_monitor_info_t;
|
||||
|
||||
typedef struct ldapconn_t {
|
||||
Connection *lc_conn;
|
||||
#define LDAP_BACK_PCONN ((void *)0x0)
|
||||
|
|
@ -254,6 +270,8 @@ typedef struct ldapinfo_t {
|
|||
|
||||
ldap_avl_info_t li_conninfo;
|
||||
|
||||
ldap_monitor_info_t li_monitor_info;
|
||||
|
||||
sig_atomic_t li_isquarantined;
|
||||
#define LDAP_BACK_FQ_NO (0)
|
||||
#define LDAP_BACK_FQ_YES (1)
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@
|
|||
#include <ac/string.h>
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include "lutil.h"
|
||||
#include "slap.h"
|
||||
#include "back-ldap.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
|
||||
|
|
@ -110,7 +110,7 @@ typedef struct ldap_chain_t {
|
|||
|
||||
static int ldap_chain_db_init_common( BackendDB *be );
|
||||
static int ldap_chain_db_init_one( BackendDB *be );
|
||||
#define ldap_chain_db_open_one(be) (lback)->bi_db_open( (be) )
|
||||
static int ldap_chain_db_open_one( BackendDB *be );
|
||||
#define ldap_chain_db_close_one(be) (0)
|
||||
#define ldap_chain_db_destroy_one(be) (lback)->bi_db_destroy( (be) )
|
||||
|
||||
|
|
@ -136,6 +136,8 @@ ldap_chain_search(
|
|||
BerVarray ref,
|
||||
int depth );
|
||||
|
||||
static slap_overinst ldapchain;
|
||||
|
||||
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
|
||||
static int
|
||||
chaining_control_add(
|
||||
|
|
@ -716,7 +718,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
|
|||
{
|
||||
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
|
||||
ldap_chain_t *lc = (ldap_chain_t *)on->on_bi.bi_private;
|
||||
void *private = op->o_bd->be_private;
|
||||
BackendDB db, *bd = op->o_bd;
|
||||
ldap_chain_cb_t lb = { 0 };
|
||||
slap_callback *sc = op->o_callback,
|
||||
sc2 = { 0 };
|
||||
|
|
@ -772,6 +774,10 @@ ldap_chain_response( Operation *op, SlapReply *rs )
|
|||
* e) what ssf
|
||||
*/
|
||||
|
||||
db = *op->o_bd;
|
||||
SLAP_DBFLAGS( &db ) &= ~SLAP_DBFLAG_MONITORING;
|
||||
op->o_bd = &db;
|
||||
|
||||
matched = rs->sr_matched;
|
||||
rs->sr_matched = NULL;
|
||||
ref = rs->sr_ref;
|
||||
|
|
@ -925,7 +931,7 @@ dont_chain:;
|
|||
rs->sr_type = sr_type;
|
||||
rs->sr_matched = matched;
|
||||
rs->sr_ref = ref;
|
||||
op->o_bd->be_private = private;
|
||||
op->o_bd = bd;
|
||||
op->o_callback = sc;
|
||||
op->o_ndn = ndn;
|
||||
|
||||
|
|
@ -1099,14 +1105,18 @@ chain_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
|
|||
if ( lc->lc_common_li == NULL ) {
|
||||
lc->lc_common_li = li;
|
||||
|
||||
} else if ( avl_insert( &lc->lc_lai.lai_tree, (caddr_t)li,
|
||||
ldap_chain_uri_cmp, ldap_chain_uri_dup ) )
|
||||
{
|
||||
Debug( LDAP_DEBUG_ANY, "slapd-chain: "
|
||||
"database \"%s\" insert failed.\n",
|
||||
e->e_name.bv_val, 0, 0 );
|
||||
rc = LDAP_CONSTRAINT_VIOLATION;
|
||||
goto done;
|
||||
} else {
|
||||
li->li_uri = ch_strdup( at->a_vals[ 0 ].bv_val );
|
||||
value_add_one( &li->li_bvuri, &at->a_vals[ 0 ] );
|
||||
if ( avl_insert( &lc->lc_lai.lai_tree, (caddr_t)li,
|
||||
ldap_chain_uri_cmp, ldap_chain_uri_dup ) )
|
||||
{
|
||||
Debug( LDAP_DEBUG_ANY, "slapd-chain: "
|
||||
"database \"%s\" insert failed.\n",
|
||||
e->e_name.bv_val, 0, 0 );
|
||||
rc = LDAP_CONSTRAINT_VIOLATION;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
done:;
|
||||
|
|
@ -1431,11 +1441,17 @@ ldap_chain_db_init(
|
|||
ldap_chain_t *lc = NULL;
|
||||
|
||||
if ( lback == NULL ) {
|
||||
static BackendInfo lback2;
|
||||
|
||||
lback = backend_info( "ldap" );
|
||||
|
||||
if ( lback == NULL ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
lback2 = *lback;
|
||||
lback2.bi_type = ldapchain.on_bi.bi_type;
|
||||
lback = &lback2;
|
||||
}
|
||||
|
||||
lc = ch_malloc( sizeof( ldap_chain_t ) );
|
||||
|
|
@ -1654,10 +1670,10 @@ ldap_chain_db_open(
|
|||
{
|
||||
slap_overinst *on = (slap_overinst *) be->bd_info;
|
||||
ldap_chain_t *lc = (ldap_chain_t *)on->on_bi.bi_private;
|
||||
slap_mask_t monitoring;
|
||||
int rc = 0;
|
||||
|
||||
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
|
||||
int rc = 0;
|
||||
|
||||
rc = overlay_register_control( be, LDAP_CONTROL_X_CHAINING_BEHAVIOR );
|
||||
if ( rc != 0 ) {
|
||||
return rc;
|
||||
|
|
@ -1671,7 +1687,13 @@ ldap_chain_db_open(
|
|||
be->be_private = be_private;
|
||||
}
|
||||
|
||||
return ldap_chain_db_func( be, db_open );
|
||||
/* filter out and restore monitoring */
|
||||
monitoring = ( SLAP_DBFLAGS( be ) & SLAP_DBFLAG_MONITORING );
|
||||
SLAP_DBFLAGS( be ) &= ~SLAP_DBFLAG_MONITORING;
|
||||
rc = ldap_chain_db_func( be, db_open );
|
||||
SLAP_DBFLAGS( be ) |= monitoring;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1711,17 +1733,18 @@ ldap_chain_db_init_common(
|
|||
{
|
||||
BackendInfo *bi = be->bd_info;
|
||||
ldapinfo_t *li;
|
||||
int t;
|
||||
int rc;
|
||||
|
||||
be->bd_info = lback;
|
||||
be->be_private = NULL;
|
||||
t = lback->bi_db_init( be );
|
||||
if ( t != 0 ) {
|
||||
return t;
|
||||
rc = lback->bi_db_init( be );
|
||||
if ( rc != 0 ) {
|
||||
return rc;
|
||||
}
|
||||
li = (ldapinfo_t *)be->be_private;
|
||||
li->li_urllist_f = NULL;
|
||||
li->li_urllist_p = NULL;
|
||||
|
||||
be->bd_info = bi;
|
||||
|
||||
return 0;
|
||||
|
|
@ -1769,6 +1792,35 @@ ldap_chain_db_init_one(
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ldap_chain_db_open_one(
|
||||
BackendDB *be )
|
||||
{
|
||||
#ifdef SLAPD_MONITOR
|
||||
if ( SLAP_DBMONITORING( be ) ) {
|
||||
ldapinfo_t *li = (ldapinfo_t *)be->be_private;
|
||||
|
||||
if ( li->li_uri == NULL ) {
|
||||
ber_str2bv( "cn=Common Connections", 0, 1,
|
||||
&li->li_monitor_info.lmi_rdn );
|
||||
|
||||
} else {
|
||||
char *ptr;
|
||||
|
||||
li->li_monitor_info.lmi_rdn.bv_len
|
||||
= STRLENOF( "cn=" ) + strlen( li->li_uri );
|
||||
ptr = li->li_monitor_info.lmi_rdn.bv_val
|
||||
= ch_malloc( li->li_monitor_info.lmi_rdn.bv_len + 1 );
|
||||
ptr = lutil_strcopy( ptr, "cn=" );
|
||||
ptr = lutil_strcopy( ptr, li->li_uri );
|
||||
ptr[ 0 ] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* SLAPD_MONITOR */
|
||||
|
||||
return lback->bi_db_open( be );
|
||||
}
|
||||
|
||||
typedef struct ldap_chain_conn_apply_t {
|
||||
BackendDB *be;
|
||||
Connection *conn;
|
||||
|
|
@ -1937,8 +1989,6 @@ ldap_chain_parse_ctrl(
|
|||
}
|
||||
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
|
||||
|
||||
static slap_overinst ldapchain;
|
||||
|
||||
int
|
||||
chain_initialize( void )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ ldap_back_open( BackendInfo *bi )
|
|||
int
|
||||
ldap_back_initialize( BackendInfo *bi )
|
||||
{
|
||||
int rc;
|
||||
|
||||
bi->bi_flags =
|
||||
#ifdef LDAP_DYNAMIC_OBJECTS
|
||||
/* this is set because all the support a proxy has to provide
|
||||
|
|
@ -59,7 +61,7 @@ ldap_back_initialize( BackendInfo *bi )
|
|||
bi->bi_db_init = ldap_back_db_init;
|
||||
bi->bi_db_config = config_generic_wrapper;
|
||||
bi->bi_db_open = ldap_back_db_open;
|
||||
bi->bi_db_close = 0;
|
||||
bi->bi_db_close = ldap_back_db_close;
|
||||
bi->bi_db_destroy = ldap_back_db_destroy;
|
||||
|
||||
bi->bi_op_bind = ldap_back_bind;
|
||||
|
|
@ -80,13 +82,15 @@ ldap_back_initialize( BackendInfo *bi )
|
|||
bi->bi_connection_init = 0;
|
||||
bi->bi_connection_destroy = ldap_back_conn_destroy;
|
||||
|
||||
if ( chain_initialize() ) {
|
||||
return -1;
|
||||
rc = chain_initialize();
|
||||
if ( rc ) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef SLAP_DISTPROC
|
||||
if ( distproc_initialize() ) {
|
||||
return -1;
|
||||
rc = distproc_initialize();
|
||||
if ( rc ) {
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -97,6 +101,7 @@ int
|
|||
ldap_back_db_init( Backend *be )
|
||||
{
|
||||
ldapinfo_t *li;
|
||||
int rc;
|
||||
|
||||
li = (ldapinfo_t *)ch_calloc( 1, sizeof( ldapinfo_t ) );
|
||||
if ( li == NULL ) {
|
||||
|
|
@ -146,7 +151,9 @@ ldap_back_db_init( Backend *be )
|
|||
|
||||
be->be_cf_ocs = be->bd_info->bi_cf_ocs;
|
||||
|
||||
return 0;
|
||||
rc = ldap_back_monitor_db_init( be );
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -199,9 +206,16 @@ ldap_back_db_open( BackendDB *be )
|
|||
}
|
||||
}
|
||||
|
||||
/* monitor setup */
|
||||
rc = ldap_back_monitor_db_open( be );
|
||||
if ( rc != 0 ) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
li->li_flags |= LDAP_BACK_F_ISOPEN;
|
||||
|
||||
return 0;
|
||||
fail:;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -226,9 +240,19 @@ ldap_back_conn_free( void *v_lc )
|
|||
}
|
||||
|
||||
int
|
||||
ldap_back_db_destroy(
|
||||
Backend *be
|
||||
)
|
||||
ldap_back_db_close( Backend *be )
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if ( be->be_private ) {
|
||||
rc = ldap_back_monitor_db_close( be );
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
ldap_back_db_destroy( Backend *be )
|
||||
{
|
||||
if ( be->be_private ) {
|
||||
ldapinfo_t *li = ( ldapinfo_t * )be->be_private;
|
||||
|
|
@ -302,6 +326,8 @@ ldap_back_db_destroy(
|
|||
ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
|
||||
ldap_pvt_thread_mutex_destroy( &li->li_conninfo.lai_mutex );
|
||||
ldap_pvt_thread_mutex_destroy( &li->li_uri_mutex );
|
||||
|
||||
(void)ldap_back_monitor_db_destroy( be );
|
||||
}
|
||||
|
||||
ch_free( be->be_private );
|
||||
|
|
|
|||
|
|
@ -24,13 +24,11 @@
|
|||
LDAP_BEGIN_DECL
|
||||
|
||||
extern BI_init ldap_back_initialize;
|
||||
|
||||
extern BI_open ldap_back_open;
|
||||
extern BI_close ldap_back_close;
|
||||
extern BI_destroy ldap_back_destroy;
|
||||
|
||||
extern BI_db_init ldap_back_db_init;
|
||||
extern BI_db_open ldap_back_db_open;
|
||||
extern BI_db_close ldap_back_db_close;
|
||||
extern BI_db_destroy ldap_back_db_destroy;
|
||||
|
||||
extern BI_op_bind ldap_back_bind;
|
||||
|
|
@ -97,6 +95,11 @@ extern int chain_initialize( void );
|
|||
extern int distproc_initialize( void );
|
||||
#endif
|
||||
|
||||
extern int ldap_back_monitor_db_init( BackendDB *be );
|
||||
extern int ldap_back_monitor_db_open( BackendDB *be );
|
||||
extern int ldap_back_monitor_db_close( BackendDB *be );
|
||||
extern int ldap_back_monitor_db_destroy( BackendDB *be );
|
||||
|
||||
extern LDAP_REBIND_PROC ldap_back_default_rebind;
|
||||
extern LDAP_URLLIST_PROC ldap_back_default_urllist;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue