]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/database.c
address ITS#4332; might remove dynamicObject counting
[openldap] / servers / slapd / back-monitor / database.c
index 67285793ffe24cc3f9caffc4397c24f077b79d36..a5485577e6d2be974bd523034db1c403d0c0f1ed 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Copyright 2001-2006 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -30,7 +30,7 @@
 
 #if defined(LDAP_SLAPI)
 #include "slapi.h"
-static int monitor_back_add_plugin( Backend *be, Entry *e );
+static int monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e );
 #endif /* defined(LDAP_SLAPI) */
 
 #if defined(SLAPD_BDB)
@@ -45,6 +45,9 @@ static int monitor_back_add_plugin( Backend *be, Entry *e );
 #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
@@ -54,6 +57,12 @@ static int monitor_back_add_plugin( Backend *be, Entry *e );
 #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;
@@ -81,7 +90,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, NULL );
+       return attr_merge_one( e, mi->mi_ad_readOnly, tf, tf );
 }
 
 static int
@@ -92,7 +101,8 @@ init_restrictedOperation( monitor_info_t *mi, Entry *e, slap_mask_t restrictops
        for ( i = 0; restricted_ops[ i ].op.bv_val; i++ ) {
                if ( restrictops & restricted_ops[ i ].tag ) {
                        rc = attr_merge_one( e, mi->mi_ad_restrictedOperation,
-                                       &restricted_ops[ i ].op, NULL );
+                                       &restricted_ops[ i ].op,
+                                       &restricted_ops[ i ].op );
                        if ( rc ) {
                                return rc;
                        }
@@ -102,7 +112,8 @@ init_restrictedOperation( monitor_info_t *mi, Entry *e, slap_mask_t restrictops
        for ( i = 0; restricted_exops[ i ].op.bv_val; i++ ) {
                if ( restrictops & restricted_exops[ i ].tag ) {
                        rc = attr_merge_one( e, mi->mi_ad_restrictedOperation,
-                                       &restricted_exops[ i ].op, NULL );
+                                       &restricted_exops[ i ].op,
+                                       &restricted_exops[ i ].op );
                        if ( rc ) {
                                return rc;
                        }
@@ -127,6 +138,8 @@ monitor_subsys_database_init(
 
        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 );
@@ -166,14 +179,16 @@ monitor_subsys_database_init(
        mp->mp_children = NULL;
        ep = &mp->mp_children;
 
-       for ( i = 0; i < nBackendDB; i++ ) {
+       i = -1;
+       LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
                char            buf[ BACKMONITOR_BUFSIZE ];
                int             j;
                slap_overinfo   *oi = NULL;
-               BackendInfo     *bi;
+               BackendInfo     *bi, *bi2;
                Entry           *e;
+               struct berval bv;
 
-               be = &backendDB[ i ];
+               i++;
 
                bi = be->bd_info;
 
@@ -187,30 +202,12 @@ monitor_subsys_database_init(
                        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: "
@@ -218,14 +215,27 @@ 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,
                                        be->be_suffix, be->be_nsuffix );
 
                } else {
+                       if ( be->be_suffix == NULL ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                       "monitor_subsys_database_init: "
+                                       "missing suffix for database %d\n",
+                                       i, 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,
@@ -235,6 +245,11 @@ monitor_subsys_database_init(
                (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;
@@ -253,8 +268,7 @@ monitor_subsys_database_init(
                                        break;
                                }
                                
-                               bv.bv_val = on->on_bi.bi_type;
-                               bv.bv_len = strlen( bv.bv_val );
+                               ber_str2bv( on->on_bi.bi_type, 0, 0, &bv );
                                attr_merge_normalize_one( e, mi->mi_ad_monitorOverlay,
                                                &bv, NULL );
 
@@ -264,46 +278,31 @@ monitor_subsys_database_init(
                                                break;
                                        }
                                }
-                               assert( on2 );
+                               assert( on2 != NULL );
 
                                snprintf( buf, sizeof( buf ), 
                                        "cn=Overlay %d,%s", 
                                        j, ms_overlay->mss_dn.bv_val );
-                               bv.bv_val = buf;
-                               bv.bv_len = strlen( buf );
-                               attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
+                               ber_str2bv( buf, 0, 0, &bv );
+                               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 ] != '/' ) {
@@ -339,25 +338,65 @@ monitor_subsys_database_init(
                                        &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 ( j = 0; j < nBackendInfo; j++ ) {
-                       if ( backendInfo[ j ].bi_type == bi->bi_type ) {
+                                       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++;
+                       if ( bi2->bi_type == bi->bi_type ) {
                                struct berval           bv;
 
                                snprintf( buf, sizeof( buf ), 
@@ -365,7 +404,8 @@ monitor_subsys_database_init(
                                        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;
                        }
@@ -391,7 +431,7 @@ monitor_subsys_database_init(
                }
 
 #if defined(LDAP_SLAPI)
-               monitor_back_add_plugin( be, e );
+               monitor_back_add_plugin( mi, be, e );
 #endif /* defined(LDAP_SLAPI) */
 
                if ( oi != NULL ) {
@@ -410,36 +450,14 @@ monitor_subsys_database_init(
                                                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: "
@@ -448,6 +466,14 @@ 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 ) {
@@ -527,16 +553,15 @@ value_mask( BerVarray v, slap_mask_t cur, slap_mask_t *delta )
        return LDAP_SUCCESS;
 }
 
-int
+static int
 monitor_subsys_database_modify(
        Operation       *op,
-       Entry           *e
-)
+       SlapReply       *rs,
+       Entry           *e )
 {
        monitor_info_t  *mi = (monitor_info_t *)op->o_bd->be_private;
        int             rc = LDAP_OTHER;
        Attribute       *save_attrs, *a;
-       Modifications   *modlist = op->oq_modify.rs_modlist;
        Modifications   *ml;
        Backend         *be;
        int             ro_gotval = 1, i, n;
@@ -544,23 +569,33 @@ monitor_subsys_database_modify(
        struct berval   *tf;
        
        i = sscanf( e->e_nname.bv_val, "cn=database %d,", &n );
-       if ( i != 1 )
-               return LDAP_UNWILLING_TO_PERFORM;
+       if ( i != 1 ) {
+               return SLAP_CB_CONTINUE;
+       }
 
-       if ( n < 0 || n >= nBackendDB )
-               return LDAP_NO_SUCH_OBJECT;
+       if ( n < 0 || n >= nBackendDB ) {
+               rs->sr_text = "invalid database index";
+               return ( rs->sr_err = LDAP_NO_SUCH_OBJECT );
+       }
 
+       LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
+               if ( n == 0 ) {
+                       break;
+               }
+               n--;
+       }
        /* do not allow some changes on back-monitor (needs work)... */
-       be = &backendDB[ n ];
-       if ( SLAP_MONITOR( be ) )
-               return LDAP_UNWILLING_TO_PERFORM;
+       if ( SLAP_MONITOR( be ) ) {
+               rs->sr_text = "no modifications allowed to monitor database entry";
+               return ( rs->sr_err = LDAP_UNWILLING_TO_PERFORM );
+       }
                
        rp_cur = be->be_restrictops;
 
        save_attrs = e->e_attrs;
        e->e_attrs = attrs_dup( e->e_attrs );
 
-       for ( ml=modlist; ml; ml=ml->sml_next ) {
+       for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
                Modification *mod = &ml->sml_mod;
 
                if ( mod->sm_desc == mi->mi_ad_readOnly ) {
@@ -568,7 +603,8 @@ monitor_subsys_database_modify(
 
                        if ( mod->sm_values ) {
                                if ( !BER_BVISNULL( &mod->sm_values[ 1 ] ) ) {
-                                       rc = LDAP_CONSTRAINT_VIOLATION;
+                                       rs->sr_text = "attempting to modify multiple values of single-valued attribute";
+                                       rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
                                        goto done;
                                }
 
@@ -579,7 +615,8 @@ monitor_subsys_database_modify(
                                        val = 0;
 
                                } else {
-                                       rc = LDAP_INVALID_SYNTAX;
+                                       assert( 0 );
+                                       rc = rs->sr_err = LDAP_INVALID_SYNTAX;
                                        goto done;
                                }
                        }
@@ -587,18 +624,18 @@ monitor_subsys_database_modify(
                        switch ( mod->sm_op ) {
                        case LDAP_MOD_DELETE:
                                if ( ro_gotval < 1 ) {
-                                       rc = LDAP_CONSTRAINT_VIOLATION;
+                                       rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
                                        goto done;
                                }
                                ro_gotval--;
 
                                if ( val == 0 && ( rp_cur & SLAP_RESTRICT_OP_WRITES ) == SLAP_RESTRICT_OP_WRITES ) {
-                                       rc = LDAP_NO_SUCH_ATTRIBUTE;
+                                       rc = rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
                                        goto done;
                                }
                                
                                if ( val == 1 && ( rp_cur & SLAP_RESTRICT_OP_WRITES ) != SLAP_RESTRICT_OP_WRITES ) {
-                                       rc = LDAP_NO_SUCH_ATTRIBUTE;
+                                       rc = rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
                                        goto done;
                                }
                                
@@ -610,7 +647,7 @@ monitor_subsys_database_modify(
 
                        case LDAP_MOD_ADD:
                                if ( ro_gotval > 0 ) {
-                                       rc = LDAP_CONSTRAINT_VIOLATION;
+                                       rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
                                        goto done;
                                }
                                ro_gotval++;
@@ -628,7 +665,7 @@ monitor_subsys_database_modify(
                                break;
 
                        default:
-                               rc = LDAP_OTHER;
+                               rc = rs->sr_err = LDAP_OTHER;
                                goto done;
                        }
 
@@ -668,12 +705,12 @@ monitor_subsys_database_modify(
                                        rp_delete &= ~mask;
 
                                } else if ( rc == LDAP_OTHER ) {
-                                       rc = LDAP_TYPE_OR_VALUE_EXISTS;
+                                       rc = rs->sr_err = LDAP_TYPE_OR_VALUE_EXISTS;
                                }
                                break;
 
                        default:
-                               rc = LDAP_OTHER;
+                               rc = rs->sr_err = LDAP_OTHER;
                                break;
                        }
 
@@ -687,29 +724,29 @@ monitor_subsys_database_modify(
                        rc = attr_merge( e, mod->sm_desc, mod->sm_values,
                                mod->sm_nvalues );
                        if ( rc ) {
-                               rc = LDAP_OTHER;
+                               rc = rs->sr_err = LDAP_OTHER;
                                break;
                        }
 
                } else {
-                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       rc = rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                        break;
                }
        }
 
        /* sanity checks: */
        if ( ro_gotval < 1 ) {
-               rc = LDAP_CONSTRAINT_VIOLATION;
+               rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
                goto done;
        }
 
        if ( ( rp_cur & SLAP_RESTRICT_OP_EXTENDED ) && ( rp_cur & SLAP_RESTRICT_EXOP_MASK ) ) {
-               rc = LDAP_CONSTRAINT_VIOLATION;
+               rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
                goto done;
        }
 
        if ( rp_delete & rp_add ) {
-               rc = LDAP_OTHER;
+               rc = rs->sr_err = LDAP_OTHER;
                goto done;
        }
 
@@ -729,7 +766,7 @@ monitor_subsys_database_modify(
 
        if ( !bvmatch( &a->a_vals[ 0 ], tf ) ) {
                attr_delete( &e->e_attrs, mi->mi_ad_readOnly );
-               rc = attr_merge_one( e, mi->mi_ad_readOnly, tf, NULL );
+               rc = attr_merge_one( e, mi->mi_ad_readOnly, tf, tf );
        }
 
        if ( rc == LDAP_SUCCESS ) {
@@ -740,7 +777,7 @@ monitor_subsys_database_modify(
                        } else {
                                a = attr_find( e->e_attrs, mi->mi_ad_restrictedOperation );
                                if ( a == NULL ) {
-                                       rc = LDAP_OTHER;
+                                       rc = rs->sr_err = LDAP_OTHER;
                                        goto done;
                                }
 
@@ -800,14 +837,16 @@ monitor_subsys_database_modify(
                        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,
-                                                       &restricted_ops[ i ].op, NULL );
+                                                       &restricted_ops[ i ].op,
+                                                       &restricted_ops[ i ].op );
                                }
                        }
 
                        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,
-                                                       &restricted_exops[ i ].op, NULL );
+                                                       &restricted_exops[ i ].op,
+                                                       &restricted_exops[ i ].op );
                                }
                        }
                }
@@ -818,6 +857,7 @@ monitor_subsys_database_modify(
 done:;
        if ( rc == LDAP_SUCCESS ) {
                attrs_free( save_attrs );
+               rc = SLAP_CB_CONTINUE;
 
        } else {
                Attribute *tmp = e->e_attrs;
@@ -829,11 +869,10 @@ done:;
 
 #if defined(LDAP_SLAPI)
 static int
-monitor_back_add_plugin( Backend *be, Entry *e_database )
+monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e_database )
 {
        Slapi_PBlock    *pCurrentPB; 
        int             i, rc = LDAP_SUCCESS;
-       monitor_info_t  *mi = ( monitor_info_t * )be->be_private;
 
        if ( slapi_int_pblock_get_first( be, &pCurrentPB ) != LDAP_SUCCESS ) {
                /*
@@ -866,8 +905,7 @@ monitor_back_add_plugin( Backend *be, Entry *e_database )
                                srchdesc->spd_version,
                                srchdesc->spd_description );
 
-               bv.bv_val = buf;
-               bv.bv_len = strlen( buf );
+               ber_str2bv( buf, 0, 0, &bv );
                attr_merge_normalize_one( e_database,
                                mi->mi_ad_monitoredInfo, &bv, NULL );