1 /* database.c - deals with database subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2005 The OpenLDAP Foundation.
6 * Portions Copyright 2001-2003 Pierangelo Masarati.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
25 #include <ac/string.h>
26 #include <ac/unistd.h>
29 #include "back-monitor.h"
31 #if defined(LDAP_SLAPI)
33 static int monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e );
34 #endif /* defined(LDAP_SLAPI) */
36 #if defined(SLAPD_BDB)
37 #include "../back-bdb/back-bdb.h"
38 #endif /* defined(SLAPD_BDB) */
39 #if defined(SLAPD_HDB)
40 #include "../back-hdb/back-bdb.h"
41 #endif /* defined(SLAPD_HDB) */
42 #if defined(SLAPD_LDAP)
43 #include "../back-ldap/back-ldap.h"
44 #endif /* defined(SLAPD_LDAP) */
45 #if 0 && defined(SLAPD_LDBM)
46 #include "../back-ldbm/back-ldbm.h"
47 #endif /* defined(SLAPD_LDBM) */
48 #if defined(SLAPD_META)
49 #include "../back-meta/back-meta.h"
50 #endif /* defined(SLAPD_META) */
52 /* for PATH_MAX on some systems (e.g. Solaris) */
55 #endif /* HAVE_LIMITS_H */
58 #endif /* ! PATH_MAX */
61 monitor_subsys_database_modify(
66 static struct restricted_ops_t {
69 } restricted_ops[] = {
70 { BER_BVC( "add" ), SLAP_RESTRICT_OP_ADD },
71 { BER_BVC( "bind" ), SLAP_RESTRICT_OP_BIND },
72 { BER_BVC( "compare" ), SLAP_RESTRICT_OP_COMPARE },
73 { BER_BVC( "delete" ), SLAP_RESTRICT_OP_DELETE },
74 { BER_BVC( "extended" ), SLAP_RESTRICT_OP_EXTENDED },
75 { BER_BVC( "modify" ), SLAP_RESTRICT_OP_MODIFY },
76 { BER_BVC( "rename" ), SLAP_RESTRICT_OP_RENAME },
77 { BER_BVC( "search" ), SLAP_RESTRICT_OP_SEARCH },
79 }, restricted_exops[] = {
80 { BER_BVC( LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
81 { BER_BVC( LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
82 { BER_BVC( LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
83 { BER_BVC( LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
88 init_readOnly( monitor_info_t *mi, Entry *e, slap_mask_t restrictops )
90 struct berval *tf = ( ( restrictops & SLAP_RESTRICT_OP_MASK ) == SLAP_RESTRICT_OP_WRITES ) ?
91 (struct berval *)&slap_true_bv : (struct berval *)&slap_false_bv;
93 return attr_merge_one( e, mi->mi_ad_readOnly, tf, tf );
97 init_restrictedOperation( monitor_info_t *mi, Entry *e, slap_mask_t restrictops )
101 for ( i = 0; restricted_ops[ i ].op.bv_val; i++ ) {
102 if ( restrictops & restricted_ops[ i ].tag ) {
103 rc = attr_merge_one( e, mi->mi_ad_restrictedOperation,
104 &restricted_ops[ i ].op,
105 &restricted_ops[ i ].op );
112 for ( i = 0; restricted_exops[ i ].op.bv_val; i++ ) {
113 if ( restrictops & restricted_exops[ i ].tag ) {
114 rc = attr_merge_one( e, mi->mi_ad_restrictedOperation,
115 &restricted_exops[ i ].op,
116 &restricted_exops[ i ].op );
127 monitor_subsys_database_init(
133 Entry *e_database, **ep;
136 monitor_subsys_t *ms_backend,
139 assert( be != NULL );
141 ms->mss_modify = monitor_subsys_database_modify;
143 mi = ( monitor_info_t * )be->be_private;
145 ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME );
146 if ( ms_backend == NULL ) {
147 Debug( LDAP_DEBUG_ANY,
148 "monitor_subsys_database_init: "
150 "\"" SLAPD_MONITOR_BACKEND_NAME "\" "
156 ms_overlay = monitor_back_get_subsys( SLAPD_MONITOR_OVERLAY_NAME );
157 if ( ms_overlay == NULL ) {
158 Debug( LDAP_DEBUG_ANY,
159 "monitor_subsys_database_init: "
161 "\"" SLAPD_MONITOR_OVERLAY_NAME "\" "
167 if ( monitor_cache_get( mi, &ms->mss_ndn, &e_database ) ) {
168 Debug( LDAP_DEBUG_ANY,
169 "monitor_subsys_database_init: "
170 "unable to get entry \"%s\"\n",
171 ms->mss_ndn.bv_val, 0, 0 );
175 (void)init_readOnly( mi, e_database, frontendDB->be_restrictops );
176 (void)init_restrictedOperation( mi, e_database, frontendDB->be_restrictops );
178 mp = ( monitor_entry_t * )e_database->e_private;
179 mp->mp_children = NULL;
180 ep = &mp->mp_children;
183 LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
184 char buf[ BACKMONITOR_BUFSIZE ];
186 slap_overinfo *oi = NULL;
187 BackendInfo *bi, *bi2;
194 if ( overlay_is_over( be ) ) {
195 oi = (slap_overinfo *)be->bd_info->bi_private;
199 /* Subordinates are not exposed as their own naming context */
200 if ( SLAP_GLUE_SUBORDINATE( be ) ) {
204 snprintf( buf, sizeof( buf ),
205 "dn: cn=Database %d,%s\n"
207 "structuralObjectClass: %s\n"
212 "modifiersName: %s\n"
213 "createTimestamp: %s\n"
214 "modifyTimestamp: %s\n",
217 mi->mi_oc_monitoredObject->soc_cname.bv_val,
218 mi->mi_oc_monitoredObject->soc_cname.bv_val,
220 mi->mi_ad_monitoredInfo->ad_cname.bv_val,
222 mi->mi_ad_monitorIsShadow->ad_cname.bv_val,
223 SLAP_SHADOW( be ) ? slap_true_bv.bv_val : slap_false_bv.bv_val,
224 mi->mi_creatorsName.bv_val,
225 mi->mi_creatorsName.bv_val,
226 mi->mi_startTime.bv_val,
227 mi->mi_startTime.bv_val );
229 e = str2entry( buf );
231 Debug( LDAP_DEBUG_ANY,
232 "monitor_subsys_database_init: "
233 "unable to create entry \"cn=Database %d,%s\"\n",
234 i, ms->mss_dn.bv_val, 0 );
238 if ( SLAP_MONITOR( be ) ) {
239 attr_merge( e, slap_schema.si_ad_monitorContext,
240 be->be_suffix, be->be_nsuffix );
241 attr_merge( e_database, slap_schema.si_ad_monitorContext,
242 be->be_suffix, be->be_nsuffix );
245 if ( be->be_suffix == NULL ) {
246 Debug( LDAP_DEBUG_ANY,
247 "monitor_subsys_database_init: "
248 "missing suffix for database %d\n",
252 attr_merge( e, slap_schema.si_ad_namingContexts,
253 be->be_suffix, be->be_nsuffix );
254 attr_merge( e_database, slap_schema.si_ad_namingContexts,
255 be->be_suffix, be->be_nsuffix );
258 (void)init_readOnly( mi, e, be->be_restrictops );
259 (void)init_restrictedOperation( mi, e, be->be_restrictops );
261 if ( SLAP_SHADOW( be ) && be->be_update_refs ) {
262 attr_merge_normalize( e, mi->mi_ad_monitorUpdateRef,
263 be->be_update_refs, NULL );
267 slap_overinst *on = oi->oi_list,
270 for ( ; on; on = on->on_next ) {
274 for ( on2 = on1; on2 != on; on2 = on2->on_next ) {
275 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
284 ber_str2bv( on->on_bi.bi_type, 0, 0, &bv );
285 attr_merge_normalize_one( e, mi->mi_ad_monitorOverlay,
288 /* find the overlay number, j */
289 for ( on2 = overlay_next( NULL ), j = 0; on2; on2 = overlay_next( on2 ), j++ ) {
290 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
294 assert( on2 != NULL );
296 snprintf( buf, sizeof( buf ),
298 j, ms_overlay->mss_dn.bv_val );
299 ber_str2bv( buf, 0, 0, &bv );
300 attr_merge_normalize_one( e,
301 slap_schema.si_ad_seeAlso,
310 #if defined(SLAPD_BDB) || defined(SLAPD_HDB)
311 } else if ( strcmp( bi->bi_type, "bdb" ) == 0
312 || strcmp( bi->bi_type, "hdb" ) == 0 )
315 ber_len_t pathlen = 0, len = 0;
316 char path[ PATH_MAX ] = { '\0' };
317 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
318 char *fname = bdb->bi_dbenv_home;
320 len = strlen( fname );
321 if ( fname[ 0 ] != '/' ) {
322 /* get full path name */
323 getcwd( path, sizeof( path ) );
324 pathlen = strlen( path );
326 if ( fname[ 0 ] == '.' && fname[ 1 ] == '/' ) {
332 bv.bv_len = STRLENOF( "file://" ) + pathlen
333 + STRLENOF( "/" ) + len;
334 bv.bv_val = ch_malloc( bv.bv_len + STRLENOF( "/" ) + 1 );
335 AC_MEMCPY( bv.bv_val, "file://", STRLENOF( "file://" ) );
337 AC_MEMCPY( &bv.bv_val[ STRLENOF( "file://" ) ],
339 bv.bv_val[ STRLENOF( "file://" ) + pathlen ] = '/';
342 AC_MEMCPY( &bv.bv_val[ STRLENOF( "file://" ) + pathlen ],
344 if ( bv.bv_val[ bv.bv_len - 1 ] != '/' ) {
345 bv.bv_val[ bv.bv_len ] = '/';
348 bv.bv_val[ bv.bv_len ] = '\0';
350 attr_merge_normalize_one( e, slap_schema.si_ad_labeledURI,
353 ch_free( bv.bv_val );
355 #endif /* defined(SLAPD_BDB) || defined(SLAPD_HDB) */
356 #if defined(SLAPD_LDAP)
357 } else if ( strcmp( bi->bi_type, "ldap" ) == 0 ) {
358 ldapinfo_t *li = (ldapinfo_t *)be->be_private;
360 attr_merge_normalize( e, slap_schema.si_ad_labeledURI,
361 li->li_bvuri, NULL );
363 char **urls = ldap_str2charray( li->li_uri, " " );
365 if ( urls != NULL ) {
368 for ( u = 0; urls[ u ] != NULL; u++ ) {
371 ber_str2bv( urls[ u ], 0, 0, &bv );
373 attr_merge_normalize_one( e,
374 slap_schema.si_ad_labeledURI,
378 ldap_charray_free( urls );
382 #endif /* defined(SLAPD_LDAP) */
383 #if defined(SLAPD_META)
384 } else if ( strcmp( bi->bi_type, "meta" ) == 0 ) {
385 metainfo_t *mi = (metainfo_t *)be->be_private;
388 for ( t = 0; t < mi->mi_ntargets; t++ ) {
389 char **urls = ldap_str2charray( mi->mi_targets[ t ].mt_uri, " " );
391 if ( urls != NULL ) {
394 for ( u = 0; urls[ u ] != NULL; u++ ) {
397 ber_str2bv( urls[ u ], 0, 0, &bv );
399 attr_merge_normalize_one( e,
400 slap_schema.si_ad_labeledURI,
403 ldap_charray_free( urls );
406 #endif /* defined(SLAPD_META) */
410 LDAP_STAILQ_FOREACH( bi2, &backendInfo, bi_next ) {
412 if ( bi2->bi_type == bi->bi_type ) {
415 snprintf( buf, sizeof( buf ),
417 j, ms_backend->mss_dn.bv_val );
419 bv.bv_len = strlen( buf );
420 attr_merge_normalize_one( e,
421 slap_schema.si_ad_seeAlso,
426 /* we must find it! */
429 mp = monitor_entrypriv_create();
433 e->e_private = ( void * )mp;
435 mp->mp_flags = ms->mss_flags
438 if ( monitor_cache_add( mi, e ) ) {
439 Debug( LDAP_DEBUG_ANY,
440 "monitor_subsys_database_init: "
441 "unable to add entry \"cn=Database %d,%s\"\n",
442 i, ms->mss_dn.bv_val, 0 );
446 #if defined(LDAP_SLAPI)
447 monitor_back_add_plugin( mi, be, e );
448 #endif /* defined(LDAP_SLAPI) */
451 Entry **ep_overlay = &mp->mp_children;
452 monitor_entry_t *mp_overlay;
453 slap_overinst *on = oi->oi_list;
456 for ( o = 0; on; o++, on = on->on_next ) {
460 /* find the overlay number, j */
461 for ( on2 = overlay_next( NULL ), j = 0; on2; on2 = overlay_next( on2 ), j++ ) {
462 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
466 assert( on2 != NULL );
468 snprintf( buf, sizeof( buf ),
469 "dn: cn=Overlay %d,cn=Database %d,%s\n"
471 "structuralObjectClass: %s\n"
474 "seeAlso: cn=Overlay %d,%s\n"
476 "modifiersName: %s\n"
477 "createTimestamp: %s\n"
478 "modifyTimestamp: %s\n",
482 mi->mi_oc_monitoredObject->soc_cname.bv_val,
483 mi->mi_oc_monitoredObject->soc_cname.bv_val,
485 mi->mi_ad_monitoredInfo->ad_cname.bv_val,
488 ms_overlay->mss_dn.bv_val,
489 mi->mi_creatorsName.bv_val,
490 mi->mi_creatorsName.bv_val,
491 mi->mi_startTime.bv_val,
492 mi->mi_startTime.bv_val );
494 e_overlay = str2entry( buf );
495 if ( e_overlay == NULL ) {
496 Debug( LDAP_DEBUG_ANY,
497 "monitor_subsys_database_init: "
498 "unable to create entry "
499 "\"cn=Overlay %d,cn=Database %d,%s\"\n",
500 o, i, ms->mss_dn.bv_val );
504 mp_overlay = monitor_entrypriv_create();
505 if ( mp_overlay == NULL ) {
508 e_overlay->e_private = ( void * )mp_overlay;
509 mp_overlay->mp_info = ms;
510 mp_overlay->mp_flags = ms->mss_flags
513 if ( monitor_cache_add( mi, e_overlay ) ) {
514 Debug( LDAP_DEBUG_ANY,
515 "monitor_subsys_database_init: "
516 "unable to add entry "
517 "\"cn=Overlay %d,cn=Database %d,%s\"\n",
518 o, i, ms->mss_dn.bv_val );
522 *ep_overlay = e_overlay;
523 ep_overlay = &mp_overlay->mp_next;
531 monitor_cache_release( mi, e_database );
538 * cur: must not contain the tags corresponding to the values in v
539 * delta: will contain the tags corresponding to the values in v
542 value_mask( BerVarray v, slap_mask_t cur, slap_mask_t *delta )
544 for ( ; !BER_BVISNULL( v ); v++ ) {
545 struct restricted_ops_t *rops;
548 if ( OID_LEADCHAR( v->bv_val[ 0 ] ) ) {
549 rops = restricted_exops;
552 rops = restricted_ops;
555 for ( i = 0; !BER_BVISNULL( &rops[ i ].op ); i++ ) {
556 if ( ber_bvstrcasecmp( v, &rops[ i ].op ) != 0 ) {
560 if ( rops[ i ].tag & *delta ) {
564 if ( rops[ i ].tag & cur ) {
568 cur |= rops[ i ].tag;
569 *delta |= rops[ i ].tag;
574 if ( BER_BVISNULL( &rops[ i ].op ) ) {
575 return LDAP_INVALID_SYNTAX;
583 monitor_subsys_database_modify(
588 monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private;
590 Attribute *save_attrs, *a;
593 int ro_gotval = 1, i, n;
594 slap_mask_t rp_add = 0, rp_delete = 0, rp_cur;
597 i = sscanf( e->e_nname.bv_val, "cn=database %d,", &n );
599 return SLAP_CB_CONTINUE;
602 if ( n < 0 || n >= nBackendDB ) {
603 rs->sr_text = "invalid database index";
604 return ( rs->sr_err = LDAP_NO_SUCH_OBJECT );
607 LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
613 /* do not allow some changes on back-monitor (needs work)... */
614 if ( SLAP_MONITOR( be ) ) {
615 rs->sr_text = "no modifications allowed to monitor database entry";
616 return ( rs->sr_err = LDAP_UNWILLING_TO_PERFORM );
619 rp_cur = be->be_restrictops;
621 save_attrs = e->e_attrs;
622 e->e_attrs = attrs_dup( e->e_attrs );
624 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
625 Modification *mod = &ml->sml_mod;
627 if ( mod->sm_desc == mi->mi_ad_readOnly ) {
630 if ( mod->sm_values ) {
631 if ( !BER_BVISNULL( &mod->sm_values[ 1 ] ) ) {
632 rs->sr_text = "attempting to modify multiple values of single-valued attribute";
633 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
637 if ( bvmatch( &slap_true_bv, mod->sm_values )) {
640 } else if ( bvmatch( &slap_false_bv, mod->sm_values )) {
645 rc = rs->sr_err = LDAP_INVALID_SYNTAX;
650 switch ( mod->sm_op ) {
651 case LDAP_MOD_DELETE:
652 if ( ro_gotval < 1 ) {
653 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
658 if ( val == 0 && ( rp_cur & SLAP_RESTRICT_OP_WRITES ) == SLAP_RESTRICT_OP_WRITES ) {
659 rc = rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
663 if ( val == 1 && ( rp_cur & SLAP_RESTRICT_OP_WRITES ) != SLAP_RESTRICT_OP_WRITES ) {
664 rc = rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
670 case LDAP_MOD_REPLACE:
675 if ( ro_gotval > 0 ) {
676 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
682 rp_add |= (~rp_cur) & SLAP_RESTRICT_OP_WRITES;
683 rp_cur |= SLAP_RESTRICT_OP_WRITES;
684 rp_delete &= ~SLAP_RESTRICT_OP_WRITES;
686 } else if ( val == 0 ) {
687 rp_delete |= rp_cur & SLAP_RESTRICT_OP_WRITES;
688 rp_cur &= ~SLAP_RESTRICT_OP_WRITES;
689 rp_add &= ~SLAP_RESTRICT_OP_WRITES;
694 rc = rs->sr_err = LDAP_OTHER;
698 } else if ( mod->sm_desc == mi->mi_ad_restrictedOperation ) {
699 slap_mask_t mask = 0;
701 switch ( mod->sm_op ) {
702 case LDAP_MOD_DELETE:
703 if ( mod->sm_values == NULL ) {
709 rc = value_mask( mod->sm_values, ~rp_cur, &mask );
710 if ( rc == LDAP_SUCCESS ) {
715 } else if ( rc == LDAP_OTHER ) {
716 rc = LDAP_NO_SUCH_ATTRIBUTE;
720 case LDAP_MOD_REPLACE:
727 rc = value_mask( mod->sm_values, rp_cur, &mask );
728 if ( rc == LDAP_SUCCESS ) {
733 } else if ( rc == LDAP_OTHER ) {
734 rc = rs->sr_err = LDAP_TYPE_OR_VALUE_EXISTS;
739 rc = rs->sr_err = LDAP_OTHER;
743 if ( rc != LDAP_SUCCESS ) {
747 } else if ( is_at_operational( mod->sm_desc->ad_type )) {
748 /* accept all operational attributes */
749 attr_delete( &e->e_attrs, mod->sm_desc );
750 rc = attr_merge( e, mod->sm_desc, mod->sm_values,
753 rc = rs->sr_err = LDAP_OTHER;
758 rc = rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
764 if ( ro_gotval < 1 ) {
765 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
769 if ( ( rp_cur & SLAP_RESTRICT_OP_EXTENDED ) && ( rp_cur & SLAP_RESTRICT_EXOP_MASK ) ) {
770 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
774 if ( rp_delete & rp_add ) {
775 rc = rs->sr_err = LDAP_OTHER;
779 /* check current value of readOnly */
780 if ( ( rp_cur & SLAP_RESTRICT_OP_WRITES ) == SLAP_RESTRICT_OP_WRITES ) {
781 tf = (struct berval *)&slap_true_bv;
784 tf = (struct berval *)&slap_false_bv;
787 a = attr_find( e->e_attrs, mi->mi_ad_readOnly );
793 if ( !bvmatch( &a->a_vals[ 0 ], tf ) ) {
794 attr_delete( &e->e_attrs, mi->mi_ad_readOnly );
795 rc = attr_merge_one( e, mi->mi_ad_readOnly, tf, tf );
798 if ( rc == LDAP_SUCCESS ) {
800 if ( rp_delete == be->be_restrictops ) {
801 attr_delete( &e->e_attrs, mi->mi_ad_restrictedOperation );
804 a = attr_find( e->e_attrs, mi->mi_ad_restrictedOperation );
806 rc = rs->sr_err = LDAP_OTHER;
810 for ( i = 0; !BER_BVISNULL( &restricted_ops[ i ].op ); i++ ) {
811 if ( rp_delete & restricted_ops[ i ].tag ) {
814 for ( j = 0; !BER_BVISNULL( &a->a_nvals[ j ] ); j++ ) {
817 if ( !bvmatch( &a->a_nvals[ j ], &restricted_ops[ i ].op ) ) {
821 ch_free( a->a_vals[ j ].bv_val );
822 ch_free( a->a_nvals[ j ].bv_val );
824 for ( k = j + 1; !BER_BVISNULL( &a->a_nvals[ k ] ); k++ ) {
825 a->a_vals[ k - 1 ] = a->a_vals[ k ];
826 a->a_nvals[ k - 1 ] = a->a_nvals[ k ];
829 BER_BVZERO( &a->a_vals[ k - 1 ] );
830 BER_BVZERO( &a->a_nvals[ k - 1 ] );
835 for ( i = 0; !BER_BVISNULL( &restricted_exops[ i ].op ); i++ ) {
836 if ( rp_delete & restricted_exops[ i ].tag ) {
839 for ( j = 0; !BER_BVISNULL( &a->a_nvals[ j ] ); j++ ) {
842 if ( !bvmatch( &a->a_nvals[ j ], &restricted_exops[ i ].op ) ) {
846 ch_free( a->a_vals[ j ].bv_val );
847 ch_free( a->a_nvals[ j ].bv_val );
849 for ( k = j + 1; !BER_BVISNULL( &a->a_nvals[ k ] ); k++ ) {
850 a->a_vals[ k - 1 ] = a->a_vals[ k ];
851 a->a_nvals[ k - 1 ] = a->a_nvals[ k ];
854 BER_BVZERO( &a->a_vals[ k - 1 ] );
855 BER_BVZERO( &a->a_nvals[ k - 1 ] );
863 for ( i = 0; !BER_BVISNULL( &restricted_ops[ i ].op ); i++ ) {
864 if ( rp_add & restricted_ops[ i ].tag ) {
865 attr_merge_one( e, mi->mi_ad_restrictedOperation,
866 &restricted_ops[ i ].op,
867 &restricted_ops[ i ].op );
871 for ( i = 0; !BER_BVISNULL( &restricted_exops[ i ].op ); i++ ) {
872 if ( rp_add & restricted_exops[ i ].tag ) {
873 attr_merge_one( e, mi->mi_ad_restrictedOperation,
874 &restricted_exops[ i ].op,
875 &restricted_exops[ i ].op );
881 be->be_restrictops = rp_cur;
884 if ( rc == LDAP_SUCCESS ) {
885 attrs_free( save_attrs );
886 rc = SLAP_CB_CONTINUE;
889 Attribute *tmp = e->e_attrs;
890 e->e_attrs = save_attrs;
896 #if defined(LDAP_SLAPI)
898 monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e_database )
900 Slapi_PBlock *pCurrentPB;
901 int i, rc = LDAP_SUCCESS;
903 if ( slapi_int_pblock_get_first( be, &pCurrentPB ) != LDAP_SUCCESS ) {
905 * LDAP_OTHER is returned if no plugins are installed
913 Slapi_PluginDesc *srchdesc;
914 char buf[ BACKMONITOR_BUFSIZE ];
917 rc = slapi_pblock_get( pCurrentPB, SLAPI_PLUGIN_DESCRIPTION,
919 if ( rc != LDAP_SUCCESS ) {
923 snprintf( buf, sizeof(buf),
924 "plugin %d name: %s; "
930 srchdesc->spd_vendor,
931 srchdesc->spd_version,
932 srchdesc->spd_description );
934 ber_str2bv( buf, 0, 0, &bv );
935 attr_merge_normalize_one( e_database,
936 mi->mi_ad_monitoredInfo, &bv, NULL );
940 } while ( ( slapi_int_pblock_get_next( &pCurrentPB ) == LDAP_SUCCESS )
941 && ( pCurrentPB != NULL ) );
946 #endif /* defined(LDAP_SLAPI) */