/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2001-2006 The OpenLDAP Foundation.
+ * Copyright 2001-2009 The OpenLDAP Foundation.
* Portions Copyright 2001-2003 Pierangelo Masarati.
* All rights reserved.
*
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 <limits.h>
-#endif /* HAVE_LIMITS_H */
-#ifndef PATH_MAX
-#define PATH_MAX 4095
-#endif /* ! PATH_MAX */
-
static int
monitor_subsys_database_modify(
Operation *op,
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
}
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 );
"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 );
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 );
} 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();
return 0;
}
+int
+monitor_back_register_database(
+ BackendDB *be,
+ struct berval *ndn )
+{
+ monitor_info_t *mi;
+ Entry *e_database, **ep;
+ int i, rc;
+ monitor_entry_t *mp;
+ monitor_subsys_t *ms_backend,
+ *ms_database,
+ *ms_overlay;
+ struct berval bv;
+ char buf[ BACKMONITOR_BUFSIZE ];
+
+ assert( be_monitor != NULL );
+
+ if ( !monitor_subsys_is_opened() ) {
+ return monitor_back_register_database_limbo( be, ndn );
+ }
+
+ mi = ( monitor_info_t * )be_monitor->be_private;
+
+ ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME );
+ if ( ms_backend == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_back_register_database: "
+ "unable to get "
+ "\"" SLAPD_MONITOR_BACKEND_NAME "\" "
+ "subsystem\n",
+ 0, 0, 0 );
+ return -1;
+ }
+
+ ms_database = monitor_back_get_subsys( SLAPD_MONITOR_DATABASE_NAME );
+ if ( ms_database == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_back_register_database: "
+ "unable to get "
+ "\"" SLAPD_MONITOR_DATABASE_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_back_register_database: "
+ "unable to get "
+ "\"" SLAPD_MONITOR_OVERLAY_NAME "\" "
+ "subsystem\n",
+ 0, 0, 0 );
+ return -1;
+ }
+
+ if ( monitor_cache_get( mi, &ms_database->mss_ndn, &e_database ) ) {
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_database_init: "
+ "unable to get entry \"%s\"\n",
+ ms_database->mss_ndn.bv_val, 0, 0 );
+ return( -1 );
+ }
+
+ mp = ( monitor_entry_t * )e_database->e_private;
+ for ( i = -1, ep = &mp->mp_children; *ep; i++ ) {
+ Attribute *a;
+
+ a = attr_find( (*ep)->e_attrs, slap_schema.si_ad_namingContexts );
+ if ( a ) {
+ int j, 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;
+ }
+ }
+ }
+ }
+
+ mp = ( monitor_entry_t * )(*ep)->e_private;
+
+ assert( mp != NULL );
+ ep = &mp->mp_next;
+ }
+
+ bv.bv_val = buf;
+ bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Database %d", i );
+ if ( bv.bv_len >= sizeof( buf ) ) {
+ rc = -1;
+ goto done;
+ }
+
+ rc = monitor_subsys_database_init_one( mi, be,
+ ms_database, ms_backend, ms_overlay, &bv, e_database, &ep );
+ 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;
+}
+
int
monitor_subsys_database_init(
BackendDB *be,
BER_BVZERO( &a->a_vals[ k - 1 ] );
BER_BVZERO( &a->a_nvals[ k - 1 ] );
+ a->a_numvals--;
}
}
}
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 );
+ }
}
}
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: <no description available>", i );
+ }
ber_str2bv( buf, 0, 0, &bv );
attr_merge_normalize_one( e_database,