2001-07-15 01:34:24 +08:00
|
|
|
/* database.c - deals with database subsystem */
|
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>
|
2003-05-15 05:36:34 +08:00
|
|
|
#include <ac/string.h>
|
2004-11-15 23:46:56 +08:00
|
|
|
#include <ac/unistd.h>
|
2001-07-15 01:34:24 +08:00
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "back-monitor.h"
|
|
|
|
|
2002-12-14 23:04:37 +08:00
|
|
|
#if defined(LDAP_SLAPI)
|
2003-02-10 10:09:00 +08:00
|
|
|
#include "slapi.h"
|
2005-03-02 04:05:20 +08:00
|
|
|
static int monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e );
|
2002-12-14 23:04:37 +08:00
|
|
|
#endif /* defined(LDAP_SLAPI) */
|
|
|
|
|
2004-12-02 20:32:36 +08:00
|
|
|
/* for PATH_MAX on some systems (e.g. Solaris) */
|
|
|
|
#ifdef HAVE_LIMITS_H
|
|
|
|
#include <limits.h>
|
|
|
|
#endif /* HAVE_LIMITS_H */
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
#define PATH_MAX 4095
|
|
|
|
#endif /* ! PATH_MAX */
|
|
|
|
|
2005-08-09 04:45:10 +08:00
|
|
|
static int
|
|
|
|
monitor_subsys_database_modify(
|
|
|
|
Operation *op,
|
|
|
|
SlapReply *rs,
|
|
|
|
Entry *e );
|
|
|
|
|
2004-05-03 06:08:12 +08:00
|
|
|
static struct restricted_ops_t {
|
2004-05-02 02:55:52 +08:00
|
|
|
struct berval op;
|
|
|
|
unsigned int tag;
|
2004-05-03 06:08:12 +08:00
|
|
|
} restricted_ops[] = {
|
2004-05-02 02:55:52 +08:00
|
|
|
{ BER_BVC( "add" ), SLAP_RESTRICT_OP_ADD },
|
|
|
|
{ BER_BVC( "bind" ), SLAP_RESTRICT_OP_BIND },
|
|
|
|
{ BER_BVC( "compare" ), SLAP_RESTRICT_OP_COMPARE },
|
|
|
|
{ BER_BVC( "delete" ), SLAP_RESTRICT_OP_DELETE },
|
|
|
|
{ BER_BVC( "extended" ), SLAP_RESTRICT_OP_EXTENDED },
|
|
|
|
{ BER_BVC( "modify" ), SLAP_RESTRICT_OP_MODIFY },
|
|
|
|
{ BER_BVC( "rename" ), SLAP_RESTRICT_OP_RENAME },
|
|
|
|
{ BER_BVC( "search" ), SLAP_RESTRICT_OP_SEARCH },
|
|
|
|
{ BER_BVNULL, 0 }
|
2004-05-03 06:08:12 +08:00
|
|
|
}, restricted_exops[] = {
|
2004-05-02 02:55:52 +08:00
|
|
|
{ BER_BVC( LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
|
|
|
|
{ BER_BVC( LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
|
2006-02-16 13:01:29 +08:00
|
|
|
{ BER_BVC( LDAP_EXOP_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
|
|
|
|
{ BER_BVC( LDAP_EXOP_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
|
2004-05-02 02:55:52 +08:00
|
|
|
{ BER_BVNULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2004-11-09 02:52:27 +08:00
|
|
|
init_readOnly( monitor_info_t *mi, Entry *e, slap_mask_t restrictops )
|
2004-05-02 02:55:52 +08:00
|
|
|
{
|
|
|
|
struct berval *tf = ( ( restrictops & SLAP_RESTRICT_OP_MASK ) == SLAP_RESTRICT_OP_WRITES ) ?
|
|
|
|
(struct berval *)&slap_true_bv : (struct berval *)&slap_false_bv;
|
|
|
|
|
2005-04-22 05:05:38 +08:00
|
|
|
return attr_merge_one( e, mi->mi_ad_readOnly, tf, tf );
|
2004-05-02 02:55:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-11-09 02:52:27 +08:00
|
|
|
init_restrictedOperation( monitor_info_t *mi, Entry *e, slap_mask_t restrictops )
|
2004-05-02 02:55:52 +08:00
|
|
|
{
|
|
|
|
int i, rc;
|
|
|
|
|
2004-05-03 06:08:12 +08:00
|
|
|
for ( i = 0; restricted_ops[ i ].op.bv_val; i++ ) {
|
|
|
|
if ( restrictops & restricted_ops[ i ].tag ) {
|
2004-05-02 02:55:52 +08:00
|
|
|
rc = attr_merge_one( e, mi->mi_ad_restrictedOperation,
|
2005-04-22 05:05:38 +08:00
|
|
|
&restricted_ops[ i ].op,
|
|
|
|
&restricted_ops[ i ].op );
|
2004-05-02 02:55:52 +08:00
|
|
|
if ( rc ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-03 06:08:12 +08:00
|
|
|
for ( i = 0; restricted_exops[ i ].op.bv_val; i++ ) {
|
|
|
|
if ( restrictops & restricted_exops[ i ].tag ) {
|
2004-05-02 02:55:52 +08:00
|
|
|
rc = attr_merge_one( e, mi->mi_ad_restrictedOperation,
|
2005-04-22 05:05:38 +08:00
|
|
|
&restricted_exops[ i ].op,
|
|
|
|
&restricted_exops[ i ].op );
|
2004-05-02 02:55:52 +08:00
|
|
|
if ( rc ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return LDAP_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-09-09 10:35:58 +08:00
|
|
|
static int
|
|
|
|
monitor_subsys_database_init_one(
|
|
|
|
monitor_info_t *mi,
|
|
|
|
BackendDB *be,
|
|
|
|
monitor_subsys_t *ms,
|
|
|
|
monitor_subsys_t *ms_backend,
|
|
|
|
monitor_subsys_t *ms_overlay,
|
|
|
|
struct berval *rdn,
|
|
|
|
Entry *e_database,
|
|
|
|
Entry ***epp )
|
|
|
|
{
|
|
|
|
char buf[ BACKMONITOR_BUFSIZE ];
|
|
|
|
int j;
|
|
|
|
slap_overinfo *oi = NULL;
|
|
|
|
BackendInfo *bi, *bi2;
|
|
|
|
Entry *e;
|
|
|
|
monitor_entry_t *mp;
|
|
|
|
char *rdnval = strchr( rdn->bv_val, '=' ) + 1;
|
|
|
|
struct berval bv;
|
|
|
|
|
|
|
|
bi = be->bd_info;
|
|
|
|
|
|
|
|
if ( overlay_is_over( be ) ) {
|
|
|
|
oi = (slap_overinfo *)be->bd_info->bi_private;
|
|
|
|
bi = oi->oi_orig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Subordinates are not exposed as their own naming context */
|
|
|
|
if ( SLAP_GLUE_SUBORDINATE( be ) ) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
e = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn, rdn,
|
|
|
|
mi->mi_oc_monitoredObject, mi, NULL, NULL );
|
|
|
|
|
|
|
|
if ( e == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_subsys_database_init: "
|
|
|
|
"unable to create entry \"%s,%s\"\n",
|
|
|
|
rdn->bv_val, ms->mss_dn.bv_val, 0 );
|
|
|
|
return( -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
ber_str2bv( bi->bi_type, 0, 0, &bv );
|
|
|
|
attr_merge_one( e, mi->mi_ad_monitoredInfo, &bv, NULL );
|
|
|
|
attr_merge_one( e, mi->mi_ad_monitorIsShadow,
|
|
|
|
SLAP_SHADOW( be ) ? (struct berval *)&slap_true_bv :
|
|
|
|
(struct berval *)&slap_false_bv, NULL );
|
|
|
|
|
|
|
|
if ( SLAP_MONITOR( be ) ) {
|
|
|
|
attr_merge( e, slap_schema.si_ad_monitorContext,
|
|
|
|
be->be_suffix, be->be_nsuffix );
|
|
|
|
attr_merge( e_database, slap_schema.si_ad_monitorContext,
|
|
|
|
be->be_suffix, be->be_nsuffix );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if ( be->be_suffix == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_subsys_database_init: "
|
|
|
|
"missing suffix for %s\n",
|
|
|
|
rdnval, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
attr_merge( e, slap_schema.si_ad_namingContexts,
|
|
|
|
be->be_suffix, be->be_nsuffix );
|
|
|
|
attr_merge( e_database, slap_schema.si_ad_namingContexts,
|
|
|
|
be->be_suffix, be->be_nsuffix );
|
|
|
|
}
|
|
|
|
|
|
|
|
(void)init_readOnly( mi, e, be->be_restrictops );
|
|
|
|
(void)init_restrictedOperation( mi, e, be->be_restrictops );
|
|
|
|
|
|
|
|
if ( SLAP_SHADOW( be ) && be->be_update_refs ) {
|
|
|
|
attr_merge_normalize( e, mi->mi_ad_monitorUpdateRef,
|
|
|
|
be->be_update_refs, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( oi != NULL ) {
|
|
|
|
slap_overinst *on = oi->oi_list,
|
|
|
|
*on1 = on;
|
|
|
|
|
|
|
|
for ( ; on; on = on->on_next ) {
|
|
|
|
slap_overinst *on2;
|
|
|
|
|
|
|
|
for ( on2 = on1; on2 != on; on2 = on2->on_next ) {
|
|
|
|
if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( on2 != on ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ber_str2bv( on->on_bi.bi_type, 0, 0, &bv );
|
|
|
|
attr_merge_normalize_one( e, mi->mi_ad_monitorOverlay,
|
|
|
|
&bv, NULL );
|
|
|
|
|
|
|
|
/* find the overlay number, j */
|
|
|
|
for ( on2 = overlay_next( NULL ), j = 0; on2; on2 = overlay_next( on2 ), j++ ) {
|
|
|
|
if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert( on2 != NULL );
|
|
|
|
|
|
|
|
snprintf( buf, sizeof( buf ),
|
|
|
|
"cn=Overlay %d,%s",
|
|
|
|
j, ms_overlay->mss_dn.bv_val );
|
|
|
|
ber_str2bv( buf, 0, 0, &bv );
|
|
|
|
attr_merge_normalize_one( e,
|
|
|
|
slap_schema.si_ad_seeAlso,
|
|
|
|
&bv, NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
j = -1;
|
|
|
|
LDAP_STAILQ_FOREACH( bi2, &backendInfo, bi_next ) {
|
|
|
|
j++;
|
|
|
|
if ( bi2->bi_type == bi->bi_type ) {
|
|
|
|
snprintf( buf, sizeof( buf ),
|
|
|
|
"cn=Backend %d,%s",
|
|
|
|
j, ms_backend->mss_dn.bv_val );
|
|
|
|
bv.bv_val = buf;
|
|
|
|
bv.bv_len = strlen( buf );
|
|
|
|
attr_merge_normalize_one( e,
|
|
|
|
slap_schema.si_ad_seeAlso,
|
|
|
|
&bv, NULL );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* we must find it! */
|
|
|
|
assert( j >= 0 );
|
|
|
|
|
|
|
|
mp = monitor_entrypriv_create();
|
|
|
|
if ( mp == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
e->e_private = ( void * )mp;
|
|
|
|
mp->mp_info = ms;
|
|
|
|
mp->mp_flags = ms->mss_flags
|
|
|
|
| MONITOR_F_SUB;
|
|
|
|
|
|
|
|
if ( monitor_cache_add( mi, e ) ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_subsys_database_init: "
|
|
|
|
"unable to add entry \"%s,%s\"\n",
|
|
|
|
rdn->bv_val, ms->mss_dn.bv_val, 0 );
|
|
|
|
return( -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(LDAP_SLAPI)
|
|
|
|
monitor_back_add_plugin( mi, be, e );
|
|
|
|
#endif /* defined(LDAP_SLAPI) */
|
|
|
|
|
|
|
|
if ( oi != NULL ) {
|
|
|
|
Entry **ep_overlay = &mp->mp_children;
|
|
|
|
monitor_entry_t *mp_overlay;
|
|
|
|
slap_overinst *on = oi->oi_list;
|
|
|
|
int o;
|
|
|
|
|
|
|
|
for ( o = 0; on; o++, on = on->on_next ) {
|
|
|
|
Entry *e_overlay;
|
|
|
|
slap_overinst *on2;
|
|
|
|
|
|
|
|
/* find the overlay number, j */
|
|
|
|
for ( on2 = overlay_next( NULL ), j = 0; on2; on2 = overlay_next( on2 ), j++ ) {
|
|
|
|
if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert( on2 != NULL );
|
|
|
|
|
|
|
|
bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Overlay %d", o );
|
|
|
|
bv.bv_val = buf;
|
|
|
|
|
|
|
|
e_overlay = monitor_entry_stub( &e->e_name, &e->e_nname, &bv,
|
|
|
|
mi->mi_oc_monitoredObject, mi, NULL, NULL );
|
|
|
|
|
|
|
|
if ( e_overlay == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_subsys_database_init: "
|
|
|
|
"unable to create entry "
|
|
|
|
"\"cn=Overlay %d,%s,%s\"\n",
|
|
|
|
o, rdn->bv_val, ms->mss_dn.bv_val );
|
|
|
|
return( -1 );
|
|
|
|
}
|
|
|
|
ber_str2bv( on->on_bi.bi_type, 0, 0, &bv );
|
|
|
|
attr_merge_one( e_overlay, mi->mi_ad_monitoredInfo, &bv, NULL );
|
|
|
|
|
|
|
|
bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Overlay %d,%s",
|
|
|
|
j, ms_overlay->mss_dn.bv_val );
|
|
|
|
bv.bv_val = buf;
|
|
|
|
attr_merge_normalize_one( e_overlay, slap_schema.si_ad_seeAlso,
|
|
|
|
&bv, NULL );
|
|
|
|
|
|
|
|
if ( SLAP_MONITOR( be ) ) {
|
|
|
|
attr_merge( e_overlay, slap_schema.si_ad_monitorContext,
|
|
|
|
be->be_suffix, be->be_nsuffix );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
attr_merge( e_overlay, slap_schema.si_ad_namingContexts,
|
|
|
|
be->be_suffix, be->be_nsuffix );
|
|
|
|
}
|
|
|
|
|
|
|
|
mp_overlay = monitor_entrypriv_create();
|
|
|
|
if ( mp_overlay == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
e_overlay->e_private = ( void * )mp_overlay;
|
|
|
|
mp_overlay->mp_info = ms;
|
|
|
|
mp_overlay->mp_flags = ms->mss_flags
|
|
|
|
| MONITOR_F_SUB;
|
|
|
|
|
|
|
|
if ( monitor_cache_add( mi, e_overlay ) ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_subsys_database_init: "
|
|
|
|
"unable to add entry "
|
|
|
|
"\"cn=Overlay %d,%s,%s\"\n",
|
|
|
|
o, rdn->bv_val, ms->mss_dn.bv_val );
|
|
|
|
return( -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
*ep_overlay = e_overlay;
|
|
|
|
ep_overlay = &mp_overlay->mp_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
**epp = e;
|
|
|
|
*epp = &mp->mp_next;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-07-15 01:34:24 +08:00
|
|
|
int
|
|
|
|
monitor_subsys_database_init(
|
2004-11-09 02:52:27 +08:00
|
|
|
BackendDB *be,
|
2006-09-09 10:35:58 +08:00
|
|
|
monitor_subsys_t *ms )
|
2001-07-15 01:34:24 +08:00
|
|
|
{
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_info_t *mi;
|
2004-09-13 06:12:58 +08:00
|
|
|
Entry *e_database, **ep;
|
2006-09-09 10:35:58 +08:00
|
|
|
int i, rc;
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_entry_t *mp;
|
|
|
|
monitor_subsys_t *ms_backend,
|
2004-11-08 18:10:15 +08:00
|
|
|
*ms_overlay;
|
2006-09-09 10:35:58 +08:00
|
|
|
struct berval bv;
|
2001-07-15 01:34:24 +08:00
|
|
|
|
|
|
|
assert( be != NULL );
|
|
|
|
|
2005-08-09 04:45:10 +08:00
|
|
|
ms->mss_modify = monitor_subsys_database_modify;
|
|
|
|
|
2004-11-09 02:52:27 +08:00
|
|
|
mi = ( monitor_info_t * )be->be_private;
|
2001-07-15 01:34:24 +08:00
|
|
|
|
2004-11-08 18:10:15 +08:00
|
|
|
ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME );
|
|
|
|
if ( ms_backend == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_subsys_database_init: "
|
|
|
|
"unable to get "
|
|
|
|
"\"" SLAPD_MONITOR_BACKEND_NAME "\" "
|
|
|
|
"subsystem\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ms_overlay = monitor_back_get_subsys( SLAPD_MONITOR_OVERLAY_NAME );
|
|
|
|
if ( ms_overlay == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_subsys_database_init: "
|
|
|
|
"unable to get "
|
|
|
|
"\"" SLAPD_MONITOR_OVERLAY_NAME "\" "
|
|
|
|
"subsystem\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( monitor_cache_get( mi, &ms->mss_ndn, &e_database ) ) {
|
2001-07-15 01:34:24 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"monitor_subsys_database_init: "
|
2004-09-13 06:12:58 +08:00
|
|
|
"unable to get entry \"%s\"\n",
|
2004-11-08 18:10:15 +08:00
|
|
|
ms->mss_ndn.bv_val, 0, 0 );
|
2001-07-15 01:34:24 +08:00
|
|
|
return( -1 );
|
|
|
|
}
|
2004-05-02 02:55:52 +08:00
|
|
|
|
2004-07-27 05:26:34 +08:00
|
|
|
(void)init_readOnly( mi, e_database, frontendDB->be_restrictops );
|
|
|
|
(void)init_restrictedOperation( mi, e_database, frontendDB->be_restrictops );
|
2001-07-15 01:34:24 +08:00
|
|
|
|
2004-11-09 02:52:27 +08:00
|
|
|
mp = ( monitor_entry_t * )e_database->e_private;
|
2004-09-13 06:12:58 +08:00
|
|
|
mp->mp_children = NULL;
|
|
|
|
ep = &mp->mp_children;
|
|
|
|
|
2006-09-09 10:35:58 +08:00
|
|
|
BER_BVSTR( &bv, "cn=Frontend" );
|
|
|
|
rc = monitor_subsys_database_init_one( mi, frontendDB,
|
|
|
|
ms, ms_backend, ms_overlay, &bv, e_database, &ep );
|
|
|
|
if ( rc != 0 ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-03-24 13:13:31 +08:00
|
|
|
i = -1;
|
|
|
|
LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
|
2004-03-16 09:22:34 +08:00
|
|
|
char buf[ BACKMONITOR_BUFSIZE ];
|
2002-11-30 01:43:28 +08:00
|
|
|
|
2006-01-12 16:40:09 +08:00
|
|
|
bv.bv_val = buf;
|
2006-09-09 10:35:58 +08:00
|
|
|
bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Database %d", ++i );
|
|
|
|
if ( bv.bv_len >= sizeof( buf ) ) {
|
2004-11-08 18:55:33 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2004-11-15 23:46:56 +08:00
|
|
|
|
2006-09-09 10:35:58 +08:00
|
|
|
rc = monitor_subsys_database_init_one( mi, be,
|
|
|
|
ms, ms_backend, ms_overlay, &bv, e_database, &ep );
|
|
|
|
if ( rc != 0 ) {
|
|
|
|
return rc;
|
2004-11-15 23:46:56 +08:00
|
|
|
}
|
2001-07-15 01:34:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
monitor_cache_release( mi, e_database );
|
|
|
|
|
|
|
|
return( 0 );
|
|
|
|
}
|
|
|
|
|
2004-05-03 06:08:12 +08:00
|
|
|
/*
|
|
|
|
* v: array of values
|
|
|
|
* cur: must not contain the tags corresponding to the values in v
|
|
|
|
* delta: will contain the tags corresponding to the values in v
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
value_mask( BerVarray v, slap_mask_t cur, slap_mask_t *delta )
|
|
|
|
{
|
|
|
|
for ( ; !BER_BVISNULL( v ); v++ ) {
|
|
|
|
struct restricted_ops_t *rops;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ( OID_LEADCHAR( v->bv_val[ 0 ] ) ) {
|
|
|
|
rops = restricted_exops;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
rops = restricted_ops;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0; !BER_BVISNULL( &rops[ i ].op ); i++ ) {
|
|
|
|
if ( ber_bvstrcasecmp( v, &rops[ i ].op ) != 0 ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rops[ i ].tag & *delta ) {
|
|
|
|
return LDAP_OTHER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rops[ i ].tag & cur ) {
|
|
|
|
return LDAP_OTHER;
|
|
|
|
}
|
|
|
|
|
|
|
|
cur |= rops[ i ].tag;
|
|
|
|
*delta |= rops[ i ].tag;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( BER_BVISNULL( &rops[ i ].op ) ) {
|
|
|
|
return LDAP_INVALID_SYNTAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return LDAP_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-09 04:45:10 +08:00
|
|
|
static int
|
2004-04-27 09:56:38 +08:00
|
|
|
monitor_subsys_database_modify(
|
|
|
|
Operation *op,
|
2005-04-28 05:30:35 +08:00
|
|
|
SlapReply *rs,
|
2005-08-09 04:45:10 +08:00
|
|
|
Entry *e )
|
2004-04-27 09:56:38 +08:00
|
|
|
{
|
2004-11-09 02:52:27 +08:00
|
|
|
monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private;
|
|
|
|
int rc = LDAP_OTHER;
|
|
|
|
Attribute *save_attrs, *a;
|
|
|
|
Modifications *ml;
|
|
|
|
Backend *be;
|
|
|
|
int ro_gotval = 1, i, n;
|
2004-05-03 06:08:12 +08:00
|
|
|
slap_mask_t rp_add = 0, rp_delete = 0, rp_cur;
|
2004-11-09 02:52:27 +08:00
|
|
|
struct berval *tf;
|
2004-04-27 09:56:38 +08:00
|
|
|
|
|
|
|
i = sscanf( e->e_nname.bv_val, "cn=database %d,", &n );
|
2005-04-28 05:30:35 +08:00
|
|
|
if ( i != 1 ) {
|
|
|
|
return SLAP_CB_CONTINUE;
|
|
|
|
}
|
2004-04-27 09:56:38 +08:00
|
|
|
|
2005-04-28 05:30:35 +08:00
|
|
|
if ( n < 0 || n >= nBackendDB ) {
|
|
|
|
rs->sr_text = "invalid database index";
|
|
|
|
return ( rs->sr_err = LDAP_NO_SUCH_OBJECT );
|
|
|
|
}
|
2004-04-27 09:56:38 +08:00
|
|
|
|
2005-03-24 13:13:31 +08:00
|
|
|
LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
if ( n == 0 ) {
|
|
|
|
break;
|
|
|
|
}
|
2005-03-24 13:13:31 +08:00
|
|
|
n--;
|
|
|
|
}
|
2004-05-03 06:08:12 +08:00
|
|
|
/* do not allow some changes on back-monitor (needs work)... */
|
2005-04-28 05:30:35 +08:00
|
|
|
if ( SLAP_MONITOR( be ) ) {
|
|
|
|
rs->sr_text = "no modifications allowed to monitor database entry";
|
|
|
|
return ( rs->sr_err = LDAP_UNWILLING_TO_PERFORM );
|
|
|
|
}
|
2004-04-27 20:18:42 +08:00
|
|
|
|
2004-05-03 06:08:12 +08:00
|
|
|
rp_cur = be->be_restrictops;
|
2004-04-27 09:56:38 +08:00
|
|
|
|
|
|
|
save_attrs = e->e_attrs;
|
|
|
|
e->e_attrs = attrs_dup( e->e_attrs );
|
|
|
|
|
2005-04-28 05:30:35 +08:00
|
|
|
for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
|
2004-04-27 09:56:38 +08:00
|
|
|
Modification *mod = &ml->sml_mod;
|
|
|
|
|
|
|
|
if ( mod->sm_desc == mi->mi_ad_readOnly ) {
|
2004-05-03 06:08:12 +08:00
|
|
|
int val = -1;
|
2004-04-27 09:56:38 +08:00
|
|
|
|
|
|
|
if ( mod->sm_values ) {
|
2004-05-03 06:08:12 +08:00
|
|
|
if ( !BER_BVISNULL( &mod->sm_values[ 1 ] ) ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rs->sr_text = "attempting to modify multiple values of single-valued attribute";
|
|
|
|
rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
2004-04-27 09:56:38 +08:00
|
|
|
}
|
2004-05-03 06:08:12 +08:00
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
if ( bvmatch( &slap_true_bv, mod->sm_values )) {
|
|
|
|
val = 1;
|
2004-05-03 06:08:12 +08:00
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
} else if ( bvmatch( &slap_false_bv, mod->sm_values )) {
|
|
|
|
val = 0;
|
2004-05-03 06:08:12 +08:00
|
|
|
|
|
|
|
} else {
|
2005-04-28 05:30:35 +08:00
|
|
|
assert( 0 );
|
|
|
|
rc = rs->sr_err = LDAP_INVALID_SYNTAX;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
2004-04-27 09:56:38 +08:00
|
|
|
}
|
|
|
|
}
|
2004-05-03 06:08:12 +08:00
|
|
|
|
|
|
|
switch ( mod->sm_op ) {
|
2004-04-27 09:56:38 +08:00
|
|
|
case LDAP_MOD_DELETE:
|
2004-05-03 06:08:12 +08:00
|
|
|
if ( ro_gotval < 1 ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ro_gotval--;
|
|
|
|
|
|
|
|
if ( val == 0 && ( rp_cur & SLAP_RESTRICT_OP_WRITES ) == SLAP_RESTRICT_OP_WRITES ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
2004-04-27 09:56:38 +08:00
|
|
|
}
|
2004-05-03 06:08:12 +08:00
|
|
|
|
|
|
|
if ( val == 1 && ( rp_cur & SLAP_RESTRICT_OP_WRITES ) != SLAP_RESTRICT_OP_WRITES ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
break;
|
2004-05-03 06:08:12 +08:00
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
case LDAP_MOD_REPLACE:
|
2004-05-03 06:08:12 +08:00
|
|
|
ro_gotval = 0;
|
|
|
|
/* fall thru */
|
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
case LDAP_MOD_ADD:
|
2004-05-03 06:08:12 +08:00
|
|
|
if ( ro_gotval > 0 ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ro_gotval++;
|
|
|
|
|
|
|
|
if ( val == 1 ) {
|
|
|
|
rp_add |= (~rp_cur) & SLAP_RESTRICT_OP_WRITES;
|
|
|
|
rp_cur |= SLAP_RESTRICT_OP_WRITES;
|
|
|
|
rp_delete &= ~SLAP_RESTRICT_OP_WRITES;
|
|
|
|
|
|
|
|
} else if ( val == 0 ) {
|
|
|
|
rp_delete |= rp_cur & SLAP_RESTRICT_OP_WRITES;
|
|
|
|
rp_cur &= ~SLAP_RESTRICT_OP_WRITES;
|
|
|
|
rp_add &= ~SLAP_RESTRICT_OP_WRITES;
|
2004-04-27 09:56:38 +08:00
|
|
|
}
|
|
|
|
break;
|
2004-05-03 06:08:12 +08:00
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
default:
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_OTHER;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
2004-04-27 09:56:38 +08:00
|
|
|
}
|
2004-05-03 06:08:12 +08:00
|
|
|
|
|
|
|
} else if ( mod->sm_desc == mi->mi_ad_restrictedOperation ) {
|
|
|
|
slap_mask_t mask = 0;
|
|
|
|
|
|
|
|
switch ( mod->sm_op ) {
|
|
|
|
case LDAP_MOD_DELETE:
|
|
|
|
if ( mod->sm_values == NULL ) {
|
|
|
|
rp_delete = rp_cur;
|
|
|
|
rp_cur = 0;
|
|
|
|
rp_add = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rc = value_mask( mod->sm_values, ~rp_cur, &mask );
|
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
rp_delete |= mask;
|
|
|
|
rp_add &= ~mask;
|
|
|
|
rp_cur &= ~mask;
|
|
|
|
|
|
|
|
} else if ( rc == LDAP_OTHER ) {
|
|
|
|
rc = LDAP_NO_SUCH_ATTRIBUTE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_MOD_REPLACE:
|
|
|
|
rp_delete = rp_cur;
|
|
|
|
rp_cur = 0;
|
|
|
|
rp_add = 0;
|
|
|
|
/* fall thru */
|
|
|
|
|
|
|
|
case LDAP_MOD_ADD:
|
|
|
|
rc = value_mask( mod->sm_values, rp_cur, &mask );
|
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
rp_add |= mask;
|
|
|
|
rp_cur |= mask;
|
|
|
|
rp_delete &= ~mask;
|
|
|
|
|
|
|
|
} else if ( rc == LDAP_OTHER ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_TYPE_OR_VALUE_EXISTS;
|
2004-05-03 06:08:12 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_OTHER;
|
2004-04-27 09:56:38 +08:00
|
|
|
break;
|
|
|
|
}
|
2004-05-02 02:55:52 +08:00
|
|
|
|
2004-05-03 06:08:12 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
goto done;
|
|
|
|
}
|
2004-05-02 02:55:52 +08:00
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
} else if ( is_at_operational( mod->sm_desc->ad_type )) {
|
|
|
|
/* accept all operational attributes */
|
|
|
|
attr_delete( &e->e_attrs, mod->sm_desc );
|
|
|
|
rc = attr_merge( e, mod->sm_desc, mod->sm_values,
|
|
|
|
mod->sm_nvalues );
|
|
|
|
if ( rc ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_OTHER;
|
2004-04-27 09:56:38 +08:00
|
|
|
break;
|
|
|
|
}
|
2004-05-02 02:55:52 +08:00
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
} else {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
|
2004-04-27 09:56:38 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-05-02 02:55:52 +08:00
|
|
|
|
2004-05-03 06:08:12 +08:00
|
|
|
/* sanity checks: */
|
|
|
|
if ( ro_gotval < 1 ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( rp_cur & SLAP_RESTRICT_OP_EXTENDED ) && ( rp_cur & SLAP_RESTRICT_EXOP_MASK ) ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rp_delete & rp_add ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_OTHER;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check current value of readOnly */
|
|
|
|
if ( ( rp_cur & SLAP_RESTRICT_OP_WRITES ) == SLAP_RESTRICT_OP_WRITES ) {
|
|
|
|
tf = (struct berval *)&slap_true_bv;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
tf = (struct berval *)&slap_false_bv;
|
|
|
|
}
|
|
|
|
|
|
|
|
a = attr_find( e->e_attrs, mi->mi_ad_readOnly );
|
|
|
|
if ( a == NULL ) {
|
|
|
|
rc = LDAP_OTHER;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2004-11-08 18:55:33 +08:00
|
|
|
if ( !bvmatch( &a->a_vals[ 0 ], tf ) ) {
|
2004-04-27 09:56:38 +08:00
|
|
|
attr_delete( &e->e_attrs, mi->mi_ad_readOnly );
|
2005-04-22 05:05:38 +08:00
|
|
|
rc = attr_merge_one( e, mi->mi_ad_readOnly, tf, tf );
|
2004-05-03 06:08:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
if ( rp_delete ) {
|
|
|
|
if ( rp_delete == be->be_restrictops ) {
|
|
|
|
attr_delete( &e->e_attrs, mi->mi_ad_restrictedOperation );
|
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
} else {
|
2004-05-03 06:08:12 +08:00
|
|
|
a = attr_find( e->e_attrs, mi->mi_ad_restrictedOperation );
|
|
|
|
if ( a == NULL ) {
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = rs->sr_err = LDAP_OTHER;
|
2004-05-03 06:08:12 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0; !BER_BVISNULL( &restricted_ops[ i ].op ); i++ ) {
|
|
|
|
if ( rp_delete & restricted_ops[ i ].tag ) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for ( j = 0; !BER_BVISNULL( &a->a_nvals[ j ] ); j++ ) {
|
|
|
|
int k;
|
|
|
|
|
|
|
|
if ( !bvmatch( &a->a_nvals[ j ], &restricted_ops[ i ].op ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ch_free( a->a_vals[ j ].bv_val );
|
|
|
|
ch_free( a->a_nvals[ j ].bv_val );
|
|
|
|
|
|
|
|
for ( k = j + 1; !BER_BVISNULL( &a->a_nvals[ k ] ); k++ ) {
|
|
|
|
a->a_vals[ k - 1 ] = a->a_vals[ k ];
|
|
|
|
a->a_nvals[ k - 1 ] = a->a_nvals[ k ];
|
|
|
|
}
|
|
|
|
|
|
|
|
BER_BVZERO( &a->a_vals[ k - 1 ] );
|
|
|
|
BER_BVZERO( &a->a_nvals[ k - 1 ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0; !BER_BVISNULL( &restricted_exops[ i ].op ); i++ ) {
|
|
|
|
if ( rp_delete & restricted_exops[ i ].tag ) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for ( j = 0; !BER_BVISNULL( &a->a_nvals[ j ] ); j++ ) {
|
|
|
|
int k;
|
|
|
|
|
|
|
|
if ( !bvmatch( &a->a_nvals[ j ], &restricted_exops[ i ].op ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ch_free( a->a_vals[ j ].bv_val );
|
|
|
|
ch_free( a->a_nvals[ j ].bv_val );
|
|
|
|
|
|
|
|
for ( k = j + 1; !BER_BVISNULL( &a->a_nvals[ k ] ); k++ ) {
|
|
|
|
a->a_vals[ k - 1 ] = a->a_vals[ k ];
|
|
|
|
a->a_nvals[ k - 1 ] = a->a_nvals[ k ];
|
|
|
|
}
|
|
|
|
|
|
|
|
BER_BVZERO( &a->a_vals[ k - 1 ] );
|
|
|
|
BER_BVZERO( &a->a_nvals[ k - 1 ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rp_add ) {
|
|
|
|
for ( i = 0; !BER_BVISNULL( &restricted_ops[ i ].op ); i++ ) {
|
|
|
|
if ( rp_add & restricted_ops[ i ].tag ) {
|
|
|
|
attr_merge_one( e, mi->mi_ad_restrictedOperation,
|
2005-04-22 05:05:38 +08:00
|
|
|
&restricted_ops[ i ].op,
|
|
|
|
&restricted_ops[ i ].op );
|
2004-05-03 06:08:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0; !BER_BVISNULL( &restricted_exops[ i ].op ); i++ ) {
|
|
|
|
if ( rp_add & restricted_exops[ i ].tag ) {
|
|
|
|
attr_merge_one( e, mi->mi_ad_restrictedOperation,
|
2005-04-22 05:05:38 +08:00
|
|
|
&restricted_exops[ i ].op,
|
|
|
|
&restricted_exops[ i ].op );
|
2004-05-03 06:08:12 +08:00
|
|
|
}
|
2004-04-27 09:56:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-03 06:08:12 +08:00
|
|
|
|
|
|
|
be->be_restrictops = rp_cur;
|
|
|
|
|
|
|
|
done:;
|
2004-04-27 09:56:38 +08:00
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
attrs_free( save_attrs );
|
2005-04-28 05:30:35 +08:00
|
|
|
rc = SLAP_CB_CONTINUE;
|
2004-05-03 06:08:12 +08:00
|
|
|
|
2004-04-27 09:56:38 +08:00
|
|
|
} else {
|
|
|
|
Attribute *tmp = e->e_attrs;
|
|
|
|
e->e_attrs = save_attrs;
|
|
|
|
attrs_free( tmp );
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-12-14 23:04:37 +08:00
|
|
|
#if defined(LDAP_SLAPI)
|
|
|
|
static int
|
2005-03-02 04:05:20 +08:00
|
|
|
monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e_database )
|
2002-12-14 23:04:37 +08:00
|
|
|
{
|
2004-11-09 02:52:27 +08:00
|
|
|
Slapi_PBlock *pCurrentPB;
|
|
|
|
int i, rc = LDAP_SUCCESS;
|
2002-12-14 23:04:37 +08:00
|
|
|
|
2003-12-16 23:49:31 +08:00
|
|
|
if ( slapi_int_pblock_get_first( be, &pCurrentPB ) != LDAP_SUCCESS ) {
|
2002-12-14 23:04:37 +08:00
|
|
|
/*
|
|
|
|
* LDAP_OTHER is returned if no plugins are installed
|
|
|
|
*/
|
|
|
|
rc = LDAP_OTHER;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
do {
|
|
|
|
Slapi_PluginDesc *srchdesc;
|
2003-04-19 01:17:18 +08:00
|
|
|
char buf[ BACKMONITOR_BUFSIZE ];
|
2002-12-14 23:04:37 +08:00
|
|
|
struct berval bv;
|
|
|
|
|
|
|
|
rc = slapi_pblock_get( pCurrentPB, SLAPI_PLUGIN_DESCRIPTION,
|
|
|
|
&srchdesc );
|
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf( buf, sizeof(buf),
|
|
|
|
"plugin %d name: %s; "
|
|
|
|
"vendor: %s; "
|
|
|
|
"version: %s; "
|
|
|
|
"description: %s",
|
|
|
|
i,
|
|
|
|
srchdesc->spd_id,
|
|
|
|
srchdesc->spd_vendor,
|
|
|
|
srchdesc->spd_version,
|
|
|
|
srchdesc->spd_description );
|
|
|
|
|
2005-04-22 05:05:38 +08:00
|
|
|
ber_str2bv( buf, 0, 0, &bv );
|
2003-04-12 08:30:47 +08:00
|
|
|
attr_merge_normalize_one( e_database,
|
2003-05-18 01:19:16 +08:00
|
|
|
mi->mi_ad_monitoredInfo, &bv, NULL );
|
2002-12-14 23:04:37 +08:00
|
|
|
|
|
|
|
i++;
|
|
|
|
|
2003-12-16 23:49:31 +08:00
|
|
|
} while ( ( slapi_int_pblock_get_next( &pCurrentPB ) == LDAP_SUCCESS )
|
2002-12-14 23:04:37 +08:00
|
|
|
&& ( pCurrentPB != NULL ) );
|
|
|
|
|
|
|
|
done:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
#endif /* defined(LDAP_SLAPI) */
|