1 /* database.c - deals with database subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2009 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) */
37 monitor_subsys_database_modify(
42 static struct restricted_ops_t {
45 } restricted_ops[] = {
46 { BER_BVC( "add" ), SLAP_RESTRICT_OP_ADD },
47 { BER_BVC( "bind" ), SLAP_RESTRICT_OP_BIND },
48 { BER_BVC( "compare" ), SLAP_RESTRICT_OP_COMPARE },
49 { BER_BVC( "delete" ), SLAP_RESTRICT_OP_DELETE },
50 { BER_BVC( "extended" ), SLAP_RESTRICT_OP_EXTENDED },
51 { BER_BVC( "modify" ), SLAP_RESTRICT_OP_MODIFY },
52 { BER_BVC( "rename" ), SLAP_RESTRICT_OP_RENAME },
53 { BER_BVC( "search" ), SLAP_RESTRICT_OP_SEARCH },
55 }, restricted_exops[] = {
56 { BER_BVC( LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
57 { BER_BVC( LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
58 { BER_BVC( LDAP_EXOP_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
59 { BER_BVC( LDAP_EXOP_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
64 init_readOnly( monitor_info_t *mi, Entry *e, slap_mask_t restrictops )
66 struct berval *tf = ( ( restrictops & SLAP_RESTRICT_OP_MASK ) == SLAP_RESTRICT_OP_WRITES ) ?
67 (struct berval *)&slap_true_bv : (struct berval *)&slap_false_bv;
69 return attr_merge_one( e, mi->mi_ad_readOnly, tf, NULL );
73 init_restrictedOperation( monitor_info_t *mi, Entry *e, slap_mask_t restrictops )
77 for ( i = 0; restricted_ops[ i ].op.bv_val; i++ ) {
78 if ( restrictops & restricted_ops[ i ].tag ) {
79 rc = attr_merge_one( e, mi->mi_ad_restrictedOperation,
80 &restricted_ops[ i ].op,
81 &restricted_ops[ i ].op );
88 for ( i = 0; restricted_exops[ i ].op.bv_val; i++ ) {
89 if ( restrictops & restricted_exops[ i ].tag ) {
90 rc = attr_merge_one( e, mi->mi_ad_restrictedOperation,
91 &restricted_exops[ i ].op,
92 &restricted_exops[ i ].op );
103 monitor_subsys_database_init_one(
106 monitor_subsys_t *ms,
107 monitor_subsys_t *ms_backend,
108 monitor_subsys_t *ms_overlay,
113 char buf[ BACKMONITOR_BUFSIZE ];
115 slap_overinfo *oi = NULL;
116 BackendInfo *bi, *bi2;
119 char *rdnval = strchr( rdn->bv_val, '=' ) + 1;
124 if ( overlay_is_over( be ) ) {
125 oi = (slap_overinfo *)be->bd_info->bi_private;
129 e = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn, rdn,
130 mi->mi_oc_monitoredObject, mi, NULL, NULL );
133 Debug( LDAP_DEBUG_ANY,
134 "monitor_subsys_database_init: "
135 "unable to create entry \"%s,%s\"\n",
136 rdn->bv_val, ms->mss_dn.bv_val, 0 );
140 ber_str2bv( bi->bi_type, 0, 0, &bv );
141 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL );
142 attr_merge_one( e, mi->mi_ad_monitorIsShadow,
143 SLAP_SHADOW( be ) ? (struct berval *)&slap_true_bv :
144 (struct berval *)&slap_false_bv, NULL );
146 if ( SLAP_MONITOR( be ) ) {
147 attr_merge( e, slap_schema.si_ad_monitorContext,
148 be->be_suffix, be->be_nsuffix );
149 attr_merge( e_database, slap_schema.si_ad_monitorContext,
150 be->be_suffix, be->be_nsuffix );
153 if ( be->be_suffix == NULL ) {
154 Debug( LDAP_DEBUG_ANY,
155 "monitor_subsys_database_init: "
156 "missing suffix for %s\n",
159 attr_merge( e, slap_schema.si_ad_namingContexts,
160 be->be_suffix, NULL );
161 attr_merge( e_database, slap_schema.si_ad_namingContexts,
162 be->be_suffix, NULL );
165 if ( SLAP_GLUE_SUBORDINATE( be ) ) {
166 BackendDB *sup_be = select_backend( &be->be_nsuffix[ 0 ], 1 );
167 if ( sup_be == NULL ) {
168 Debug( LDAP_DEBUG_ANY,
169 "monitor_subsys_database_init: "
170 "unable to get superior for %s\n",
171 be->be_suffix[ 0 ].bv_val, 0, 0 );
174 attr_merge( e, mi->mi_ad_monitorSuperiorDN,
175 sup_be->be_suffix, sup_be->be_nsuffix );
180 (void)init_readOnly( mi, e, be->be_restrictops );
181 (void)init_restrictedOperation( mi, e, be->be_restrictops );
183 if ( SLAP_SHADOW( be ) && be->be_update_refs ) {
184 attr_merge_normalize( e, mi->mi_ad_monitorUpdateRef,
185 be->be_update_refs, NULL );
189 slap_overinst *on = oi->oi_list,
192 for ( ; on; on = on->on_next ) {
195 for ( on2 = on1; on2 != on; on2 = on2->on_next ) {
196 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
205 ber_str2bv( on->on_bi.bi_type, 0, 0, &bv );
206 attr_merge_normalize_one( e, mi->mi_ad_monitorOverlay,
209 /* find the overlay number, j */
210 for ( on2 = overlay_next( NULL ), j = 0; on2; on2 = overlay_next( on2 ), j++ ) {
211 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
215 assert( on2 != NULL );
217 snprintf( buf, sizeof( buf ),
219 j, ms_overlay->mss_dn.bv_val );
220 ber_str2bv( buf, 0, 0, &bv );
221 attr_merge_normalize_one( e,
222 slap_schema.si_ad_seeAlso,
228 LDAP_STAILQ_FOREACH( bi2, &backendInfo, bi_next ) {
230 if ( bi2->bi_type == bi->bi_type ) {
231 snprintf( buf, sizeof( buf ),
233 j, ms_backend->mss_dn.bv_val );
235 bv.bv_len = strlen( buf );
236 attr_merge_normalize_one( e,
237 slap_schema.si_ad_seeAlso,
242 /* we must find it! */
245 mp = monitor_entrypriv_create();
249 e->e_private = ( void * )mp;
251 mp->mp_flags = ms->mss_flags
254 if ( monitor_cache_add( mi, e ) ) {
255 Debug( LDAP_DEBUG_ANY,
256 "monitor_subsys_database_init: "
257 "unable to add entry \"%s,%s\"\n",
258 rdn->bv_val, ms->mss_dn.bv_val, 0 );
262 #if defined(LDAP_SLAPI)
263 monitor_back_add_plugin( mi, be, e );
264 #endif /* defined(LDAP_SLAPI) */
267 Entry **ep_overlay = &mp->mp_children;
268 monitor_entry_t *mp_overlay;
269 slap_overinst *on = oi->oi_list;
272 for ( o = 0; on; o++, on = on->on_next ) {
276 /* find the overlay number, j */
277 for ( on2 = overlay_next( NULL ), j = 0; on2; on2 = overlay_next( on2 ), j++ ) {
278 if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
282 assert( on2 != NULL );
284 bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Overlay %d", o );
287 e_overlay = monitor_entry_stub( &e->e_name, &e->e_nname, &bv,
288 mi->mi_oc_monitoredObject, mi, NULL, NULL );
290 if ( e_overlay == NULL ) {
291 Debug( LDAP_DEBUG_ANY,
292 "monitor_subsys_database_init: "
293 "unable to create entry "
294 "\"cn=Overlay %d,%s,%s\"\n",
295 o, rdn->bv_val, ms->mss_dn.bv_val );
298 ber_str2bv( on->on_bi.bi_type, 0, 0, &bv );
299 attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo, &bv, NULL );
301 bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Overlay %d,%s",
302 j, ms_overlay->mss_dn.bv_val );
304 attr_merge_normalize_one( e_overlay, slap_schema.si_ad_seeAlso,
307 if ( SLAP_MONITOR( be ) ) {
308 attr_merge( e_overlay, slap_schema.si_ad_monitorContext,
309 be->be_suffix, be->be_nsuffix );
312 attr_merge( e_overlay, slap_schema.si_ad_namingContexts,
313 be->be_suffix, NULL );
316 mp_overlay = monitor_entrypriv_create();
317 if ( mp_overlay == NULL ) {
320 e_overlay->e_private = ( void * )mp_overlay;
321 mp_overlay->mp_info = ms;
322 mp_overlay->mp_flags = ms->mss_flags
325 if ( monitor_cache_add( mi, e_overlay ) ) {
326 Debug( LDAP_DEBUG_ANY,
327 "monitor_subsys_database_init: "
328 "unable to add entry "
329 "\"cn=Overlay %d,%s,%s\"\n",
330 o, rdn->bv_val, ms->mss_dn.bv_val );
334 *ep_overlay = e_overlay;
335 ep_overlay = &mp_overlay->mp_next;
346 monitor_back_register_database(
351 Entry *e_database, **ep;
354 monitor_subsys_t *ms_backend,
358 char buf[ BACKMONITOR_BUFSIZE ];
360 assert( be_monitor != NULL );
362 if ( !monitor_subsys_is_opened() ) {
363 return monitor_back_register_database_limbo( be, ndn );
366 mi = ( monitor_info_t * )be_monitor->be_private;
368 ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME );
369 if ( ms_backend == NULL ) {
370 Debug( LDAP_DEBUG_ANY,
371 "monitor_back_register_database: "
373 "\"" SLAPD_MONITOR_BACKEND_NAME "\" "
379 ms_database = monitor_back_get_subsys( SLAPD_MONITOR_DATABASE_NAME );
380 if ( ms_database == NULL ) {
381 Debug( LDAP_DEBUG_ANY,
382 "monitor_back_register_database: "
384 "\"" SLAPD_MONITOR_DATABASE_NAME "\" "
390 ms_overlay = monitor_back_get_subsys( SLAPD_MONITOR_OVERLAY_NAME );
391 if ( ms_overlay == NULL ) {
392 Debug( LDAP_DEBUG_ANY,
393 "monitor_back_register_database: "
395 "\"" SLAPD_MONITOR_OVERLAY_NAME "\" "
401 if ( monitor_cache_get( mi, &ms_database->mss_ndn, &e_database ) ) {
402 Debug( LDAP_DEBUG_ANY,
403 "monitor_subsys_database_init: "
404 "unable to get entry \"%s\"\n",
405 ms_database->mss_ndn.bv_val, 0, 0 );
409 mp = ( monitor_entry_t * )e_database->e_private;
410 for ( i = -1, ep = &mp->mp_children; *ep; i++ ) {
413 a = attr_find( (*ep)->e_attrs, slap_schema.si_ad_namingContexts );
417 /* FIXME: RFC 4512 defines namingContexts without an
418 * equality matching rule, making comparisons
419 * like this one tricky. We use a_vals and
420 * be_suffix instead for now.
422 for ( j = 0; !BER_BVISNULL( &a->a_vals[ j ] ); j++ ) {
423 for ( k = 0; !BER_BVISNULL( &be->be_suffix[ k ] ); k++ ) {
424 if ( dn_match( &a->a_vals[ j ],
425 &be->be_suffix[ k ] ) ) {
433 mp = ( monitor_entry_t * )(*ep)->e_private;
435 assert( mp != NULL );
440 bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Database %d", i );
441 if ( bv.bv_len >= sizeof( buf ) ) {
446 rc = monitor_subsys_database_init_one( mi, be,
447 ms_database, ms_backend, ms_overlay, &bv, e_database, &ep );
451 /* database_init_one advanced ep past where we want.
452 * But it stored the entry we want in mp->mp_next.
457 monitor_cache_release( mi, e_database );
458 if ( rc == 0 && ndn && ep && *ep ) {
459 *ndn = (*ep)->e_nname;
466 monitor_subsys_database_init(
468 monitor_subsys_t *ms )
471 Entry *e_database, **ep;
474 monitor_subsys_t *ms_backend,
478 assert( be != NULL );
480 ms->mss_modify = monitor_subsys_database_modify;
482 mi = ( monitor_info_t * )be->be_private;
484 ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME );
485 if ( ms_backend == NULL ) {
486 Debug( LDAP_DEBUG_ANY,
487 "monitor_subsys_database_init: "
489 "\"" SLAPD_MONITOR_BACKEND_NAME "\" "
495 ms_overlay = monitor_back_get_subsys( SLAPD_MONITOR_OVERLAY_NAME );
496 if ( ms_overlay == NULL ) {
497 Debug( LDAP_DEBUG_ANY,
498 "monitor_subsys_database_init: "
500 "\"" SLAPD_MONITOR_OVERLAY_NAME "\" "
506 if ( monitor_cache_get( mi, &ms->mss_ndn, &e_database ) ) {
507 Debug( LDAP_DEBUG_ANY,
508 "monitor_subsys_database_init: "
509 "unable to get entry \"%s\"\n",
510 ms->mss_ndn.bv_val, 0, 0 );
514 (void)init_readOnly( mi, e_database, frontendDB->be_restrictops );
515 (void)init_restrictedOperation( mi, e_database, frontendDB->be_restrictops );
517 mp = ( monitor_entry_t * )e_database->e_private;
518 mp->mp_children = NULL;
519 ep = &mp->mp_children;
521 BER_BVSTR( &bv, "cn=Frontend" );
522 rc = monitor_subsys_database_init_one( mi, frontendDB,
523 ms, ms_backend, ms_overlay, &bv, e_database, &ep );
529 LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
530 char buf[ BACKMONITOR_BUFSIZE ];
533 bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Database %d", ++i );
534 if ( bv.bv_len >= sizeof( buf ) ) {
538 rc = monitor_subsys_database_init_one( mi, be,
539 ms, ms_backend, ms_overlay, &bv, e_database, &ep );
545 monitor_cache_release( mi, e_database );
552 * cur: must not contain the tags corresponding to the values in v
553 * delta: will contain the tags corresponding to the values in v
556 value_mask( BerVarray v, slap_mask_t cur, slap_mask_t *delta )
558 for ( ; !BER_BVISNULL( v ); v++ ) {
559 struct restricted_ops_t *rops;
562 if ( OID_LEADCHAR( v->bv_val[ 0 ] ) ) {
563 rops = restricted_exops;
566 rops = restricted_ops;
569 for ( i = 0; !BER_BVISNULL( &rops[ i ].op ); i++ ) {
570 if ( ber_bvstrcasecmp( v, &rops[ i ].op ) != 0 ) {
574 if ( rops[ i ].tag & *delta ) {
578 if ( rops[ i ].tag & cur ) {
582 cur |= rops[ i ].tag;
583 *delta |= rops[ i ].tag;
588 if ( BER_BVISNULL( &rops[ i ].op ) ) {
589 return LDAP_INVALID_SYNTAX;
597 monitor_subsys_database_modify(
602 monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private;
604 Attribute *save_attrs, *a;
607 int ro_gotval = 1, i, n;
608 slap_mask_t rp_add = 0, rp_delete = 0, rp_cur;
611 i = sscanf( e->e_nname.bv_val, "cn=database %d,", &n );
613 return SLAP_CB_CONTINUE;
616 if ( n < 0 || n >= nBackendDB ) {
617 rs->sr_text = "invalid database index";
618 return ( rs->sr_err = LDAP_NO_SUCH_OBJECT );
621 LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
627 /* do not allow some changes on back-monitor (needs work)... */
628 if ( SLAP_MONITOR( be ) ) {
629 rs->sr_text = "no modifications allowed to monitor database entry";
630 return ( rs->sr_err = LDAP_UNWILLING_TO_PERFORM );
633 rp_cur = be->be_restrictops;
635 save_attrs = e->e_attrs;
636 e->e_attrs = attrs_dup( e->e_attrs );
638 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
639 Modification *mod = &ml->sml_mod;
641 if ( mod->sm_desc == mi->mi_ad_readOnly ) {
644 if ( mod->sm_values ) {
645 if ( !BER_BVISNULL( &mod->sm_values[ 1 ] ) ) {
646 rs->sr_text = "attempting to modify multiple values of single-valued attribute";
647 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
651 if ( bvmatch( &slap_true_bv, mod->sm_values )) {
654 } else if ( bvmatch( &slap_false_bv, mod->sm_values )) {
659 rc = rs->sr_err = LDAP_INVALID_SYNTAX;
664 switch ( mod->sm_op ) {
665 case LDAP_MOD_DELETE:
666 if ( ro_gotval < 1 ) {
667 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
672 if ( val == 0 && ( rp_cur & SLAP_RESTRICT_OP_WRITES ) == SLAP_RESTRICT_OP_WRITES ) {
673 rc = rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
677 if ( val == 1 && ( rp_cur & SLAP_RESTRICT_OP_WRITES ) != SLAP_RESTRICT_OP_WRITES ) {
678 rc = rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
684 case LDAP_MOD_REPLACE:
689 if ( ro_gotval > 0 ) {
690 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
696 rp_add |= (~rp_cur) & SLAP_RESTRICT_OP_WRITES;
697 rp_cur |= SLAP_RESTRICT_OP_WRITES;
698 rp_delete &= ~SLAP_RESTRICT_OP_WRITES;
700 } else if ( val == 0 ) {
701 rp_delete |= rp_cur & SLAP_RESTRICT_OP_WRITES;
702 rp_cur &= ~SLAP_RESTRICT_OP_WRITES;
703 rp_add &= ~SLAP_RESTRICT_OP_WRITES;
708 rc = rs->sr_err = LDAP_OTHER;
712 } else if ( mod->sm_desc == mi->mi_ad_restrictedOperation ) {
713 slap_mask_t mask = 0;
715 switch ( mod->sm_op ) {
716 case LDAP_MOD_DELETE:
717 if ( mod->sm_values == NULL ) {
723 rc = value_mask( mod->sm_values, ~rp_cur, &mask );
724 if ( rc == LDAP_SUCCESS ) {
729 } else if ( rc == LDAP_OTHER ) {
730 rc = LDAP_NO_SUCH_ATTRIBUTE;
734 case LDAP_MOD_REPLACE:
741 rc = value_mask( mod->sm_values, rp_cur, &mask );
742 if ( rc == LDAP_SUCCESS ) {
747 } else if ( rc == LDAP_OTHER ) {
748 rc = rs->sr_err = LDAP_TYPE_OR_VALUE_EXISTS;
753 rc = rs->sr_err = LDAP_OTHER;
757 if ( rc != LDAP_SUCCESS ) {
761 } else if ( is_at_operational( mod->sm_desc->ad_type )) {
762 /* accept all operational attributes */
763 attr_delete( &e->e_attrs, mod->sm_desc );
764 rc = attr_merge( e, mod->sm_desc, mod->sm_values,
767 rc = rs->sr_err = LDAP_OTHER;
772 rc = rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
778 if ( ro_gotval < 1 ) {
779 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
783 if ( ( rp_cur & SLAP_RESTRICT_OP_EXTENDED ) && ( rp_cur & SLAP_RESTRICT_EXOP_MASK ) ) {
784 rc = rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
788 if ( rp_delete & rp_add ) {
789 rc = rs->sr_err = LDAP_OTHER;
793 /* check current value of readOnly */
794 if ( ( rp_cur & SLAP_RESTRICT_OP_WRITES ) == SLAP_RESTRICT_OP_WRITES ) {
795 tf = (struct berval *)&slap_true_bv;
798 tf = (struct berval *)&slap_false_bv;
801 a = attr_find( e->e_attrs, mi->mi_ad_readOnly );
807 if ( !bvmatch( &a->a_vals[ 0 ], tf ) ) {
808 attr_delete( &e->e_attrs, mi->mi_ad_readOnly );
809 rc = attr_merge_one( e, mi->mi_ad_readOnly, tf, tf );
812 if ( rc == LDAP_SUCCESS ) {
814 if ( rp_delete == be->be_restrictops ) {
815 attr_delete( &e->e_attrs, mi->mi_ad_restrictedOperation );
818 a = attr_find( e->e_attrs, mi->mi_ad_restrictedOperation );
820 rc = rs->sr_err = LDAP_OTHER;
824 for ( i = 0; !BER_BVISNULL( &restricted_ops[ i ].op ); i++ ) {
825 if ( rp_delete & restricted_ops[ i ].tag ) {
828 for ( j = 0; !BER_BVISNULL( &a->a_nvals[ j ] ); j++ ) {
831 if ( !bvmatch( &a->a_nvals[ j ], &restricted_ops[ i ].op ) ) {
835 ch_free( a->a_vals[ j ].bv_val );
836 ch_free( a->a_nvals[ j ].bv_val );
838 for ( k = j + 1; !BER_BVISNULL( &a->a_nvals[ k ] ); k++ ) {
839 a->a_vals[ k - 1 ] = a->a_vals[ k ];
840 a->a_nvals[ k - 1 ] = a->a_nvals[ k ];
843 BER_BVZERO( &a->a_vals[ k - 1 ] );
844 BER_BVZERO( &a->a_nvals[ k - 1 ] );
850 for ( i = 0; !BER_BVISNULL( &restricted_exops[ i ].op ); i++ ) {
851 if ( rp_delete & restricted_exops[ i ].tag ) {
854 for ( j = 0; !BER_BVISNULL( &a->a_nvals[ j ] ); j++ ) {
857 if ( !bvmatch( &a->a_nvals[ j ], &restricted_exops[ i ].op ) ) {
861 ch_free( a->a_vals[ j ].bv_val );
862 ch_free( a->a_nvals[ j ].bv_val );
864 for ( k = j + 1; !BER_BVISNULL( &a->a_nvals[ k ] ); k++ ) {
865 a->a_vals[ k - 1 ] = a->a_vals[ k ];
866 a->a_nvals[ k - 1 ] = a->a_nvals[ k ];
869 BER_BVZERO( &a->a_vals[ k - 1 ] );
870 BER_BVZERO( &a->a_nvals[ k - 1 ] );
876 if ( a->a_vals == NULL ) {
877 assert( a->a_numvals == 0 );
879 attr_delete( &e->e_attrs, mi->mi_ad_restrictedOperation );
885 for ( i = 0; !BER_BVISNULL( &restricted_ops[ i ].op ); i++ ) {
886 if ( rp_add & restricted_ops[ i ].tag ) {
887 attr_merge_one( e, mi->mi_ad_restrictedOperation,
888 &restricted_ops[ i ].op,
889 &restricted_ops[ i ].op );
893 for ( i = 0; !BER_BVISNULL( &restricted_exops[ i ].op ); i++ ) {
894 if ( rp_add & restricted_exops[ i ].tag ) {
895 attr_merge_one( e, mi->mi_ad_restrictedOperation,
896 &restricted_exops[ i ].op,
897 &restricted_exops[ i ].op );
903 be->be_restrictops = rp_cur;
906 if ( rc == LDAP_SUCCESS ) {
907 attrs_free( save_attrs );
908 rc = SLAP_CB_CONTINUE;
911 Attribute *tmp = e->e_attrs;
912 e->e_attrs = save_attrs;
918 #if defined(LDAP_SLAPI)
920 monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e_database )
922 Slapi_PBlock *pCurrentPB;
923 int i, rc = LDAP_SUCCESS;
925 if ( slapi_int_pblock_get_first( be, &pCurrentPB ) != LDAP_SUCCESS ) {
927 * LDAP_OTHER is returned if no plugins are installed
935 Slapi_PluginDesc *srchdesc;
936 char buf[ BACKMONITOR_BUFSIZE ];
939 rc = slapi_pblock_get( pCurrentPB, SLAPI_PLUGIN_DESCRIPTION,
941 if ( rc != LDAP_SUCCESS ) {
945 snprintf( buf, sizeof(buf),
946 "plugin %d name: %s; "
952 srchdesc->spd_vendor,
953 srchdesc->spd_version,
954 srchdesc->spd_description );
956 snprintf( buf, sizeof(buf),
957 "plugin %d name: <no description available>", i );
960 ber_str2bv( buf, 0, 0, &bv );
961 attr_merge_normalize_one( e_database,
962 mi->mi_ad_monitoredInfo, &bv, NULL );
966 } while ( ( slapi_int_pblock_get_next( &pCurrentPB ) == LDAP_SUCCESS )
967 && ( pCurrentPB != NULL ) );
972 #endif /* defined(LDAP_SLAPI) */