X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-monitor%2Fdatabase.c;h=eb75a340f08eff109d0ec119c264fed33f0c14e2;hb=0121f8c01dcdef0827c8e6a1770d0a5ae3b0806e;hp=2b7d678eed0d20284c5ccab12c233f43ca01c8e9;hpb=226133ea387089f667f9273ac314bbec25e169c3;p=openldap
diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c
index 2b7d678eed..eb75a340f0 100644
--- a/servers/slapd/back-monitor/database.c
+++ b/servers/slapd/back-monitor/database.c
@@ -2,7 +2,7 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2001-2007 The OpenLDAP Foundation.
+ * Copyright 2001-2009 The OpenLDAP Foundation.
* Portions Copyright 2001-2003 Pierangelo Masarati.
* All rights reserved.
*
@@ -33,14 +33,6 @@
static int monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e );
#endif /* defined(LDAP_SLAPI) */
-/* for PATH_MAX on some systems (e.g. Solaris) */
-#ifdef HAVE_LIMITS_H
-#include
-#endif /* HAVE_LIMITS_H */
-#ifndef PATH_MAX
-#define PATH_MAX 4095
-#endif /* ! PATH_MAX */
-
static int
monitor_subsys_database_modify(
Operation *op,
@@ -74,7 +66,7 @@ init_readOnly( monitor_info_t *mi, Entry *e, slap_mask_t restrictops )
struct berval *tf = ( ( restrictops & SLAP_RESTRICT_OP_MASK ) == SLAP_RESTRICT_OP_WRITES ) ?
(struct berval *)&slap_true_bv : (struct berval *)&slap_false_bv;
- return attr_merge_one( e, mi->mi_ad_readOnly, tf, tf );
+ return attr_merge_one( e, mi->mi_ad_readOnly, tf, NULL );
}
static int
@@ -151,7 +143,7 @@ monitor_subsys_database_init_one(
}
ber_str2bv( bi->bi_type, 0, 0, &bv );
- attr_merge_one( e, mi->mi_ad_monitoredInfo, &bv, NULL );
+ attr_merge_normalize_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 );
@@ -168,12 +160,12 @@ monitor_subsys_database_init_one(
"monitor_subsys_database_init: "
"missing suffix for %s\n",
rdnval, 0, 0 );
- return -1;
+ } else {
+ attr_merge( e, slap_schema.si_ad_namingContexts,
+ be->be_suffix, NULL );
+ attr_merge( e_database, slap_schema.si_ad_namingContexts,
+ be->be_suffix, NULL );
}
- 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 );
@@ -295,7 +287,7 @@ monitor_subsys_database_init_one(
return( -1 );
}
ber_str2bv( on->on_bi.bi_type, 0, 0, &bv );
- attr_merge_one( e_overlay, mi->mi_ad_monitoredInfo, &bv, NULL );
+ attr_merge_normalize_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 );
@@ -309,7 +301,7 @@ monitor_subsys_database_init_one(
} else {
attr_merge( e_overlay, slap_schema.si_ad_namingContexts,
- be->be_suffix, be->be_nsuffix );
+ be->be_suffix, NULL );
}
mp_overlay = monitor_entrypriv_create();
@@ -343,7 +335,8 @@ monitor_subsys_database_init_one(
int
monitor_back_register_database(
- BackendDB *be )
+ BackendDB *be,
+ struct berval *ndn )
{
monitor_info_t *mi;
Entry *e_database, **ep;
@@ -358,7 +351,7 @@ monitor_back_register_database(
assert( be_monitor != NULL );
if ( !monitor_subsys_is_opened() ) {
- return monitor_back_register_database_limbo( be );
+ return monitor_back_register_database_limbo( be, ndn );
}
mi = ( monitor_info_t * )be_monitor->be_private;
@@ -375,7 +368,7 @@ monitor_back_register_database(
}
ms_database = monitor_back_get_subsys( SLAPD_MONITOR_DATABASE_NAME );
- if ( ms_backend == NULL ) {
+ if ( ms_database == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_back_register_database: "
"unable to get "
@@ -412,9 +405,15 @@ monitor_back_register_database(
if ( a ) {
int j, k;
- for ( j = 0; !BER_BVISNULL( &a->a_nvals[ j ] ); j++ ) {
- for ( k = 0; !BER_BVISNULL( &be->be_nsuffix[ k ] ); k++ ) {
- if ( dn_match( &a->a_nvals[ j ], &be->be_nsuffix[ k ] ) ) {
+ /* FIXME: RFC 4512 defines namingContexts without an
+ * equality matching rule, making comparisons
+ * like this one tricky. We use a_vals and
+ * be_suffix instead for now.
+ */
+ for ( j = 0; !BER_BVISNULL( &a->a_vals[ j ] ); j++ ) {
+ for ( k = 0; !BER_BVISNULL( &be->be_suffix[ k ] ); k++ ) {
+ if ( dn_match( &a->a_vals[ j ],
+ &be->be_suffix[ k ] ) ) {
rc = 0;
goto done;
}
@@ -440,9 +439,16 @@ monitor_back_register_database(
if ( rc != 0 ) {
goto done;
}
+ /* database_init_one advanced ep past where we want.
+ * But it stored the entry we want in mp->mp_next.
+ */
+ ep = &mp->mp_next;
done:;
monitor_cache_release( mi, e_database );
+ if ( rc == 0 && ndn && ep && *ep ) {
+ *ndn = (*ep)->e_nname;
+ }
return rc;
}
@@ -827,6 +833,7 @@ monitor_subsys_database_modify(
BER_BVZERO( &a->a_vals[ k - 1 ] );
BER_BVZERO( &a->a_nvals[ k - 1 ] );
+ a->a_numvals--;
}
}
}
@@ -852,9 +859,16 @@ monitor_subsys_database_modify(
BER_BVZERO( &a->a_vals[ k - 1 ] );
BER_BVZERO( &a->a_nvals[ k - 1 ] );
+ a->a_numvals--;
}
}
}
+
+ if ( a->a_vals == NULL ) {
+ assert( a->a_numvals == 0 );
+
+ attr_delete( &e->e_attrs, mi->mi_ad_restrictedOperation );
+ }
}
}
@@ -918,17 +932,21 @@ monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e_database )
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 );
+ if ( srchdesc ) {
+ 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 );
+ } else {
+ snprintf( buf, sizeof(buf),
+ "plugin %d name: ", i );
+ }
ber_str2bv( buf, 0, 0, &bv );
attr_merge_normalize_one( e_database,