1 /* backend.c - deals with backend subsystem */
3 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
8 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
12 * This work has beed deveolped for the OpenLDAP Foundation
13 * in the hope that it may be useful to the Open Source community,
14 * but WITHOUT ANY WARRANTY.
16 * Permission is granted to anyone to use this software for any purpose
17 * on any computer system, and to alter it and redistribute it, subject
18 * to the following restrictions:
20 * 1. The author and SysNet s.n.c. are not responsible for the consequences
21 * of use of this software, no matter how awful, even if they arise from
24 * 2. The origin of this software must not be misrepresented, either by
25 * explicit claim or by omission. Since few users ever read sources,
26 * credits should appear in the documentation.
28 * 3. Altered versions must be plainly marked as such, and must not be
29 * misrepresented as being the original software. Since few users
30 * ever read sources, credits should appear in the documentation.
31 * SysNet s.n.c. cannot be responsible for the consequences of the
34 * 4. This notice may not be removed or altered.
43 #include "back-monitor.h"
46 * initializes backend subentries
49 monitor_subsys_backend_init(
53 struct monitorinfo *mi;
54 Entry *e, *e_backend, *e_tmp;
56 struct monitorentrypriv *mp;
57 struct berval *bv[2], val;
59 mi = ( struct monitorinfo * )be->be_private;
61 if ( monitor_cache_get( mi,
62 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
65 LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
66 "monitor_subsys_backend_init: "
67 "unable to get entry '%s'\n",
68 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn ));
70 Debug( LDAP_DEBUG_ANY,
71 "monitor_subsys_backend_init: "
72 "unable to get entry '%s'\n%s%s",
73 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
82 for ( i = nBackendInfo; i--; ) {
88 snprintf( buf, sizeof( buf ),
91 "objectClass: LDAPsubEntry\n"
92 #ifdef SLAPD_MONITORSUBENTRY
93 "objectClass: monitorSubEntry\n"
94 #else /* !SLAPD_MONITORSUBENTRY */
95 "objectClass: extensibleObject\n"
96 #endif /* !SLAPD_MONITORSUBENTRY */
99 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn,
102 e = str2entry( buf );
105 LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
106 "monitor_subsys_backend_init: "
107 "unable to create entry 'cn=%d,%s'\n",
109 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn ));
111 Debug( LDAP_DEBUG_ANY,
112 "monitor_subsys_backend_init: "
113 "unable to create entry 'cn=%d,%s'\n%s",
115 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
121 val.bv_val = bi->bi_type;
122 val.bv_len = strlen( val.bv_val );
124 attr_merge( e, monitor_ad_desc, bv );
125 attr_merge( e_backend, monitor_ad_desc, bv );
127 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
128 e->e_private = ( void * )mp;
130 mp->mp_children = NULL;
131 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
132 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
135 if ( monitor_cache_add( mi, e ) ) {
137 LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
138 "monitor_subsys_backend_init: "
139 "unable to add entry 'cn=%d,%s'\n",
141 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn ));
143 Debug( LDAP_DEBUG_ANY,
144 "monitor_subsys_backend_init: "
145 "unable to add entry 'cn=%d,%s'\n%s",
147 monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
156 mp = ( struct monitorentrypriv * )e_backend->e_private;
157 mp->mp_children = e_tmp;
159 monitor_cache_release( mi, e_backend);