1 /* backend.c - deals with backend subsystem */
3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
9 * This work has beed deveolped for the OpenLDAP Foundation
10 * in the hope that it may be useful to the Open Source community,
11 * but WITHOUT ANY WARRANTY.
13 * Permission is granted to anyone to use this software for any purpose
14 * on any computer system, and to alter it and redistribute it, subject
15 * to the following restrictions:
17 * 1. The author and SysNet s.n.c. are not responsible for the consequences
18 * of use of this software, no matter how awful, even if they arise from
21 * 2. The origin of this software must not be misrepresented, either by
22 * explicit claim or by omission. Since few users ever read sources,
23 * credits should appear in the documentation.
25 * 3. Altered versions must be plainly marked as such, and must not be
26 * misrepresented as being the original software. Since few users
27 * ever read sources, credits should appear in the documentation.
28 * SysNet s.n.c. cannot be responsible for the consequences of the
31 * 4. This notice may not be removed or altered.
40 #include "back-monitor.h"
43 * initializes backend subentries
46 monitor_subsys_backend_init(
50 struct monitorinfo *mi;
51 Entry *e, *e_backend, *e_tmp;
53 struct monitorentrypriv *mp;
55 mi = ( struct monitorinfo * )be->be_private;
57 if ( monitor_cache_get( mi,
58 &monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
61 LDAP_LOG( OPERATION, CRIT,
62 "monitor_subsys_backend_init: "
63 "unable to get entry '%s'\n",
64 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0, 0 );
66 Debug( LDAP_DEBUG_ANY,
67 "monitor_subsys_backend_init: "
68 "unable to get entry '%s'\n%s%s",
69 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
76 for ( i = nBackendInfo; i--; ) {
79 struct berval bv, nbv;
84 snprintf( buf, sizeof( buf ),
85 "dn: cn=Backend %d,%s\n"
86 SLAPD_MONITOR_OBJECTCLASSES
89 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val,
95 LDAP_LOG( OPERATION, CRIT,
96 "monitor_subsys_backend_init: "
97 "unable to create entry 'cn=Backend %d,%s'\n",
98 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
100 Debug( LDAP_DEBUG_ANY,
101 "monitor_subsys_backend_init: "
102 "unable to create entry 'cn=Backend %d,%s'\n%s",
104 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
110 bv.bv_val = bi->bi_type;
111 bv.bv_len = strlen( bv.bv_val );
114 if ( monitor_ad_normalize ) {
115 rc = monitor_ad_normalize(
117 monitor_ad_desc->ad_type->sat_syntax,
118 monitor_ad_desc->ad_type->sat_equality,
125 attr_merge_one( e, monitor_ad_desc, &bv,
126 nbv.bv_val ? &nbv : NULL );
127 attr_merge_one( e_backend, monitor_ad_desc, &bv,
128 nbv.bv_val ? &nbv : NULL );
129 ch_free( nbv.bv_val );
131 if ( bi->bi_controls ) {
134 for ( j = 0; bi->bi_controls[ j ]; j++ ) {
135 bv.bv_val = bi->bi_controls[ j ];
136 bv.bv_len = strlen( bv.bv_val );
137 attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL );
141 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
142 e->e_private = ( void * )mp;
144 mp->mp_children = NULL;
145 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
146 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
149 if ( monitor_cache_add( mi, e ) ) {
151 LDAP_LOG( OPERATION, CRIT,
152 "monitor_subsys_backend_init: "
153 "unable to add entry 'cn=Backend %d,%s'\n",
154 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
156 Debug( LDAP_DEBUG_ANY,
157 "monitor_subsys_backend_init: "
158 "unable to add entry 'cn=Backend %d,%s'\n%s",
160 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
169 mp = ( struct monitorentrypriv * )e_backend->e_private;
170 mp->mp_children = e_tmp;
172 monitor_cache_release( mi, e_backend );