/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2001-2005 The OpenLDAP Foundation.
+ * Copyright 2001-2006 The OpenLDAP Foundation.
* Portions Copyright 2001-2003 Pierangelo Masarati.
* All rights reserved.
*
#if 0 && defined(SLAPD_LDBM)
#include "../back-ldbm/back-ldbm.h"
#endif /* defined(SLAPD_LDBM) */
+#if defined(SLAPD_META)
+#include "../back-meta/back-meta.h"
+#endif /* defined(SLAPD_META) */
/* for PATH_MAX on some systems (e.g. Solaris) */
#ifdef HAVE_LIMITS_H
#define PATH_MAX 4095
#endif /* ! PATH_MAX */
+static int
+monitor_subsys_database_modify(
+ Operation *op,
+ SlapReply *rs,
+ Entry *e );
+
static struct restricted_ops_t {
struct berval op;
unsigned int tag;
assert( be != NULL );
+ ms->mss_modify = monitor_subsys_database_modify;
+
mi = ( monitor_info_t * )be->be_private;
ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME );
slap_overinfo *oi = NULL;
BackendInfo *bi, *bi2;
Entry *e;
+ struct berval bv;
i++;
continue;
}
- snprintf( buf, sizeof( buf ),
- "dn: cn=Database %d,%s\n"
- "objectClass: %s\n"
- "structuralObjectClass: %s\n"
- "cn: Database %d\n"
- "description: This object contains the type of the database.\n"
- "%s: %s\n"
- "creatorsName: %s\n"
- "modifiersName: %s\n"
- "createTimestamp: %s\n"
- "modifyTimestamp: %s\n",
- i,
- ms->mss_dn.bv_val,
- mi->mi_oc_monitoredObject->soc_cname.bv_val,
- mi->mi_oc_monitoredObject->soc_cname.bv_val,
- i,
- mi->mi_ad_monitoredInfo->ad_cname.bv_val,
- bi->bi_type,
- mi->mi_creatorsName.bv_val,
- mi->mi_creatorsName.bv_val,
- mi->mi_startTime.bv_val,
- mi->mi_startTime.bv_val );
-
- e = str2entry( buf );
+ bv.bv_len = snprintf( buf, sizeof( buf ),
+ "cn=Database %d", i );
+ bv.bv_val = buf;
+ e = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn, &bv,
+ mi->mi_oc_monitoredObject, mi, NULL, NULL );
+
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_database_init: "
i, ms->mss_dn.bv_val, 0 );
return( -1 );
}
-
- if ( SLAP_MONITOR(be) ) {
+
+ 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,
(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;
break;
}
}
- assert( on2 );
+ 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, mi->mi_ad_seeAlso,
+ attr_merge_normalize_one( e,
+ slap_schema.si_ad_seeAlso,
&bv, NULL );
}
}
+
+ if ( 0 ) {
+ assert( 0 );
+
#if defined(SLAPD_BDB) || defined(SLAPD_HDB)
- if ( strcmp( bi->bi_type, "bdb" ) == 0
+ } else if ( strcmp( bi->bi_type, "bdb" ) == 0
|| strcmp( bi->bi_type, "hdb" ) == 0 )
{
struct berval bv;
ber_len_t pathlen = 0, len = 0;
char path[ PATH_MAX ] = { '\0' };
- char *fname = NULL;
-
- if ( strcmp( bi->bi_type, "bdb" ) == 0
- || strcmp( bi->bi_type, "hdb" ) == 0 )
- {
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
-
- fname = bdb->bi_dbenv_home;
-#if 0
- } else if ( strcmp( bi->bi_type, "ldbm" ) == 0 ) {
- struct ldbminfo *ldbm = (struct ldbminfo *) be->be_private;
-
- /* FIXME: there's a conflict
- * between back-bdb.h and back.ldbm.h;
- * anyway, this code will be moved
- * to the backends as soon as the
- * issue with filtering on namingContexts
- * is fixed */
- fname = ldbm->li_directory;
-#endif
- }
+ struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+ char *fname = bdb->bi_dbenv_home;
len = strlen( fname );
if ( fname[ 0 ] != '/' ) {
&bv, NULL );
ch_free( bv.bv_val );
- }
-#endif /* defined(SLAPD_LDAP) || defined(SLAPD_HDB) */
+#endif /* defined(SLAPD_BDB) || defined(SLAPD_HDB) */
#if defined(SLAPD_LDAP)
- if ( strcmp( bi->bi_type, "ldap" ) == 0 ) {
- struct ldapinfo *li =
- (struct ldapinfo *)be->be_private;
- struct berval bv;
+ } else if ( strcmp( bi->bi_type, "ldap" ) == 0 ) {
+ ldapinfo_t *li = (ldapinfo_t *)be->be_private;
+#if 0
+ attr_merge_normalize( e, slap_schema.si_ad_labeledURI,
+ li->li_bvuri, NULL );
+#else
+ char **urls = ldap_str2charray( li->li_uri, " " );
- ber_str2bv( li->url, 0, 0, &bv );
+ if ( urls != NULL ) {
+ int u;
+
+ for ( u = 0; urls[ u ] != NULL; u++ ) {
+ struct berval bv;
+
+ ber_str2bv( urls[ u ], 0, 0, &bv );
+
+ attr_merge_normalize_one( e,
+ slap_schema.si_ad_labeledURI,
+ &bv, NULL );
+ }
+
+ ldap_charray_free( urls );
+ }
+#endif
- attr_merge_normalize_one( e,
- slap_schema.si_ad_labeledURI,
- &bv, NULL );
- }
#endif /* defined(SLAPD_LDAP) */
+#if defined(SLAPD_META)
+ } else if ( strcmp( bi->bi_type, "meta" ) == 0 ) {
+ metainfo_t *mi = (metainfo_t *)be->be_private;
+ int t;
+
+ for ( t = 0; t < mi->mi_ntargets; t++ ) {
+ char **urls = ldap_str2charray( mi->mi_targets[ t ].mt_uri, " " );
+
+ if ( urls != NULL ) {
+ int u;
+
+ for ( u = 0; urls[ u ] != NULL; u++ ) {
+ struct berval bv;
+
+ ber_str2bv( urls[ u ], 0, 0, &bv );
+
+ attr_merge_normalize_one( e,
+ slap_schema.si_ad_labeledURI,
+ &bv, NULL );
+ }
+ ldap_charray_free( urls );
+ }
+ }
+#endif /* defined(SLAPD_META) */
+ }
j = -1;
LDAP_STAILQ_FOREACH( bi2, &backendInfo, bi_next ) {
j, ms_backend->mss_dn.bv_val );
bv.bv_val = buf;
bv.bv_len = strlen( buf );
- attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
+ attr_merge_normalize_one( e,
+ slap_schema.si_ad_seeAlso,
&bv, NULL );
break;
}
break;
}
}
- assert( on2 );
-
- snprintf( buf, sizeof( buf ),
- "dn: cn=Overlay %d,cn=Database %d,%s\n"
- "objectClass: %s\n"
- "structuralObjectClass: %s\n"
- "cn: Overlay %d\n"
- "description: This object contains the type of the overlay.\n"
- "%s: %s\n"
- "seeAlso: cn=Overlay %d,%s\n"
- "creatorsName: %s\n"
- "modifiersName: %s\n"
- "createTimestamp: %s\n"
- "modifyTimestamp: %s\n",
- o,
- i,
- ms->mss_dn.bv_val,
- mi->mi_oc_monitoredObject->soc_cname.bv_val,
- mi->mi_oc_monitoredObject->soc_cname.bv_val,
- o,
- mi->mi_ad_monitoredInfo->ad_cname.bv_val,
- on->on_bi.bi_type,
- j,
- ms_overlay->mss_dn.bv_val,
- mi->mi_creatorsName.bv_val,
- mi->mi_creatorsName.bv_val,
- mi->mi_startTime.bv_val,
- mi->mi_startTime.bv_val );
-
- e_overlay = str2entry( buf );
+ 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: "
o, i, ms->mss_dn.bv_val );
return( -1 );
}
+ ber_str2bv( on->on_bi.bi_type, 0, 0, &bv );
+ attr_merge_one( e, 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, slap_schema.si_ad_seeAlso,
+ &bv, NULL );
mp_overlay = monitor_entrypriv_create();
if ( mp_overlay == NULL ) {
return LDAP_SUCCESS;
}
-int
+static int
monitor_subsys_database_modify(
Operation *op,
SlapReply *rs,
- Entry *e
-)
+ Entry *e )
{
monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private;
int rc = LDAP_OTHER;