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.
38 #include <ac/string.h>
41 #include "back-monitor.h"
44 * initializes backend subentries
47 monitor_subsys_backend_init(
51 struct monitorinfo *mi;
52 Entry *e, *e_backend, *e_tmp;
54 struct monitorentrypriv *mp;
56 mi = ( struct monitorinfo * )be->be_private;
58 if ( monitor_cache_get( mi,
59 &monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
62 LDAP_LOG( OPERATION, CRIT,
63 "monitor_subsys_backend_init: "
64 "unable to get entry '%s'\n",
65 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0, 0 );
67 Debug( LDAP_DEBUG_ANY,
68 "monitor_subsys_backend_init: "
69 "unable to get entry '%s'\n%s%s",
70 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
77 for ( i = nBackendInfo; i--; ) {
78 char buf[ BACKMONITOR_BUFSIZE ];
85 snprintf( buf, sizeof( buf ),
86 "dn: cn=Backend %d,%s\n"
88 "structuralObjectClass: %s\n"
91 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val,
92 mi->oc_monitoredObject->soc_cname.bv_val,
93 mi->oc_monitoredObject->soc_cname.bv_val,
99 LDAP_LOG( OPERATION, CRIT,
100 "monitor_subsys_backend_init: "
101 "unable to create entry 'cn=Backend %d,%s'\n",
102 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
104 Debug( LDAP_DEBUG_ANY,
105 "monitor_subsys_backend_init: "
106 "unable to create entry 'cn=Backend %d,%s'\n%s",
108 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
114 bv.bv_val = bi->bi_type;
115 bv.bv_len = strlen( bv.bv_val );
117 attr_merge_normalize_one( e, mi->ad_monitoredInfo,
119 attr_merge_normalize_one( e_backend, mi->ad_monitoredInfo,
122 if ( bi->bi_controls ) {
125 for ( j = 0; bi->bi_controls[ j ]; j++ ) {
126 bv.bv_val = bi->bi_controls[ j ];
127 bv.bv_len = strlen( bv.bv_val );
128 attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL );
132 for ( j = 0; j < nBackendDB; j++ ) {
133 BackendDB *be = &backendDB[j];
134 char buf[ SLAP_LDAPDN_MAXLEN ];
137 if ( be->bd_info != bi ) {
141 snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
142 j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
144 dn.bv_len = strlen( buf );
146 attr_merge_normalize_one( e, mi->ad_seeAlso,
150 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
151 e->e_private = ( void * )mp;
153 mp->mp_children = NULL;
154 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
155 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
158 if ( monitor_cache_add( mi, e ) ) {
160 LDAP_LOG( OPERATION, CRIT,
161 "monitor_subsys_backend_init: "
162 "unable to add entry 'cn=Backend %d,%s'\n",
163 i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
165 Debug( LDAP_DEBUG_ANY,
166 "monitor_subsys_backend_init: "
167 "unable to add entry 'cn=Backend %d,%s'\n%s",
169 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
178 mp = ( struct monitorentrypriv * )e_backend->e_private;
179 mp->mp_children = e_tmp;
181 monitor_cache_release( mi, e_backend );