| 1 |
/* init.c - initialize monitor backend */ |
| 2 |
/* $OpenLDAP$ */ |
| 3 |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
| 4 |
* |
| 5 |
* Copyright 2001-2024 The OpenLDAP Foundation. |
| 6 |
* Portions Copyright 2001-2003 Pierangelo Masarati. |
| 7 |
* All rights reserved. |
| 8 |
* |
| 9 |
* Redistribution and use in source and binary forms, with or without |
| 10 |
* modification, are permitted only as authorized by the OpenLDAP |
| 11 |
* Public License. |
| 12 |
* |
| 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>. |
| 16 |
*/ |
| 17 |
/* ACKNOWLEDGEMENTS: |
| 18 |
* This work was initially developed by Pierangelo Masarati for inclusion |
| 19 |
* in OpenLDAP Software. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "portable.h" |
| 23 |
|
| 24 |
#include <stdio.h> |
| 25 |
#include <ac/string.h> |
| 26 |
|
| 27 |
#include <lutil.h> |
| 28 |
#include "slap.h" |
| 29 |
#include "slap-config.h" |
| 30 |
#include "lber_pvt.h" |
| 31 |
#include "back-monitor.h" |
| 32 |
|
| 33 |
#include "slap-config.h" |
| 34 |
|
| 35 |
#undef INTEGRATE_CORE_SCHEMA |
| 36 |
|
| 37 |
/* |
| 38 |
* used by many functions to add description to entries |
| 39 |
* |
| 40 |
* WARNING: be_monitor may change as new databases are added, |
| 41 |
* so it should not be used outside monitor_back_db_init() |
| 42 |
* until monitor_back_db_open is called. |
| 43 |
*/ |
| 44 |
BackendDB *be_monitor; |
| 45 |
|
| 46 |
static struct monitor_subsys_t **monitor_subsys; |
| 47 |
static int monitor_subsys_opened; |
| 48 |
static monitor_info_t monitor_info; |
| 49 |
static const monitor_extra_t monitor_extra = { |
| 50 |
monitor_back_is_configured, |
| 51 |
monitor_back_get_subsys, |
| 52 |
monitor_back_get_subsys_by_dn, |
| 53 |
|
| 54 |
monitor_back_register_subsys, |
| 55 |
monitor_back_register_backend, |
| 56 |
monitor_back_register_database, |
| 57 |
monitor_back_register_overlay_info, |
| 58 |
monitor_back_register_overlay, |
| 59 |
monitor_back_register_entry, |
| 60 |
monitor_back_register_entry_parent, |
| 61 |
monitor_back_register_entry_attrs, |
| 62 |
monitor_back_register_entry_callback, |
| 63 |
|
| 64 |
monitor_back_unregister_entry, |
| 65 |
monitor_back_unregister_entry_parent, |
| 66 |
monitor_back_unregister_entry_attrs, |
| 67 |
monitor_back_unregister_entry_callback, |
| 68 |
|
| 69 |
monitor_back_entry_stub, |
| 70 |
monitor_back_entrypriv_create, |
| 71 |
monitor_back_register_subsys_late, |
| 72 |
monitor_back_entry_get_unlocked |
| 73 |
}; |
| 74 |
|
| 75 |
|
| 76 |
/* |
| 77 |
* subsystem data |
| 78 |
* |
| 79 |
* the known subsystems are added to the subsystems |
| 80 |
* array at backend initialization; other subsystems |
| 81 |
* may be added by calling monitor_back_register_subsys() |
| 82 |
* before the database is opened (e.g. by other backends |
| 83 |
* or by overlays or modules). |
| 84 |
*/ |
| 85 |
static struct monitor_subsys_t known_monitor_subsys[] = { |
| 86 |
{ |
| 87 |
SLAPD_MONITOR_BACKEND_NAME, |
| 88 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 89 |
{ BER_BVC( "This subsystem contains information about available backends." ), |
| 90 |
BER_BVNULL }, |
| 91 |
MONITOR_F_PERSISTENT_CH, |
| 92 |
monitor_subsys_backend_init, |
| 93 |
NULL, /* destroy */ |
| 94 |
NULL, /* update */ |
| 95 |
NULL, /* create */ |
| 96 |
NULL /* modify */ |
| 97 |
}, { |
| 98 |
SLAPD_MONITOR_CONN_NAME, |
| 99 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 100 |
{ BER_BVC( "This subsystem contains information about connections." ), |
| 101 |
BER_BVNULL }, |
| 102 |
MONITOR_F_VOLATILE_CH, |
| 103 |
monitor_subsys_conn_init, |
| 104 |
NULL, /* destroy */ |
| 105 |
NULL, /* update */ |
| 106 |
NULL, /* create */ |
| 107 |
NULL /* modify */ |
| 108 |
}, { |
| 109 |
SLAPD_MONITOR_DATABASE_NAME, |
| 110 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 111 |
{ BER_BVC( "This subsystem contains information about configured databases." ), |
| 112 |
BER_BVNULL }, |
| 113 |
MONITOR_F_PERSISTENT_CH, |
| 114 |
monitor_subsys_database_init, |
| 115 |
NULL, /* destroy */ |
| 116 |
NULL, /* update */ |
| 117 |
NULL, /* create */ |
| 118 |
NULL /* modify */ |
| 119 |
}, { |
| 120 |
SLAPD_MONITOR_LISTENER_NAME, |
| 121 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 122 |
{ BER_BVC( "This subsystem contains information about active listeners." ), |
| 123 |
BER_BVNULL }, |
| 124 |
MONITOR_F_PERSISTENT_CH, |
| 125 |
monitor_subsys_listener_init, |
| 126 |
NULL, /* destroy */ |
| 127 |
NULL, /* update */ |
| 128 |
NULL, /* create */ |
| 129 |
NULL /* modify */ |
| 130 |
}, { |
| 131 |
SLAPD_MONITOR_LOG_NAME, |
| 132 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 133 |
{ BER_BVC( "This subsystem contains information about logging." ), |
| 134 |
BER_BVC( "Set the \"monitorLogLevel\" or \"monitorDebugLevel\" attributes to the desired levels." ), |
| 135 |
BER_BVNULL }, |
| 136 |
MONITOR_F_NONE, |
| 137 |
monitor_subsys_log_init, |
| 138 |
NULL, /* destroy */ |
| 139 |
NULL, /* update */ |
| 140 |
NULL, /* create */ |
| 141 |
NULL, /* modify */ |
| 142 |
}, { |
| 143 |
SLAPD_MONITOR_OPS_NAME, |
| 144 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 145 |
{ BER_BVC( "This subsystem contains information about performed operations." ), |
| 146 |
BER_BVNULL }, |
| 147 |
MONITOR_F_PERSISTENT_CH, |
| 148 |
monitor_subsys_ops_init, |
| 149 |
NULL, /* destroy */ |
| 150 |
NULL, /* update */ |
| 151 |
NULL, /* create */ |
| 152 |
NULL, /* modify */ |
| 153 |
}, { |
| 154 |
SLAPD_MONITOR_OVERLAY_NAME, |
| 155 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 156 |
{ BER_BVC( "This subsystem contains information about available overlays." ), |
| 157 |
BER_BVNULL }, |
| 158 |
MONITOR_F_PERSISTENT_CH, |
| 159 |
monitor_subsys_overlay_init, |
| 160 |
NULL, /* destroy */ |
| 161 |
NULL, /* update */ |
| 162 |
NULL, /* create */ |
| 163 |
NULL, /* modify */ |
| 164 |
}, { |
| 165 |
SLAPD_MONITOR_SASL_NAME, |
| 166 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 167 |
{ BER_BVC( "This subsystem contains information about SASL." ), |
| 168 |
BER_BVNULL }, |
| 169 |
MONITOR_F_NONE, |
| 170 |
NULL, /* init */ |
| 171 |
NULL, /* destroy */ |
| 172 |
NULL, /* update */ |
| 173 |
NULL, /* create */ |
| 174 |
NULL /* modify */ |
| 175 |
}, { |
| 176 |
SLAPD_MONITOR_SENT_NAME, |
| 177 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 178 |
{ BER_BVC( "This subsystem contains statistics." ), |
| 179 |
BER_BVNULL }, |
| 180 |
MONITOR_F_PERSISTENT_CH, |
| 181 |
monitor_subsys_sent_init, |
| 182 |
NULL, /* destroy */ |
| 183 |
NULL, /* update */ |
| 184 |
NULL, /* create */ |
| 185 |
NULL, /* modify */ |
| 186 |
}, { |
| 187 |
SLAPD_MONITOR_THREAD_NAME, |
| 188 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 189 |
{ BER_BVC( "This subsystem contains information about threads." ), |
| 190 |
BER_BVNULL }, |
| 191 |
MONITOR_F_PERSISTENT_CH, |
| 192 |
monitor_subsys_thread_init, |
| 193 |
NULL, /* destroy */ |
| 194 |
NULL, /* update */ |
| 195 |
NULL, /* create */ |
| 196 |
NULL /* modify */ |
| 197 |
}, { |
| 198 |
SLAPD_MONITOR_TIME_NAME, |
| 199 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 200 |
{ BER_BVC( "This subsystem contains information about time." ), |
| 201 |
BER_BVNULL }, |
| 202 |
MONITOR_F_PERSISTENT_CH, |
| 203 |
monitor_subsys_time_init, |
| 204 |
NULL, /* destroy */ |
| 205 |
NULL, /* update */ |
| 206 |
NULL, /* create */ |
| 207 |
NULL, /* modify */ |
| 208 |
}, { |
| 209 |
SLAPD_MONITOR_TLS_NAME, |
| 210 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 211 |
{ BER_BVC( "This subsystem contains information about TLS." ), |
| 212 |
BER_BVNULL }, |
| 213 |
MONITOR_F_NONE, |
| 214 |
NULL, /* init */ |
| 215 |
NULL, /* destroy */ |
| 216 |
NULL, /* update */ |
| 217 |
NULL, /* create */ |
| 218 |
NULL /* modify */ |
| 219 |
}, { |
| 220 |
SLAPD_MONITOR_RWW_NAME, |
| 221 |
BER_BVNULL, BER_BVNULL, BER_BVNULL, |
| 222 |
{ BER_BVC( "This subsystem contains information about read/write waiters." ), |
| 223 |
BER_BVNULL }, |
| 224 |
MONITOR_F_PERSISTENT_CH, |
| 225 |
monitor_subsys_rww_init, |
| 226 |
NULL, /* destroy */ |
| 227 |
NULL, /* update */ |
| 228 |
NULL, /* create */ |
| 229 |
NULL /* modify */ |
| 230 |
}, { NULL } |
| 231 |
}; |
| 232 |
|
| 233 |
int |
| 234 |
monitor_subsys_is_opened( void ) |
| 235 |
{ |
| 236 |
return monitor_subsys_opened; |
| 237 |
} |
| 238 |
|
| 239 |
int |
| 240 |
monitor_back_register_subsys( |
| 241 |
monitor_subsys_t *ms ) |
| 242 |
{ |
| 243 |
int i = 0; |
| 244 |
|
| 245 |
if ( monitor_subsys ) { |
| 246 |
for ( ; monitor_subsys[ i ] != NULL; i++ ) |
| 247 |
/* just count'em */ ; |
| 248 |
} |
| 249 |
|
| 250 |
monitor_subsys = ch_realloc( monitor_subsys, |
| 251 |
( 2 + i ) * sizeof( monitor_subsys_t * ) ); |
| 252 |
|
| 253 |
if ( monitor_subsys == NULL ) { |
| 254 |
return -1; |
| 255 |
} |
| 256 |
|
| 257 |
monitor_subsys[ i ] = ms; |
| 258 |
monitor_subsys[ i + 1 ] = NULL; |
| 259 |
|
| 260 |
/* if a subsystem is registered __AFTER__ subsystem |
| 261 |
* initialization (depending on the sequence the databases |
| 262 |
* are listed in slapd.conf), init it */ |
| 263 |
if ( monitor_subsys_is_opened() ) { |
| 264 |
|
| 265 |
/* FIXME: this should only be possible |
| 266 |
* if be_monitor is already initialized */ |
| 267 |
assert( be_monitor != NULL ); |
| 268 |
|
| 269 |
if ( ms->mss_open && ( *ms->mss_open )( be_monitor, ms ) ) { |
| 270 |
return -1; |
| 271 |
} |
| 272 |
|
| 273 |
ms->mss_flags |= MONITOR_F_OPENED; |
| 274 |
} |
| 275 |
|
| 276 |
return 0; |
| 277 |
} |
| 278 |
|
| 279 |
enum { |
| 280 |
LIMBO_ENTRY, |
| 281 |
LIMBO_ENTRY_PARENT, |
| 282 |
LIMBO_ATTRS, |
| 283 |
LIMBO_CB, |
| 284 |
LIMBO_BACKEND, |
| 285 |
LIMBO_DATABASE, |
| 286 |
LIMBO_OVERLAY_INFO, |
| 287 |
LIMBO_OVERLAY, |
| 288 |
LIMBO_SUBSYS, |
| 289 |
|
| 290 |
LIMBO_LAST |
| 291 |
}; |
| 292 |
|
| 293 |
typedef struct entry_limbo_t { |
| 294 |
int el_type; |
| 295 |
BackendInfo *el_bi; |
| 296 |
BackendDB *el_be; |
| 297 |
slap_overinst *el_on; |
| 298 |
Entry *el_e; |
| 299 |
Attribute *el_a; |
| 300 |
struct berval *el_ndn; |
| 301 |
struct berval el_nbase; |
| 302 |
int el_scope; |
| 303 |
struct berval el_filter; |
| 304 |
monitor_callback_t *el_cb; |
| 305 |
monitor_subsys_t *el_mss; |
| 306 |
unsigned long el_flags; |
| 307 |
struct entry_limbo_t *el_next; |
| 308 |
} entry_limbo_t; |
| 309 |
|
| 310 |
int |
| 311 |
monitor_back_is_configured( void ) |
| 312 |
{ |
| 313 |
return be_monitor != NULL; |
| 314 |
} |
| 315 |
|
| 316 |
int |
| 317 |
monitor_back_register_subsys_late( |
| 318 |
monitor_subsys_t *ms ) |
| 319 |
{ |
| 320 |
entry_limbo_t **elpp, el = { 0 }; |
| 321 |
monitor_info_t *mi; |
| 322 |
|
| 323 |
if ( be_monitor == NULL ) { |
| 324 |
Debug( LDAP_DEBUG_ANY, |
| 325 |
"monitor_back_register_subsys_late: " |
| 326 |
"monitor database not configured.\n" ); |
| 327 |
return -1; |
| 328 |
} |
| 329 |
|
| 330 |
/* everything is ready, can register already */ |
| 331 |
if ( monitor_subsys_is_opened() ) { |
| 332 |
return monitor_back_register_subsys( ms ); |
| 333 |
} |
| 334 |
|
| 335 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 336 |
|
| 337 |
|
| 338 |
el.el_type = LIMBO_SUBSYS; |
| 339 |
|
| 340 |
el.el_mss = ms; |
| 341 |
|
| 342 |
for ( elpp = &mi->mi_entry_limbo; |
| 343 |
*elpp; |
| 344 |
elpp = &(*elpp)->el_next ) |
| 345 |
/* go to last */; |
| 346 |
|
| 347 |
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) ); |
| 348 |
|
| 349 |
el.el_next = NULL; |
| 350 |
**elpp = el; |
| 351 |
|
| 352 |
return 0; |
| 353 |
} |
| 354 |
|
| 355 |
int |
| 356 |
monitor_back_register_backend( |
| 357 |
BackendInfo *bi ) |
| 358 |
{ |
| 359 |
return -1; |
| 360 |
} |
| 361 |
|
| 362 |
int |
| 363 |
monitor_back_register_overlay_info( |
| 364 |
slap_overinst *on ) |
| 365 |
{ |
| 366 |
return -1; |
| 367 |
} |
| 368 |
|
| 369 |
int |
| 370 |
monitor_back_register_backend_limbo( |
| 371 |
BackendInfo *bi ) |
| 372 |
{ |
| 373 |
return -1; |
| 374 |
} |
| 375 |
|
| 376 |
int |
| 377 |
monitor_back_register_database_limbo( |
| 378 |
BackendDB *be, |
| 379 |
struct berval *ndn_out ) |
| 380 |
{ |
| 381 |
entry_limbo_t **elpp, el = { 0 }; |
| 382 |
monitor_info_t *mi; |
| 383 |
|
| 384 |
if ( be_monitor == NULL ) { |
| 385 |
Debug( LDAP_DEBUG_ANY, |
| 386 |
"monitor_back_register_database_limbo: " |
| 387 |
"monitor database not configured.\n" ); |
| 388 |
return -1; |
| 389 |
} |
| 390 |
|
| 391 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 392 |
|
| 393 |
|
| 394 |
el.el_type = LIMBO_DATABASE; |
| 395 |
|
| 396 |
el.el_be = be->bd_self; |
| 397 |
el.el_ndn = ndn_out; |
| 398 |
|
| 399 |
for ( elpp = &mi->mi_entry_limbo; |
| 400 |
*elpp; |
| 401 |
elpp = &(*elpp)->el_next ) |
| 402 |
/* go to last */; |
| 403 |
|
| 404 |
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) ); |
| 405 |
|
| 406 |
el.el_next = NULL; |
| 407 |
**elpp = el; |
| 408 |
|
| 409 |
return 0; |
| 410 |
} |
| 411 |
|
| 412 |
int |
| 413 |
monitor_back_register_overlay_info_limbo( |
| 414 |
slap_overinst *on ) |
| 415 |
{ |
| 416 |
return -1; |
| 417 |
} |
| 418 |
|
| 419 |
int |
| 420 |
monitor_back_register_overlay_limbo( |
| 421 |
BackendDB *be, |
| 422 |
struct slap_overinst *on, |
| 423 |
struct berval *ndn_out ) |
| 424 |
{ |
| 425 |
entry_limbo_t **elpp, el = { 0 }; |
| 426 |
monitor_info_t *mi; |
| 427 |
|
| 428 |
if ( be_monitor == NULL ) { |
| 429 |
Debug( LDAP_DEBUG_ANY, |
| 430 |
"monitor_back_register_overlay_limbo: " |
| 431 |
"monitor database not configured.\n" ); |
| 432 |
return -1; |
| 433 |
} |
| 434 |
|
| 435 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 436 |
|
| 437 |
|
| 438 |
el.el_type = LIMBO_OVERLAY; |
| 439 |
|
| 440 |
el.el_be = be->bd_self; |
| 441 |
el.el_on = on; |
| 442 |
el.el_ndn = ndn_out; |
| 443 |
|
| 444 |
for ( elpp = &mi->mi_entry_limbo; |
| 445 |
*elpp; |
| 446 |
elpp = &(*elpp)->el_next ) |
| 447 |
/* go to last */; |
| 448 |
|
| 449 |
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) ); |
| 450 |
|
| 451 |
el.el_next = NULL; |
| 452 |
**elpp = el; |
| 453 |
|
| 454 |
return 0; |
| 455 |
} |
| 456 |
|
| 457 |
int |
| 458 |
monitor_back_register_entry( |
| 459 |
Entry *e, |
| 460 |
monitor_callback_t *cb, |
| 461 |
monitor_subsys_t *mss, |
| 462 |
unsigned long flags ) |
| 463 |
{ |
| 464 |
monitor_info_t *mi; |
| 465 |
int rc = 0; |
| 466 |
|
| 467 |
if ( be_monitor == NULL ) { |
| 468 |
Debug( LDAP_DEBUG_ANY, |
| 469 |
"monitor_back_register_entry(\"%s\"): " |
| 470 |
"monitor database not configured.\n", |
| 471 |
e->e_name.bv_val ); |
| 472 |
return -1; |
| 473 |
} |
| 474 |
|
| 475 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 476 |
|
| 477 |
assert( mi != NULL ); |
| 478 |
assert( e != NULL ); |
| 479 |
assert( e->e_private == NULL ); |
| 480 |
|
| 481 |
if ( monitor_subsys_is_opened() ) { |
| 482 |
Entry *e_parent = NULL, *e_new = NULL; |
| 483 |
struct berval pdn = BER_BVNULL; |
| 484 |
monitor_entry_t *mp = NULL, |
| 485 |
*mp_parent = NULL; |
| 486 |
|
| 487 |
if ( monitor_cache_get( mi, &e->e_nname, &e_parent ) == 0 ) { |
| 488 |
/* entry exists */ |
| 489 |
Debug( LDAP_DEBUG_ANY, |
| 490 |
"monitor_back_register_entry(\"%s\"): " |
| 491 |
"entry exists\n", |
| 492 |
e->e_name.bv_val ); |
| 493 |
monitor_cache_release( mi, e_parent ); |
| 494 |
return -1; |
| 495 |
} |
| 496 |
|
| 497 |
dnParent( &e->e_nname, &pdn ); |
| 498 |
if ( monitor_cache_get( mi, &pdn, &e_parent ) != 0 ) { |
| 499 |
/* parent does not exist */ |
| 500 |
Debug( LDAP_DEBUG_ANY, |
| 501 |
"monitor_back_register_entry(\"%s\"): " |
| 502 |
"parent \"%s\" not found\n", |
| 503 |
e->e_name.bv_val, pdn.bv_val ); |
| 504 |
return -1; |
| 505 |
} |
| 506 |
|
| 507 |
assert( e_parent->e_private != NULL ); |
| 508 |
mp_parent = ( monitor_entry_t * )e_parent->e_private; |
| 509 |
|
| 510 |
if ( mp_parent->mp_flags & MONITOR_F_VOLATILE ) { |
| 511 |
/* entry is volatile; cannot append children */ |
| 512 |
Debug( LDAP_DEBUG_ANY, |
| 513 |
"monitor_back_register_entry(\"%s\"): " |
| 514 |
"parent \"%s\" is volatile\n", |
| 515 |
e->e_name.bv_val, e_parent->e_name.bv_val ); |
| 516 |
rc = -1; |
| 517 |
goto done; |
| 518 |
} |
| 519 |
|
| 520 |
mp = monitor_entrypriv_create(); |
| 521 |
if ( mp == NULL ) { |
| 522 |
Debug( LDAP_DEBUG_ANY, |
| 523 |
"monitor_back_register_entry(\"%s\"): " |
| 524 |
"monitor_entrypriv_create() failed\n", |
| 525 |
e->e_name.bv_val ); |
| 526 |
rc = -1; |
| 527 |
goto done; |
| 528 |
} |
| 529 |
|
| 530 |
e_new = entry_dup( e ); |
| 531 |
if ( e_new == NULL ) { |
| 532 |
Debug( LDAP_DEBUG_ANY, |
| 533 |
"monitor_back_register_entry(\"%s\"): " |
| 534 |
"entry_dup() failed\n", |
| 535 |
e->e_name.bv_val ); |
| 536 |
rc = -1; |
| 537 |
goto done; |
| 538 |
} |
| 539 |
|
| 540 |
e_new->e_private = ( void * )mp; |
| 541 |
if ( mss != NULL ) { |
| 542 |
mp->mp_info = mss; |
| 543 |
mp->mp_flags = flags; |
| 544 |
|
| 545 |
} else { |
| 546 |
mp->mp_info = mp_parent->mp_info; |
| 547 |
mp->mp_flags = mp_parent->mp_flags | MONITOR_F_SUB; |
| 548 |
} |
| 549 |
mp->mp_cb = cb; |
| 550 |
|
| 551 |
if ( monitor_cache_add( mi, e_new, e_parent ) ) { |
| 552 |
Debug( LDAP_DEBUG_ANY, |
| 553 |
"monitor_back_register_entry(\"%s\"): " |
| 554 |
"unable to add entry\n", |
| 555 |
e->e_name.bv_val ); |
| 556 |
rc = -1; |
| 557 |
goto done; |
| 558 |
} |
| 559 |
|
| 560 |
done:; |
| 561 |
if ( rc ) { |
| 562 |
if ( mp ) { |
| 563 |
ch_free( mp ); |
| 564 |
} |
| 565 |
if ( e_new ) { |
| 566 |
e_new->e_private = NULL; |
| 567 |
entry_free( e_new ); |
| 568 |
} |
| 569 |
} |
| 570 |
|
| 571 |
if ( e_parent ) { |
| 572 |
monitor_cache_release( mi, e_parent ); |
| 573 |
} |
| 574 |
|
| 575 |
} else { |
| 576 |
entry_limbo_t **elpp, el = { 0 }; |
| 577 |
|
| 578 |
el.el_type = LIMBO_ENTRY; |
| 579 |
|
| 580 |
el.el_e = entry_dup( e ); |
| 581 |
if ( el.el_e == NULL ) { |
| 582 |
Debug( LDAP_DEBUG_ANY, |
| 583 |
"monitor_back_register_entry(\"%s\"): " |
| 584 |
"entry_dup() failed\n", |
| 585 |
e->e_name.bv_val ); |
| 586 |
return -1; |
| 587 |
} |
| 588 |
|
| 589 |
el.el_cb = cb; |
| 590 |
el.el_mss = mss; |
| 591 |
el.el_flags = flags; |
| 592 |
|
| 593 |
for ( elpp = &mi->mi_entry_limbo; |
| 594 |
*elpp; |
| 595 |
elpp = &(*elpp)->el_next ) |
| 596 |
/* go to last */; |
| 597 |
|
| 598 |
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) ); |
| 599 |
if ( *elpp == NULL ) { |
| 600 |
el.el_e->e_private = NULL; |
| 601 |
entry_free( el.el_e ); |
| 602 |
return -1; |
| 603 |
} |
| 604 |
|
| 605 |
el.el_next = NULL; |
| 606 |
**elpp = el; |
| 607 |
} |
| 608 |
|
| 609 |
return rc; |
| 610 |
} |
| 611 |
|
| 612 |
int |
| 613 |
monitor_back_register_entry_parent( |
| 614 |
Entry *e, |
| 615 |
monitor_callback_t *cb, |
| 616 |
monitor_subsys_t *mss, |
| 617 |
unsigned long flags, |
| 618 |
struct berval *nbase, |
| 619 |
int scope, |
| 620 |
struct berval *filter ) |
| 621 |
{ |
| 622 |
monitor_info_t *mi; |
| 623 |
struct berval ndn = BER_BVNULL; |
| 624 |
|
| 625 |
if ( be_monitor == NULL ) { |
| 626 |
Debug( LDAP_DEBUG_ANY, |
| 627 |
"monitor_back_register_entry_parent(base=\"%s\" scope=%s filter=\"%s\"): " |
| 628 |
"monitor database not configured.\n", |
| 629 |
BER_BVISNULL( nbase ) ? "" : nbase->bv_val, |
| 630 |
ldap_pvt_scope2str( scope ), |
| 631 |
BER_BVISNULL( filter ) ? "" : filter->bv_val ); |
| 632 |
return -1; |
| 633 |
} |
| 634 |
|
| 635 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 636 |
|
| 637 |
assert( mi != NULL ); |
| 638 |
assert( e != NULL ); |
| 639 |
assert( e->e_private == NULL ); |
| 640 |
|
| 641 |
if ( BER_BVISNULL( filter ) ) { |
| 642 |
/* need a filter */ |
| 643 |
Debug( LDAP_DEBUG_ANY, |
| 644 |
"monitor_back_register_entry_parent(\"\"): " |
| 645 |
"need a valid filter\n" ); |
| 646 |
return -1; |
| 647 |
} |
| 648 |
|
| 649 |
if ( monitor_subsys_is_opened() ) { |
| 650 |
Entry *e_parent = NULL, *e_new = NULL; |
| 651 |
struct berval e_name = BER_BVNULL, |
| 652 |
e_nname = BER_BVNULL; |
| 653 |
monitor_entry_t *mp = NULL, |
| 654 |
*mp_parent = NULL; |
| 655 |
int rc = 0; |
| 656 |
|
| 657 |
if ( monitor_search2ndn( nbase, scope, filter, &ndn ) ) { |
| 658 |
/* entry does not exist */ |
| 659 |
Debug( LDAP_DEBUG_ANY, |
| 660 |
"monitor_back_register_entry_parent(\"\"): " |
| 661 |
"base=\"%s\" scope=%s filter=\"%s\": " |
| 662 |
"unable to find entry\n", |
| 663 |
nbase->bv_val ? nbase->bv_val : "\"\"", |
| 664 |
ldap_pvt_scope2str( scope ), |
| 665 |
filter->bv_val ); |
| 666 |
return -1; |
| 667 |
} |
| 668 |
|
| 669 |
if ( monitor_cache_get( mi, &ndn, &e_parent ) != 0 ) { |
| 670 |
/* entry does not exist */ |
| 671 |
Debug( LDAP_DEBUG_ANY, |
| 672 |
"monitor_back_register_entry_parent(\"%s\"): " |
| 673 |
"parent entry does not exist\n", |
| 674 |
ndn.bv_val ); |
| 675 |
rc = -1; |
| 676 |
goto done; |
| 677 |
} |
| 678 |
|
| 679 |
assert( e_parent->e_private != NULL ); |
| 680 |
mp_parent = ( monitor_entry_t * )e_parent->e_private; |
| 681 |
|
| 682 |
if ( mp_parent->mp_flags & MONITOR_F_VOLATILE ) { |
| 683 |
/* entry is volatile; cannot append callback */ |
| 684 |
Debug( LDAP_DEBUG_ANY, |
| 685 |
"monitor_back_register_entry_parent(\"%s\"): " |
| 686 |
"entry is volatile\n", |
| 687 |
e_parent->e_name.bv_val ); |
| 688 |
rc = -1; |
| 689 |
goto done; |
| 690 |
} |
| 691 |
|
| 692 |
build_new_dn( &e_name, &e_parent->e_name, &e->e_name, NULL ); |
| 693 |
build_new_dn( &e_nname, &e_parent->e_nname, &e->e_nname, NULL ); |
| 694 |
|
| 695 |
if ( monitor_cache_get( mi, &e_nname, &e_new ) == 0 ) { |
| 696 |
/* entry already exists */ |
| 697 |
Debug( LDAP_DEBUG_ANY, |
| 698 |
"monitor_back_register_entry_parent(\"%s\"): " |
| 699 |
"entry already exists\n", |
| 700 |
e_name.bv_val ); |
| 701 |
monitor_cache_release( mi, e_new ); |
| 702 |
e_new = NULL; |
| 703 |
rc = -1; |
| 704 |
goto done; |
| 705 |
} |
| 706 |
|
| 707 |
mp = monitor_entrypriv_create(); |
| 708 |
if ( mp == NULL ) { |
| 709 |
Debug( LDAP_DEBUG_ANY, |
| 710 |
"monitor_back_register_entry_parent(\"%s\"): " |
| 711 |
"monitor_entrypriv_create() failed\n", |
| 712 |
e->e_name.bv_val ); |
| 713 |
rc = -1; |
| 714 |
goto done; |
| 715 |
} |
| 716 |
|
| 717 |
e_new = entry_dup( e ); |
| 718 |
if ( e_new == NULL ) { |
| 719 |
Debug( LDAP_DEBUG_ANY, |
| 720 |
"monitor_back_register_entry(\"%s\"): " |
| 721 |
"entry_dup() failed\n", |
| 722 |
e->e_name.bv_val ); |
| 723 |
rc = -1; |
| 724 |
goto done; |
| 725 |
} |
| 726 |
ch_free( e_new->e_name.bv_val ); |
| 727 |
ch_free( e_new->e_nname.bv_val ); |
| 728 |
e_new->e_name = e_name; |
| 729 |
e_new->e_nname = e_nname; |
| 730 |
|
| 731 |
e_new->e_private = ( void * )mp; |
| 732 |
if ( mss != NULL ) { |
| 733 |
mp->mp_info = mss; |
| 734 |
mp->mp_flags = flags; |
| 735 |
|
| 736 |
} else { |
| 737 |
mp->mp_info = mp_parent->mp_info; |
| 738 |
mp->mp_flags = mp_parent->mp_flags | MONITOR_F_SUB; |
| 739 |
} |
| 740 |
mp->mp_cb = cb; |
| 741 |
|
| 742 |
if ( monitor_cache_add( mi, e_new, e_parent ) ) { |
| 743 |
Debug( LDAP_DEBUG_ANY, |
| 744 |
"monitor_back_register_entry(\"%s\"): " |
| 745 |
"unable to add entry\n", |
| 746 |
e->e_name.bv_val ); |
| 747 |
rc = -1; |
| 748 |
goto done; |
| 749 |
} |
| 750 |
|
| 751 |
done:; |
| 752 |
if ( !BER_BVISNULL( &ndn ) ) { |
| 753 |
ch_free( ndn.bv_val ); |
| 754 |
} |
| 755 |
|
| 756 |
if ( rc ) { |
| 757 |
if ( mp ) { |
| 758 |
ch_free( mp ); |
| 759 |
} |
| 760 |
if ( e_new ) { |
| 761 |
e_new->e_private = NULL; |
| 762 |
entry_free( e_new ); |
| 763 |
} |
| 764 |
} |
| 765 |
|
| 766 |
if ( e_parent ) { |
| 767 |
monitor_cache_release( mi, e_parent ); |
| 768 |
} |
| 769 |
|
| 770 |
} else { |
| 771 |
entry_limbo_t **elpp = NULL, el = { 0 }; |
| 772 |
|
| 773 |
el.el_type = LIMBO_ENTRY_PARENT; |
| 774 |
|
| 775 |
el.el_e = entry_dup( e ); |
| 776 |
if ( el.el_e == NULL ) { |
| 777 |
Debug( LDAP_DEBUG_ANY, |
| 778 |
"monitor_back_register_entry(\"%s\"): " |
| 779 |
"entry_dup() failed\n", |
| 780 |
e->e_name.bv_val ); |
| 781 |
goto done_limbo; |
| 782 |
} |
| 783 |
|
| 784 |
if ( !BER_BVISNULL( nbase ) ) { |
| 785 |
ber_dupbv( &el.el_nbase, nbase ); |
| 786 |
} |
| 787 |
|
| 788 |
el.el_scope = scope; |
| 789 |
if ( !BER_BVISNULL( filter ) ) { |
| 790 |
ber_dupbv( &el.el_filter, filter ); |
| 791 |
} |
| 792 |
|
| 793 |
el.el_cb = cb; |
| 794 |
el.el_mss = mss; |
| 795 |
el.el_flags = flags; |
| 796 |
|
| 797 |
for ( elpp = &mi->mi_entry_limbo; |
| 798 |
*elpp; |
| 799 |
elpp = &(*elpp)->el_next ) |
| 800 |
/* go to last */; |
| 801 |
|
| 802 |
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) ); |
| 803 |
if ( *elpp == NULL ) { |
| 804 |
goto done_limbo; |
| 805 |
} |
| 806 |
|
| 807 |
done_limbo:; |
| 808 |
if ( *elpp != NULL ) { |
| 809 |
el.el_next = NULL; |
| 810 |
**elpp = el; |
| 811 |
|
| 812 |
} else { |
| 813 |
if ( !BER_BVISNULL( &el.el_filter ) ) { |
| 814 |
ch_free( el.el_filter.bv_val ); |
| 815 |
} |
| 816 |
if ( !BER_BVISNULL( &el.el_nbase ) ) { |
| 817 |
ch_free( el.el_nbase.bv_val ); |
| 818 |
} |
| 819 |
entry_free( el.el_e ); |
| 820 |
return -1; |
| 821 |
} |
| 822 |
} |
| 823 |
|
| 824 |
return 0; |
| 825 |
} |
| 826 |
|
| 827 |
static int |
| 828 |
monitor_search2ndn_cb( Operation *op, SlapReply *rs ) |
| 829 |
{ |
| 830 |
if ( rs->sr_type == REP_SEARCH ) { |
| 831 |
struct berval *ndn = op->o_callback->sc_private; |
| 832 |
|
| 833 |
if ( !BER_BVISNULL( ndn ) ) { |
| 834 |
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; |
| 835 |
ch_free( ndn->bv_val ); |
| 836 |
BER_BVZERO( ndn ); |
| 837 |
return rs->sr_err; |
| 838 |
} |
| 839 |
|
| 840 |
ber_dupbv( ndn, &rs->sr_entry->e_nname ); |
| 841 |
} |
| 842 |
|
| 843 |
return 0; |
| 844 |
} |
| 845 |
|
| 846 |
int |
| 847 |
monitor_search2ndn( |
| 848 |
struct berval *nbase, |
| 849 |
int scope, |
| 850 |
struct berval *filter, |
| 851 |
struct berval *ndn ) |
| 852 |
{ |
| 853 |
Connection conn = { 0 }; |
| 854 |
OperationBuffer opbuf; |
| 855 |
Operation *op; |
| 856 |
void *thrctx; |
| 857 |
SlapReply rs = { REP_RESULT }; |
| 858 |
slap_callback cb = { NULL, monitor_search2ndn_cb, NULL, NULL }; |
| 859 |
int rc; |
| 860 |
|
| 861 |
BER_BVZERO( ndn ); |
| 862 |
|
| 863 |
if ( be_monitor == NULL ) { |
| 864 |
return -1; |
| 865 |
} |
| 866 |
|
| 867 |
thrctx = ldap_pvt_thread_pool_context(); |
| 868 |
connection_fake_init2( &conn, &opbuf, thrctx, 0 ); |
| 869 |
op = &opbuf.ob_op; |
| 870 |
|
| 871 |
op->o_tag = LDAP_REQ_SEARCH; |
| 872 |
|
| 873 |
/* use global malloc for now */ |
| 874 |
if ( op->o_tmpmemctx ) { |
| 875 |
op->o_tmpmemctx = NULL; |
| 876 |
} |
| 877 |
op->o_tmpmfuncs = &ch_mfuncs; |
| 878 |
|
| 879 |
op->o_bd = be_monitor; |
| 880 |
if ( nbase == NULL || BER_BVISNULL( nbase ) ) { |
| 881 |
ber_dupbv_x( &op->o_req_dn, &op->o_bd->be_suffix[ 0 ], |
| 882 |
op->o_tmpmemctx ); |
| 883 |
ber_dupbv_x( &op->o_req_ndn, &op->o_bd->be_nsuffix[ 0 ], |
| 884 |
op->o_tmpmemctx ); |
| 885 |
|
| 886 |
} else { |
| 887 |
if ( dnPrettyNormal( NULL, nbase, &op->o_req_dn, &op->o_req_ndn, |
| 888 |
op->o_tmpmemctx ) ) { |
| 889 |
return -1; |
| 890 |
} |
| 891 |
} |
| 892 |
|
| 893 |
op->o_callback = &cb; |
| 894 |
cb.sc_private = (void *)ndn; |
| 895 |
|
| 896 |
op->ors_scope = scope; |
| 897 |
op->ors_filter = str2filter_x( op, filter->bv_val ); |
| 898 |
if ( op->ors_filter == NULL ) { |
| 899 |
rc = LDAP_OTHER; |
| 900 |
goto cleanup; |
| 901 |
} |
| 902 |
ber_dupbv_x( &op->ors_filterstr, filter, op->o_tmpmemctx ); |
| 903 |
op->ors_attrs = slap_anlist_no_attrs; |
| 904 |
op->ors_attrsonly = 0; |
| 905 |
op->ors_tlimit = SLAP_NO_LIMIT; |
| 906 |
op->ors_slimit = 1; |
| 907 |
op->ors_limit = NULL; |
| 908 |
op->ors_deref = LDAP_DEREF_NEVER; |
| 909 |
|
| 910 |
op->o_nocaching = 1; |
| 911 |
op->o_managedsait = SLAP_CONTROL_NONCRITICAL; |
| 912 |
|
| 913 |
op->o_dn = be_monitor->be_rootdn; |
| 914 |
op->o_ndn = be_monitor->be_rootndn; |
| 915 |
|
| 916 |
rc = op->o_bd->be_search( op, &rs ); |
| 917 |
|
| 918 |
cleanup:; |
| 919 |
if ( op->ors_filter != NULL ) { |
| 920 |
filter_free_x( op, op->ors_filter, 1 ); |
| 921 |
} |
| 922 |
if ( !BER_BVISNULL( &op->ors_filterstr ) ) { |
| 923 |
op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx ); |
| 924 |
} |
| 925 |
if ( !BER_BVISNULL( &op->o_req_dn ) ) { |
| 926 |
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); |
| 927 |
} |
| 928 |
if ( !BER_BVISNULL( &op->o_req_ndn ) ) { |
| 929 |
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); |
| 930 |
} |
| 931 |
|
| 932 |
if ( rc != 0 ) { |
| 933 |
return rc; |
| 934 |
} |
| 935 |
|
| 936 |
switch ( rs.sr_err ) { |
| 937 |
case LDAP_SUCCESS: |
| 938 |
if ( BER_BVISNULL( ndn ) ) { |
| 939 |
rc = -1; |
| 940 |
} |
| 941 |
break; |
| 942 |
|
| 943 |
case LDAP_SIZELIMIT_EXCEEDED: |
| 944 |
default: |
| 945 |
if ( !BER_BVISNULL( ndn ) ) { |
| 946 |
ber_memfree( ndn->bv_val ); |
| 947 |
BER_BVZERO( ndn ); |
| 948 |
} |
| 949 |
rc = -1; |
| 950 |
break; |
| 951 |
} |
| 952 |
|
| 953 |
return rc; |
| 954 |
} |
| 955 |
|
| 956 |
int |
| 957 |
monitor_back_register_entry_attrs( |
| 958 |
struct berval *ndn_in, |
| 959 |
Attribute *a, |
| 960 |
monitor_callback_t *cb, |
| 961 |
struct berval *nbase, |
| 962 |
int scope, |
| 963 |
struct berval *filter ) |
| 964 |
{ |
| 965 |
monitor_info_t *mi; |
| 966 |
struct berval ndn = BER_BVNULL; |
| 967 |
char *fname = ( a == NULL ? "callback" : "attrs" ); |
| 968 |
struct berval empty_bv = BER_BVC(""); |
| 969 |
|
| 970 |
if ( nbase == NULL ) nbase = &empty_bv; |
| 971 |
if ( filter == NULL ) filter = &empty_bv; |
| 972 |
|
| 973 |
if ( be_monitor == NULL ) { |
| 974 |
Debug(LDAP_DEBUG_ANY, |
| 975 |
"monitor_back_register_entry_%s(base=\"%s\" scope=%s filter=\"%s\"): " "monitor database not configured.\n\n", |
| 976 |
fname, BER_BVISNULL(nbase) ? "" : nbase->bv_val, |
| 977 |
ldap_pvt_scope2str(scope), |
| 978 |
BER_BVISNULL(filter) ? "" : filter->bv_val ); |
| 979 |
|
| 980 |
return -1; |
| 981 |
} |
| 982 |
|
| 983 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 984 |
|
| 985 |
assert( mi != NULL ); |
| 986 |
|
| 987 |
if ( ndn_in != NULL ) { |
| 988 |
ndn = *ndn_in; |
| 989 |
} |
| 990 |
|
| 991 |
if ( a == NULL && cb == NULL ) { |
| 992 |
/* nothing to do */ |
| 993 |
return -1; |
| 994 |
} |
| 995 |
|
| 996 |
if ( ( ndn_in == NULL || BER_BVISNULL( &ndn ) ) |
| 997 |
&& BER_BVISNULL( filter ) ) |
| 998 |
{ |
| 999 |
/* need a filter */ |
| 1000 |
Debug( LDAP_DEBUG_ANY, |
| 1001 |
"monitor_back_register_entry_%s(\"\"): " |
| 1002 |
"need a valid filter\n", |
| 1003 |
fname ); |
| 1004 |
return -1; |
| 1005 |
} |
| 1006 |
|
| 1007 |
if ( monitor_subsys_is_opened() ) { |
| 1008 |
Entry *e = NULL; |
| 1009 |
Attribute **atp = NULL; |
| 1010 |
monitor_entry_t *mp = NULL; |
| 1011 |
monitor_callback_t **mcp = NULL; |
| 1012 |
int rc = 0; |
| 1013 |
int freeit = 0; |
| 1014 |
|
| 1015 |
if ( BER_BVISNULL( &ndn ) ) { |
| 1016 |
if ( monitor_search2ndn( nbase, scope, filter, &ndn ) ) { |
| 1017 |
Debug(LDAP_DEBUG_ANY, |
| 1018 |
"monitor_back_register_entry_%s(\"\"): " "base=\"%s\" scope=%s filter=\"%s\": " "unable to find entry\n\n", |
| 1019 |
fname, |
| 1020 |
nbase->bv_val ? nbase->bv_val : "\"\"", |
| 1021 |
ldap_pvt_scope2str(scope), |
| 1022 |
filter->bv_val ); |
| 1023 |
return -1; |
| 1024 |
} |
| 1025 |
|
| 1026 |
freeit = 1; |
| 1027 |
} |
| 1028 |
|
| 1029 |
if ( monitor_cache_get( mi, &ndn, &e ) != 0 ) { |
| 1030 |
/* entry does not exist */ |
| 1031 |
Debug( LDAP_DEBUG_ANY, |
| 1032 |
"monitor_back_register_entry_%s(\"%s\"): " |
| 1033 |
"entry does not exist\n", |
| 1034 |
fname, ndn.bv_val ); |
| 1035 |
rc = -1; |
| 1036 |
goto done; |
| 1037 |
} |
| 1038 |
|
| 1039 |
assert( e->e_private != NULL ); |
| 1040 |
mp = ( monitor_entry_t * )e->e_private; |
| 1041 |
|
| 1042 |
if ( mp->mp_flags & MONITOR_F_VOLATILE ) { |
| 1043 |
/* entry is volatile; cannot append callback */ |
| 1044 |
Debug( LDAP_DEBUG_ANY, |
| 1045 |
"monitor_back_register_entry_%s(\"%s\"): " |
| 1046 |
"entry is volatile\n", |
| 1047 |
fname, e->e_name.bv_val ); |
| 1048 |
rc = -1; |
| 1049 |
goto done; |
| 1050 |
} |
| 1051 |
|
| 1052 |
if ( a ) { |
| 1053 |
for ( atp = &e->e_attrs; *atp; atp = &(*atp)->a_next ) |
| 1054 |
/* just get to last */ ; |
| 1055 |
|
| 1056 |
for ( ; a != NULL; a = a->a_next ) { |
| 1057 |
assert( a->a_desc != NULL ); |
| 1058 |
assert( a->a_vals != NULL ); |
| 1059 |
|
| 1060 |
if ( attr_find( e->e_attrs, a->a_desc ) ) { |
| 1061 |
attr_merge( e, a->a_desc, a->a_vals, |
| 1062 |
a->a_nvals == a->a_vals ? NULL : a->a_nvals ); |
| 1063 |
|
| 1064 |
} else { |
| 1065 |
*atp = attr_dup( a ); |
| 1066 |
if ( *atp == NULL ) { |
| 1067 |
Debug( LDAP_DEBUG_ANY, |
| 1068 |
"monitor_back_register_entry_%s(\"%s\"): " |
| 1069 |
"attr_dup() failed\n", |
| 1070 |
fname, e->e_name.bv_val ); |
| 1071 |
rc = -1; |
| 1072 |
goto done; |
| 1073 |
} |
| 1074 |
atp = &(*atp)->a_next; |
| 1075 |
} |
| 1076 |
} |
| 1077 |
} |
| 1078 |
|
| 1079 |
if ( cb ) { |
| 1080 |
for ( mcp = &mp->mp_cb; *mcp; mcp = &(*mcp)->mc_next ) |
| 1081 |
/* go to tail */ ; |
| 1082 |
|
| 1083 |
/* NOTE: we do not clear cb->mc_next, so this function |
| 1084 |
* can be used to append a list of callbacks */ |
| 1085 |
(*mcp) = cb; |
| 1086 |
} |
| 1087 |
|
| 1088 |
done:; |
| 1089 |
if ( rc ) { |
| 1090 |
if ( atp && *atp ) { |
| 1091 |
attrs_free( *atp ); |
| 1092 |
*atp = NULL; |
| 1093 |
} |
| 1094 |
} |
| 1095 |
|
| 1096 |
if ( freeit ) { |
| 1097 |
ber_memfree( ndn.bv_val ); |
| 1098 |
} |
| 1099 |
|
| 1100 |
if ( e ) { |
| 1101 |
monitor_cache_release( mi, e ); |
| 1102 |
} |
| 1103 |
|
| 1104 |
} else { |
| 1105 |
entry_limbo_t **elpp, el = { 0 }; |
| 1106 |
|
| 1107 |
el.el_type = LIMBO_ATTRS; |
| 1108 |
el.el_ndn = ndn_in; |
| 1109 |
if ( !BER_BVISNULL( nbase ) ) { |
| 1110 |
ber_dupbv( &el.el_nbase, nbase); |
| 1111 |
} |
| 1112 |
el.el_scope = scope; |
| 1113 |
if ( !BER_BVISNULL( filter ) ) { |
| 1114 |
ber_dupbv( &el.el_filter, filter ); |
| 1115 |
} |
| 1116 |
|
| 1117 |
el.el_a = attrs_dup( a ); |
| 1118 |
el.el_cb = cb; |
| 1119 |
|
| 1120 |
for ( elpp = &mi->mi_entry_limbo; |
| 1121 |
*elpp; |
| 1122 |
elpp = &(*elpp)->el_next ) |
| 1123 |
/* go to last */; |
| 1124 |
|
| 1125 |
*elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) ); |
| 1126 |
if ( *elpp == NULL ) { |
| 1127 |
if ( !BER_BVISNULL( &el.el_filter ) ) { |
| 1128 |
ch_free( el.el_filter.bv_val ); |
| 1129 |
} |
| 1130 |
if ( el.el_a != NULL ) { |
| 1131 |
attrs_free( el.el_a ); |
| 1132 |
} |
| 1133 |
if ( !BER_BVISNULL( &el.el_nbase ) ) { |
| 1134 |
ch_free( &el.el_nbase.bv_val ); |
| 1135 |
} |
| 1136 |
return -1; |
| 1137 |
} |
| 1138 |
|
| 1139 |
el.el_next = NULL; |
| 1140 |
**elpp = el; |
| 1141 |
} |
| 1142 |
|
| 1143 |
return 0; |
| 1144 |
} |
| 1145 |
|
| 1146 |
int |
| 1147 |
monitor_back_register_entry_callback( |
| 1148 |
struct berval *ndn, |
| 1149 |
monitor_callback_t *cb, |
| 1150 |
struct berval *nbase, |
| 1151 |
int scope, |
| 1152 |
struct berval *filter ) |
| 1153 |
{ |
| 1154 |
return monitor_back_register_entry_attrs( ndn, NULL, cb, |
| 1155 |
nbase, scope, filter ); |
| 1156 |
} |
| 1157 |
|
| 1158 |
/* |
| 1159 |
* TODO: add corresponding calls to remove installed callbacks, entries |
| 1160 |
* and so, in case the entity that installed them is removed (e.g. a |
| 1161 |
* database, via back-config) |
| 1162 |
*/ |
| 1163 |
int |
| 1164 |
monitor_back_unregister_entry( |
| 1165 |
struct berval *ndn ) |
| 1166 |
{ |
| 1167 |
monitor_info_t *mi; |
| 1168 |
|
| 1169 |
if ( be_monitor == NULL ) { |
| 1170 |
Debug( LDAP_DEBUG_ANY, |
| 1171 |
"monitor_back_unregister_entry(\"%s\"): " |
| 1172 |
"monitor database not configured.\n", |
| 1173 |
ndn->bv_val ); |
| 1174 |
|
| 1175 |
return -1; |
| 1176 |
} |
| 1177 |
|
| 1178 |
/* entry will be regularly freed, and resources released |
| 1179 |
* according to callbacks */ |
| 1180 |
if ( slapd_shutdown ) { |
| 1181 |
return 0; |
| 1182 |
} |
| 1183 |
|
| 1184 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 1185 |
|
| 1186 |
assert( mi != NULL ); |
| 1187 |
|
| 1188 |
if ( monitor_subsys_is_opened() ) { |
| 1189 |
Entry *e = NULL; |
| 1190 |
monitor_entry_t *mp = NULL; |
| 1191 |
monitor_callback_t *cb = NULL; |
| 1192 |
|
| 1193 |
if ( monitor_cache_remove( mi, ndn, &e ) != 0 ) { |
| 1194 |
/* entry does not exist */ |
| 1195 |
Debug( LDAP_DEBUG_ANY, |
| 1196 |
"monitor_back_unregister_entry(\"%s\"): " |
| 1197 |
"entry removal failed.\n", |
| 1198 |
ndn->bv_val ); |
| 1199 |
return -1; |
| 1200 |
} |
| 1201 |
|
| 1202 |
mp = (monitor_entry_t *)e->e_private; |
| 1203 |
assert( mp != NULL ); |
| 1204 |
|
| 1205 |
for ( cb = mp->mp_cb; cb != NULL; ) { |
| 1206 |
monitor_callback_t *next = cb->mc_next; |
| 1207 |
|
| 1208 |
if ( cb->mc_free ) { |
| 1209 |
(void)cb->mc_free( e, &cb->mc_private ); |
| 1210 |
} |
| 1211 |
ch_free( cb ); |
| 1212 |
|
| 1213 |
cb = next; |
| 1214 |
} |
| 1215 |
|
| 1216 |
ch_free( mp ); |
| 1217 |
e->e_private = NULL; |
| 1218 |
entry_free( e ); |
| 1219 |
|
| 1220 |
} else { |
| 1221 |
entry_limbo_t **elpp; |
| 1222 |
|
| 1223 |
for ( elpp = &mi->mi_entry_limbo; |
| 1224 |
*elpp; |
| 1225 |
elpp = &(*elpp)->el_next ) |
| 1226 |
{ |
| 1227 |
entry_limbo_t *elp = *elpp; |
| 1228 |
|
| 1229 |
if ( elp->el_type == LIMBO_ENTRY |
| 1230 |
&& dn_match( ndn, &elp->el_e->e_nname ) ) |
| 1231 |
{ |
| 1232 |
monitor_callback_t *cb, *next; |
| 1233 |
|
| 1234 |
for ( cb = elp->el_cb; cb; cb = next ) { |
| 1235 |
/* FIXME: call callbacks? */ |
| 1236 |
next = cb->mc_next; |
| 1237 |
if ( cb->mc_dispose ) { |
| 1238 |
cb->mc_dispose( &cb->mc_private ); |
| 1239 |
} |
| 1240 |
ch_free( cb ); |
| 1241 |
} |
| 1242 |
assert( elp->el_e != NULL ); |
| 1243 |
elp->el_e->e_private = NULL; |
| 1244 |
entry_free( elp->el_e ); |
| 1245 |
*elpp = elp->el_next; |
| 1246 |
ch_free( elp ); |
| 1247 |
elpp = NULL; |
| 1248 |
break; |
| 1249 |
} |
| 1250 |
} |
| 1251 |
|
| 1252 |
if ( elpp != NULL ) { |
| 1253 |
/* not found! where did it go? */ |
| 1254 |
return 1; |
| 1255 |
} |
| 1256 |
} |
| 1257 |
|
| 1258 |
return 0; |
| 1259 |
} |
| 1260 |
|
| 1261 |
int |
| 1262 |
monitor_back_unregister_entry_parent( |
| 1263 |
struct berval *nrdn, |
| 1264 |
monitor_callback_t *target_cb, |
| 1265 |
struct berval *nbase, |
| 1266 |
int scope, |
| 1267 |
struct berval *filter ) |
| 1268 |
{ |
| 1269 |
monitor_info_t *mi; |
| 1270 |
struct berval ndn = BER_BVNULL; |
| 1271 |
|
| 1272 |
if ( be_monitor == NULL ) { |
| 1273 |
Debug( LDAP_DEBUG_ANY, |
| 1274 |
"monitor_back_unregister_entry_parent(base=\"%s\" scope=%s filter=\"%s\"): " |
| 1275 |
"monitor database not configured.\n", |
| 1276 |
BER_BVISNULL( nbase ) ? "" : nbase->bv_val, |
| 1277 |
ldap_pvt_scope2str( scope ), |
| 1278 |
BER_BVISNULL( filter ) ? "" : filter->bv_val ); |
| 1279 |
|
| 1280 |
return -1; |
| 1281 |
} |
| 1282 |
|
| 1283 |
/* entry will be regularly freed, and resources released |
| 1284 |
* according to callbacks */ |
| 1285 |
if ( slapd_shutdown ) { |
| 1286 |
return 0; |
| 1287 |
} |
| 1288 |
|
| 1289 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 1290 |
|
| 1291 |
assert( mi != NULL ); |
| 1292 |
|
| 1293 |
if ( ( nrdn == NULL || BER_BVISNULL( nrdn ) ) |
| 1294 |
&& BER_BVISNULL( filter ) ) |
| 1295 |
{ |
| 1296 |
/* need a filter */ |
| 1297 |
Debug( LDAP_DEBUG_ANY, |
| 1298 |
"monitor_back_unregister_entry_parent(\"\"): " |
| 1299 |
"need a valid filter\n" ); |
| 1300 |
return -1; |
| 1301 |
} |
| 1302 |
|
| 1303 |
if ( monitor_subsys_is_opened() ) { |
| 1304 |
Entry *e = NULL; |
| 1305 |
monitor_entry_t *mp = NULL; |
| 1306 |
|
| 1307 |
if ( monitor_search2ndn( nbase, scope, filter, &ndn ) ) { |
| 1308 |
/* entry does not exist */ |
| 1309 |
Debug( LDAP_DEBUG_ANY, |
| 1310 |
"monitor_back_unregister_entry_parent(\"\"): " |
| 1311 |
"base=\"%s\" scope=%s filter=\"%s\": " |
| 1312 |
"unable to find entry\n", |
| 1313 |
nbase->bv_val ? nbase->bv_val : "\"\"", |
| 1314 |
ldap_pvt_scope2str( scope ), |
| 1315 |
filter->bv_val ); |
| 1316 |
return -1; |
| 1317 |
} |
| 1318 |
|
| 1319 |
if ( monitor_cache_remove( mi, &ndn, &e ) != 0 ) { |
| 1320 |
/* entry does not exist */ |
| 1321 |
Debug( LDAP_DEBUG_ANY, |
| 1322 |
"monitor_back_unregister_entry(\"%s\"): " |
| 1323 |
"entry removal failed.\n", |
| 1324 |
ndn.bv_val ); |
| 1325 |
ber_memfree( ndn.bv_val ); |
| 1326 |
return -1; |
| 1327 |
} |
| 1328 |
ber_memfree( ndn.bv_val ); |
| 1329 |
|
| 1330 |
mp = (monitor_entry_t *)e->e_private; |
| 1331 |
assert( mp != NULL ); |
| 1332 |
|
| 1333 |
if ( target_cb != NULL ) { |
| 1334 |
monitor_callback_t **cbp; |
| 1335 |
|
| 1336 |
for ( cbp = &mp->mp_cb; *cbp != NULL; cbp = &(*cbp)->mc_next ) { |
| 1337 |
if ( *cbp == target_cb ) { |
| 1338 |
if ( (*cbp)->mc_free ) { |
| 1339 |
(void)(*cbp)->mc_free( e, &(*cbp)->mc_private ); |
| 1340 |
} |
| 1341 |
*cbp = (*cbp)->mc_next; |
| 1342 |
ch_free( target_cb ); |
| 1343 |
break; |
| 1344 |
} |
| 1345 |
} |
| 1346 |
} |
| 1347 |
|
| 1348 |
|
| 1349 |
ch_free( mp ); |
| 1350 |
e->e_private = NULL; |
| 1351 |
entry_free( e ); |
| 1352 |
|
| 1353 |
} else { |
| 1354 |
entry_limbo_t **elpp; |
| 1355 |
|
| 1356 |
for ( elpp = &mi->mi_entry_limbo; |
| 1357 |
*elpp; |
| 1358 |
elpp = &(*elpp)->el_next ) |
| 1359 |
{ |
| 1360 |
entry_limbo_t *elp = *elpp; |
| 1361 |
|
| 1362 |
if ( elp->el_type == LIMBO_ENTRY_PARENT |
| 1363 |
&& dn_match( nrdn, &elp->el_e->e_nname ) |
| 1364 |
&& dn_match( nbase, &elp->el_nbase ) |
| 1365 |
&& scope == elp->el_scope |
| 1366 |
&& bvmatch( filter, &elp->el_filter ) ) |
| 1367 |
{ |
| 1368 |
monitor_callback_t *cb, *next; |
| 1369 |
|
| 1370 |
for ( cb = elp->el_cb; cb; cb = next ) { |
| 1371 |
/* FIXME: call callbacks? */ |
| 1372 |
next = cb->mc_next; |
| 1373 |
if ( cb->mc_dispose ) { |
| 1374 |
cb->mc_dispose( &cb->mc_private ); |
| 1375 |
} |
| 1376 |
ch_free( cb ); |
| 1377 |
} |
| 1378 |
assert( elp->el_e != NULL ); |
| 1379 |
elp->el_e->e_private = NULL; |
| 1380 |
entry_free( elp->el_e ); |
| 1381 |
if ( !BER_BVISNULL( &elp->el_nbase ) ) { |
| 1382 |
ch_free( elp->el_nbase.bv_val ); |
| 1383 |
} |
| 1384 |
if ( !BER_BVISNULL( &elp->el_filter ) ) { |
| 1385 |
ch_free( elp->el_filter.bv_val ); |
| 1386 |
} |
| 1387 |
*elpp = elp->el_next; |
| 1388 |
ch_free( elp ); |
| 1389 |
elpp = NULL; |
| 1390 |
break; |
| 1391 |
} |
| 1392 |
} |
| 1393 |
|
| 1394 |
if ( elpp != NULL ) { |
| 1395 |
/* not found! where did it go? */ |
| 1396 |
return 1; |
| 1397 |
} |
| 1398 |
} |
| 1399 |
|
| 1400 |
return 0; |
| 1401 |
} |
| 1402 |
|
| 1403 |
int |
| 1404 |
monitor_back_unregister_entry_attrs( |
| 1405 |
struct berval *ndn_in, |
| 1406 |
Attribute *target_a, |
| 1407 |
monitor_callback_t *target_cb, |
| 1408 |
struct berval *nbase, |
| 1409 |
int scope, |
| 1410 |
struct berval *filter ) |
| 1411 |
{ |
| 1412 |
monitor_info_t *mi; |
| 1413 |
struct berval ndn = BER_BVNULL; |
| 1414 |
char *fname = ( target_a == NULL ? "callback" : "attrs" ); |
| 1415 |
|
| 1416 |
if ( be_monitor == NULL ) { |
| 1417 |
Debug(LDAP_DEBUG_ANY, |
| 1418 |
"monitor_back_unregister_entry_%s(base=\"%s\" scope=%s filter=\"%s\"): " "monitor database not configured.\n\n", |
| 1419 |
fname, BER_BVISNULL(nbase) ? "" : nbase->bv_val, |
| 1420 |
ldap_pvt_scope2str(scope), |
| 1421 |
BER_BVISNULL(filter) ? "" : filter->bv_val ); |
| 1422 |
|
| 1423 |
return -1; |
| 1424 |
} |
| 1425 |
|
| 1426 |
/* entry will be regularly freed, and resources released |
| 1427 |
* according to callbacks */ |
| 1428 |
if ( slapd_shutdown ) { |
| 1429 |
return 0; |
| 1430 |
} |
| 1431 |
|
| 1432 |
mi = ( monitor_info_t * )be_monitor->be_private; |
| 1433 |
|
| 1434 |
assert( mi != NULL ); |
| 1435 |
|
| 1436 |
if ( ndn_in != NULL ) { |
| 1437 |
ndn = *ndn_in; |
| 1438 |
} |
| 1439 |
|
| 1440 |
if ( target_a == NULL && target_cb == NULL ) { |
| 1441 |
/* nothing to do */ |
| 1442 |
return -1; |
| 1443 |
} |
| 1444 |
|
| 1445 |
if ( ( ndn_in == NULL || BER_BVISNULL( &ndn ) ) |
| 1446 |
&& BER_BVISNULL( filter ) ) |
| 1447 |
{ |
| 1448 |
/* need a filter */ |
| 1449 |
Debug( LDAP_DEBUG_ANY, |
| 1450 |
"monitor_back_unregister_entry_%s(\"\"): " |
| 1451 |
"need a valid filter\n", |
| 1452 |
fname ); |
| 1453 |
return -1; |
| 1454 |
} |
| 1455 |
|
| 1456 |
if ( monitor_subsys_is_opened() ) { |
| 1457 |
Entry *e = NULL; |
| 1458 |
monitor_entry_t *mp = NULL; |
| 1459 |
int freeit = 0; |
| 1460 |
|
| 1461 |
if ( BER_BVISNULL( &ndn ) ) { |
| 1462 |
if ( monitor_search2ndn( nbase, scope, filter, &ndn ) ) { |
| 1463 |
Debug(LDAP_DEBUG_ANY, |
| 1464 |
"monitor_back_unregister_entry_%s(\"\"): " "base=\"%s\" scope=%d filter=\"%s\": " "unable to find entry\n\n", |
| 1465 |
fname, |
| 1466 |
nbase->bv_val ? nbase->bv_val : "\"\"", |
| 1467 |
scope, filter->bv_val ); |
| 1468 |
return -1; |
| 1469 |
} |
| 1470 |
|
| 1471 |
freeit = 1; |
| 1472 |
} |
| 1473 |
|
| 1474 |
if ( monitor_cache_get( mi, &ndn, &e ) != 0 ) { |
| 1475 |
/* entry does not exist */ |
| 1476 |
Debug( LDAP_DEBUG_ANY, |
| 1477 |
"monitor_back_unregister_entry(\"%s\"): " |
| 1478 |
"entry removal failed.\n", |
| 1479 |
ndn.bv_val ); |
| 1480 |
return -1; |
| 1481 |
} |
| 1482 |
|
| 1483 |
mp = (monitor_entry_t *)e->e_private; |
| 1484 |
assert( mp != NULL ); |
| 1485 |
|
| 1486 |
if ( target_cb != NULL ) { |
| 1487 |
monitor_callback_t **cbp; |
| 1488 |
|
| 1489 |
for ( cbp = &mp->mp_cb; *cbp != NULL; cbp = &(*cbp)->mc_next ) { |
| 1490 |
if ( *cbp == target_cb ) { |
| 1491 |
if ( (*cbp)->mc_free ) { |
| 1492 |
(void)(*cbp)->mc_free( e, &(*cbp)->mc_private ); |
| 1493 |
} |
| 1494 |
*cbp = (*cbp)->mc_next; |
| 1495 |
ch_free( target_cb ); |
| 1496 |
break; |
| 1497 |
} |
| 1498 |
} |
| 1499 |
} |
| 1500 |
|
| 1501 |
if ( target_a != NULL ) { |
| 1502 |
Attribute *a; |
| 1503 |
|
| 1504 |
for ( a = target_a; a != NULL; a = a->a_next ) { |
| 1505 |
Modification mod = { 0 }; |
| 1506 |
const char *text; |
| 1507 |
char textbuf[ SLAP_TEXT_BUFLEN ]; |
| 1508 |
|
| 1509 |
mod.sm_op = LDAP_MOD_DELETE; |
| 1510 |
mod.sm_desc = a->a_desc; |
| 1511 |
mod.sm_values = a->a_vals; |
| 1512 |
mod.sm_nvalues = a->a_nvals; |
| 1513 |
|
| 1514 |
(void)modify_delete_values( e, &mod, 1, |
| 1515 |
&text, textbuf, sizeof( textbuf ) ); |
| 1516 |
} |
| 1517 |
} |
| 1518 |
|
| 1519 |
if ( freeit ) { |
| 1520 |
ber_memfree( ndn.bv_val ); |
| 1521 |
} |
| 1522 |
|
| 1523 |
monitor_cache_release( mi, e ); |
| 1524 |
|
| 1525 |
} else { |
| 1526 |
entry_limbo_t **elpp; |
| 1527 |
|
| 1528 |
for ( elpp = &mi->mi_entry_limbo; |
| 1529 |
*elpp; |
| 1530 |
elpp = &(*elpp)->el_next ) |
| 1531 |
{ |
| 1532 |
entry_limbo_t *elp = *elpp; |
| 1533 |
|
| 1534 |
if ( elp->el_type == LIMBO_ATTRS |
| 1535 |
&& dn_match( nbase, &elp->el_nbase ) |
| 1536 |
&& scope == elp->el_scope |
| 1537 |
&& bvmatch( filter, &elp->el_filter ) ) |
| 1538 |
{ |
| 1539 |
monitor_callback_t *cb, *next; |
| 1540 |
|
| 1541 |
for ( cb = elp->el_cb; cb; cb = next ) { |
| 1542 |
/* FIXME: call callbacks? */ |
| 1543 |
next = cb->mc_next; |
| 1544 |
if ( cb->mc_dispose ) { |
| 1545 |
cb->mc_dispose( &cb->mc_private ); |
| 1546 |
} |
| 1547 |
ch_free( cb ); |
| 1548 |
} |
| 1549 |
assert( elp->el_e == NULL ); |
| 1550 |
if ( elp->el_a != NULL ) { |
| 1551 |
attrs_free( elp->el_a ); |
| 1552 |
} |
| 1553 |
if ( !BER_BVISNULL( &elp->el_nbase ) ) { |
| 1554 |
ch_free( elp->el_nbase.bv_val ); |
| 1555 |
} |
| 1556 |
if ( !BER_BVISNULL( &elp->el_filter ) ) { |
| 1557 |
ch_free( elp->el_filter.bv_val ); |
| 1558 |
} |
| 1559 |
*elpp = elp->el_next; |
| 1560 |
ch_free( elp ); |
| 1561 |
elpp = NULL; |
| 1562 |
break; |
| 1563 |
} |
| 1564 |
} |
| 1565 |
|
| 1566 |
if ( elpp != NULL ) { |
| 1567 |
/* not found! where did it go? */ |
| 1568 |
return 1; |
| 1569 |
} |
| 1570 |
} |
| 1571 |
|
| 1572 |
return 0; |
| 1573 |
} |
| 1574 |
|
| 1575 |
int |
| 1576 |
monitor_back_unregister_entry_callback( |
| 1577 |
struct berval *ndn, |
| 1578 |
monitor_callback_t *cb, |
| 1579 |
struct berval *nbase, |
| 1580 |
int scope, |
| 1581 |
struct berval *filter ) |
| 1582 |
{ |
| 1583 |
/* TODO: lookup entry (by ndn, if not NULL, and/or by callback); |
| 1584 |
* unregister the callback; if a is not null, unregister the |
| 1585 |
* given attrs. In any case, call cb->cb_free */ |
| 1586 |
return monitor_back_unregister_entry_attrs( ndn, |
| 1587 |
NULL, cb, nbase, scope, filter ); |
| 1588 |
} |
| 1589 |
|
| 1590 |
monitor_subsys_t * |
| 1591 |
monitor_back_get_subsys( const char *name ) |
| 1592 |
{ |
| 1593 |
if ( monitor_subsys != NULL ) { |
| 1594 |
int i; |
| 1595 |
|
| 1596 |
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) { |
| 1597 |
if ( strcasecmp( monitor_subsys[ i ]->mss_name, name ) == 0 ) { |
| 1598 |
return monitor_subsys[ i ]; |
| 1599 |
} |
| 1600 |
} |
| 1601 |
} |
| 1602 |
|
| 1603 |
return NULL; |
| 1604 |
} |
| 1605 |
|
| 1606 |
monitor_subsys_t * |
| 1607 |
monitor_back_get_subsys_by_dn( |
| 1608 |
struct berval *ndn, |
| 1609 |
int sub ) |
| 1610 |
{ |
| 1611 |
if ( monitor_subsys != NULL ) { |
| 1612 |
int i; |
| 1613 |
|
| 1614 |
if ( sub ) { |
| 1615 |
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) { |
| 1616 |
if ( dnIsSuffix( ndn, &monitor_subsys[ i ]->mss_ndn ) ) { |
| 1617 |
return monitor_subsys[ i ]; |
| 1618 |
} |
| 1619 |
} |
| 1620 |
|
| 1621 |
} else { |
| 1622 |
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) { |
| 1623 |
if ( dn_match( ndn, &monitor_subsys[ i ]->mss_ndn ) ) { |
| 1624 |
return monitor_subsys[ i ]; |
| 1625 |
} |
| 1626 |
} |
| 1627 |
} |
| 1628 |
} |
| 1629 |
|
| 1630 |
return NULL; |
| 1631 |
} |
| 1632 |
|
| 1633 |
int |
| 1634 |
monitor_back_initialize( |
| 1635 |
BackendInfo *bi ) |
| 1636 |
{ |
| 1637 |
static char *controls[] = { |
| 1638 |
LDAP_CONTROL_MANAGEDSAIT, |
| 1639 |
NULL |
| 1640 |
}; |
| 1641 |
|
| 1642 |
static ConfigTable monitorcfg[] = { |
| 1643 |
{ NULL, NULL, 0, 0, 0, ARG_IGNORED, |
| 1644 |
NULL, NULL, NULL, NULL } |
| 1645 |
}; |
| 1646 |
|
| 1647 |
static ConfigOCs monitorocs[] = { |
| 1648 |
{ "( OLcfgDbOc:4.1 " |
| 1649 |
"NAME 'olcMonitorConfig' " |
| 1650 |
"DESC 'Monitor backend configuration' " |
| 1651 |
"SUP olcDatabaseConfig " |
| 1652 |
")", |
| 1653 |
Cft_Database, monitorcfg }, |
| 1654 |
{ NULL, 0, NULL } |
| 1655 |
}; |
| 1656 |
|
| 1657 |
struct m_s { |
| 1658 |
char *schema; |
| 1659 |
slap_mask_t flags; |
| 1660 |
int offset; |
| 1661 |
} moc[] = { |
| 1662 |
{ "( 1.3.6.1.4.1.4203.666.3.16.1 " |
| 1663 |
"NAME 'monitor' " |
| 1664 |
"DESC 'OpenLDAP system monitoring' " |
| 1665 |
"SUP top STRUCTURAL " |
| 1666 |
"MUST cn " |
| 1667 |
"MAY ( " |
| 1668 |
"description " |
| 1669 |
"$ seeAlso " |
| 1670 |
"$ labeledURI " |
| 1671 |
"$ monitoredInfo " |
| 1672 |
"$ managedInfo " |
| 1673 |
"$ monitorOverlay " |
| 1674 |
") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, |
| 1675 |
offsetof(monitor_info_t, mi_oc_monitor) }, |
| 1676 |
{ "( 1.3.6.1.4.1.4203.666.3.16.2 " |
| 1677 |
"NAME 'monitorServer' " |
| 1678 |
"DESC 'Server monitoring root entry' " |
| 1679 |
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, |
| 1680 |
offsetof(monitor_info_t, mi_oc_monitorServer) }, |
| 1681 |
{ "( 1.3.6.1.4.1.4203.666.3.16.3 " |
| 1682 |
"NAME 'monitorContainer' " |
| 1683 |
"DESC 'monitor container class' " |
| 1684 |
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, |
| 1685 |
offsetof(monitor_info_t, mi_oc_monitorContainer) }, |
| 1686 |
{ "( 1.3.6.1.4.1.4203.666.3.16.4 " |
| 1687 |
"NAME 'monitorCounterObject' " |
| 1688 |
"DESC 'monitor counter class' " |
| 1689 |
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, |
| 1690 |
offsetof(monitor_info_t, mi_oc_monitorCounterObject) }, |
| 1691 |
{ "( 1.3.6.1.4.1.4203.666.3.16.5 " |
| 1692 |
"NAME 'monitorOperation' " |
| 1693 |
"DESC 'monitor operation class' " |
| 1694 |
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, |
| 1695 |
offsetof(monitor_info_t, mi_oc_monitorOperation) }, |
| 1696 |
{ "( 1.3.6.1.4.1.4203.666.3.16.6 " |
| 1697 |
"NAME 'monitorConnection' " |
| 1698 |
"DESC 'monitor connection class' " |
| 1699 |
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, |
| 1700 |
offsetof(monitor_info_t, mi_oc_monitorConnection) }, |
| 1701 |
{ "( 1.3.6.1.4.1.4203.666.3.16.7 " |
| 1702 |
"NAME 'managedObject' " |
| 1703 |
"DESC 'monitor managed entity class' " |
| 1704 |
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, |
| 1705 |
offsetof(monitor_info_t, mi_oc_managedObject) }, |
| 1706 |
{ "( 1.3.6.1.4.1.4203.666.3.16.8 " |
| 1707 |
"NAME 'monitoredObject' " |
| 1708 |
"DESC 'monitor monitored entity class' " |
| 1709 |
"SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, |
| 1710 |
offsetof(monitor_info_t, mi_oc_monitoredObject) }, |
| 1711 |
{ NULL, 0, -1 } |
| 1712 |
}, mat[] = { |
| 1713 |
{ "( 1.3.6.1.4.1.4203.666.1.55.1 " |
| 1714 |
"NAME 'monitoredInfo' " |
| 1715 |
"DESC 'monitored info' " |
| 1716 |
/* "SUP name " */ |
| 1717 |
"EQUALITY caseIgnoreMatch " |
| 1718 |
"SUBSTR caseIgnoreSubstringsMatch " |
| 1719 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} " |
| 1720 |
"NO-USER-MODIFICATION " |
| 1721 |
"USAGE dSAOperation )", SLAP_AT_HIDE, |
| 1722 |
offsetof(monitor_info_t, mi_ad_monitoredInfo) }, |
| 1723 |
{ "( 1.3.6.1.4.1.4203.666.1.55.2 " |
| 1724 |
"NAME 'managedInfo' " |
| 1725 |
"DESC 'monitor managed info' " |
| 1726 |
"SUP name )", SLAP_AT_HIDE, |
| 1727 |
offsetof(monitor_info_t, mi_ad_managedInfo) }, |
| 1728 |
{ "( 1.3.6.1.4.1.4203.666.1.55.3 " |
| 1729 |
"NAME 'monitorCounter' " |
| 1730 |
"DESC 'monitor counter' " |
| 1731 |
"EQUALITY integerMatch " |
| 1732 |
"ORDERING integerOrderingMatch " |
| 1733 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 " |
| 1734 |
"NO-USER-MODIFICATION " |
| 1735 |
"USAGE dSAOperation )", SLAP_AT_HIDE, |
| 1736 |
offsetof(monitor_info_t, mi_ad_monitorCounter) }, |
| 1737 |
{ "( 1.3.6.1.4.1.4203.666.1.55.4 " |
| 1738 |
"NAME 'monitorOpCompleted' " |
| 1739 |
"DESC 'monitor completed operations' " |
| 1740 |
"SUP monitorCounter " |
| 1741 |
"NO-USER-MODIFICATION " |
| 1742 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1743 |
offsetof(monitor_info_t, mi_ad_monitorOpCompleted) }, |
| 1744 |
{ "( 1.3.6.1.4.1.4203.666.1.55.5 " |
| 1745 |
"NAME 'monitorOpInitiated' " |
| 1746 |
"DESC 'monitor initiated operations' " |
| 1747 |
"SUP monitorCounter " |
| 1748 |
"NO-USER-MODIFICATION " |
| 1749 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1750 |
offsetof(monitor_info_t, mi_ad_monitorOpInitiated) }, |
| 1751 |
{ "( 1.3.6.1.4.1.4203.666.1.55.6 " |
| 1752 |
"NAME 'monitorConnectionNumber' " |
| 1753 |
"DESC 'monitor connection number' " |
| 1754 |
"SUP monitorCounter " |
| 1755 |
"NO-USER-MODIFICATION " |
| 1756 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1757 |
offsetof(monitor_info_t, mi_ad_monitorConnectionNumber) }, |
| 1758 |
{ "( 1.3.6.1.4.1.4203.666.1.55.7 " |
| 1759 |
"NAME 'monitorConnectionAuthzDN' " |
| 1760 |
"DESC 'monitor connection authorization DN' " |
| 1761 |
/* "SUP distinguishedName " */ |
| 1762 |
"EQUALITY distinguishedNameMatch " |
| 1763 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 " |
| 1764 |
"NO-USER-MODIFICATION " |
| 1765 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1766 |
offsetof(monitor_info_t, mi_ad_monitorConnectionAuthzDN) }, |
| 1767 |
{ "( 1.3.6.1.4.1.4203.666.1.55.8 " |
| 1768 |
"NAME 'monitorConnectionLocalAddress' " |
| 1769 |
"DESC 'monitor connection local address' " |
| 1770 |
"SUP monitoredInfo " |
| 1771 |
"NO-USER-MODIFICATION " |
| 1772 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1773 |
offsetof(monitor_info_t, mi_ad_monitorConnectionLocalAddress) }, |
| 1774 |
{ "( 1.3.6.1.4.1.4203.666.1.55.9 " |
| 1775 |
"NAME 'monitorConnectionPeerAddress' " |
| 1776 |
"DESC 'monitor connection peer address' " |
| 1777 |
"SUP monitoredInfo " |
| 1778 |
"NO-USER-MODIFICATION " |
| 1779 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1780 |
offsetof(monitor_info_t, mi_ad_monitorConnectionPeerAddress) }, |
| 1781 |
{ "( 1.3.6.1.4.1.4203.666.1.55.10 " |
| 1782 |
"NAME 'monitorTimestamp' " |
| 1783 |
"DESC 'monitor timestamp' " |
| 1784 |
"EQUALITY generalizedTimeMatch " |
| 1785 |
"ORDERING generalizedTimeOrderingMatch " |
| 1786 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 " |
| 1787 |
"SINGLE-VALUE " |
| 1788 |
"NO-USER-MODIFICATION " |
| 1789 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1790 |
offsetof(monitor_info_t, mi_ad_monitorTimestamp) }, |
| 1791 |
{ "( 1.3.6.1.4.1.4203.666.1.55.11 " |
| 1792 |
"NAME 'monitorOverlay' " |
| 1793 |
"DESC 'name of overlays defined for a given database' " |
| 1794 |
"SUP monitoredInfo " |
| 1795 |
"NO-USER-MODIFICATION " |
| 1796 |
"USAGE dSAOperation )", SLAP_AT_HIDE, |
| 1797 |
offsetof(monitor_info_t, mi_ad_monitorOverlay) }, |
| 1798 |
{ "( 1.3.6.1.4.1.4203.666.1.55.12 " |
| 1799 |
"NAME 'readOnly' " |
| 1800 |
"DESC 'read/write status of a given database' " |
| 1801 |
"EQUALITY booleanMatch " |
| 1802 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 " |
| 1803 |
"SINGLE-VALUE " |
| 1804 |
"USAGE dSAOperation )", SLAP_AT_HIDE, |
| 1805 |
offsetof(monitor_info_t, mi_ad_readOnly) }, |
| 1806 |
{ "( 1.3.6.1.4.1.4203.666.1.55.13 " |
| 1807 |
"NAME 'restrictedOperation' " |
| 1808 |
"DESC 'name of restricted operation for a given database' " |
| 1809 |
"SUP managedInfo )", SLAP_AT_HIDE, |
| 1810 |
offsetof(monitor_info_t, mi_ad_restrictedOperation ) }, |
| 1811 |
{ "( 1.3.6.1.4.1.4203.666.1.55.14 " |
| 1812 |
"NAME 'monitorConnectionProtocol' " |
| 1813 |
"DESC 'monitor connection protocol' " |
| 1814 |
"SUP monitoredInfo " |
| 1815 |
"NO-USER-MODIFICATION " |
| 1816 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1817 |
offsetof(monitor_info_t, mi_ad_monitorConnectionProtocol) }, |
| 1818 |
{ "( 1.3.6.1.4.1.4203.666.1.55.15 " |
| 1819 |
"NAME 'monitorConnectionOpsReceived' " |
| 1820 |
"DESC 'monitor number of operations received by the connection' " |
| 1821 |
"SUP monitorCounter " |
| 1822 |
"NO-USER-MODIFICATION " |
| 1823 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1824 |
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsReceived) }, |
| 1825 |
{ "( 1.3.6.1.4.1.4203.666.1.55.16 " |
| 1826 |
"NAME 'monitorConnectionOpsExecuting' " |
| 1827 |
"DESC 'monitor number of operations in execution within the connection' " |
| 1828 |
"SUP monitorCounter " |
| 1829 |
"NO-USER-MODIFICATION " |
| 1830 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1831 |
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsExecuting) }, |
| 1832 |
{ "( 1.3.6.1.4.1.4203.666.1.55.17 " |
| 1833 |
"NAME 'monitorConnectionOpsPending' " |
| 1834 |
"DESC 'monitor number of pending operations within the connection' " |
| 1835 |
"SUP monitorCounter " |
| 1836 |
"NO-USER-MODIFICATION " |
| 1837 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1838 |
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsPending) }, |
| 1839 |
{ "( 1.3.6.1.4.1.4203.666.1.55.18 " |
| 1840 |
"NAME 'monitorConnectionOpsCompleted' " |
| 1841 |
"DESC 'monitor number of operations completed within the connection' " |
| 1842 |
"SUP monitorCounter " |
| 1843 |
"NO-USER-MODIFICATION " |
| 1844 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1845 |
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsCompleted) }, |
| 1846 |
{ "( 1.3.6.1.4.1.4203.666.1.55.19 " |
| 1847 |
"NAME 'monitorConnectionGet' " |
| 1848 |
"DESC 'number of times connection_get() was called so far' " |
| 1849 |
"SUP monitorCounter " |
| 1850 |
"NO-USER-MODIFICATION " |
| 1851 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1852 |
offsetof(monitor_info_t, mi_ad_monitorConnectionGet) }, |
| 1853 |
{ "( 1.3.6.1.4.1.4203.666.1.55.20 " |
| 1854 |
"NAME 'monitorConnectionRead' " |
| 1855 |
"DESC 'number of times connection_read() was called so far' " |
| 1856 |
"SUP monitorCounter " |
| 1857 |
"NO-USER-MODIFICATION " |
| 1858 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1859 |
offsetof(monitor_info_t, mi_ad_monitorConnectionRead) }, |
| 1860 |
{ "( 1.3.6.1.4.1.4203.666.1.55.21 " |
| 1861 |
"NAME 'monitorConnectionWrite' " |
| 1862 |
"DESC 'number of times connection_write() was called so far' " |
| 1863 |
"SUP monitorCounter " |
| 1864 |
"NO-USER-MODIFICATION " |
| 1865 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1866 |
offsetof(monitor_info_t, mi_ad_monitorConnectionWrite) }, |
| 1867 |
{ "( 1.3.6.1.4.1.4203.666.1.55.22 " |
| 1868 |
"NAME 'monitorConnectionMask' " |
| 1869 |
"DESC 'monitor connection mask' " |
| 1870 |
"SUP monitoredInfo " |
| 1871 |
"NO-USER-MODIFICATION " |
| 1872 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1873 |
offsetof(monitor_info_t, mi_ad_monitorConnectionMask) }, |
| 1874 |
{ "( 1.3.6.1.4.1.4203.666.1.55.23 " |
| 1875 |
"NAME 'monitorConnectionListener' " |
| 1876 |
"DESC 'monitor connection listener' " |
| 1877 |
"SUP monitoredInfo " |
| 1878 |
"NO-USER-MODIFICATION " |
| 1879 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1880 |
offsetof(monitor_info_t, mi_ad_monitorConnectionListener) }, |
| 1881 |
{ "( 1.3.6.1.4.1.4203.666.1.55.24 " |
| 1882 |
"NAME 'monitorConnectionPeerDomain' " |
| 1883 |
"DESC 'monitor connection peer domain' " |
| 1884 |
"SUP monitoredInfo " |
| 1885 |
"NO-USER-MODIFICATION " |
| 1886 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1887 |
offsetof(monitor_info_t, mi_ad_monitorConnectionPeerDomain) }, |
| 1888 |
{ "( 1.3.6.1.4.1.4203.666.1.55.25 " |
| 1889 |
"NAME 'monitorConnectionStartTime' " |
| 1890 |
"DESC 'monitor connection start time' " |
| 1891 |
"SUP monitorTimestamp " |
| 1892 |
"SINGLE-VALUE " |
| 1893 |
"NO-USER-MODIFICATION " |
| 1894 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1895 |
offsetof(monitor_info_t, mi_ad_monitorConnectionStartTime) }, |
| 1896 |
{ "( 1.3.6.1.4.1.4203.666.1.55.26 " |
| 1897 |
"NAME 'monitorConnectionActivityTime' " |
| 1898 |
"DESC 'monitor connection activity time' " |
| 1899 |
"SUP monitorTimestamp " |
| 1900 |
"SINGLE-VALUE " |
| 1901 |
"NO-USER-MODIFICATION " |
| 1902 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1903 |
offsetof(monitor_info_t, mi_ad_monitorConnectionActivityTime) }, |
| 1904 |
{ "( 1.3.6.1.4.1.4203.666.1.55.27 " |
| 1905 |
"NAME 'monitorIsShadow' " |
| 1906 |
"DESC 'TRUE if the database is shadow' " |
| 1907 |
"EQUALITY booleanMatch " |
| 1908 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 " |
| 1909 |
"SINGLE-VALUE " |
| 1910 |
"USAGE dSAOperation )", SLAP_AT_HIDE, |
| 1911 |
offsetof(monitor_info_t, mi_ad_monitorIsShadow) }, |
| 1912 |
{ "( 1.3.6.1.4.1.4203.666.1.55.28 " |
| 1913 |
"NAME 'monitorUpdateRef' " |
| 1914 |
"DESC 'update referral for shadow databases' " |
| 1915 |
"SUP monitoredInfo " |
| 1916 |
"SINGLE-VALUE " |
| 1917 |
"USAGE dSAOperation )", SLAP_AT_HIDE, |
| 1918 |
offsetof(monitor_info_t, mi_ad_monitorUpdateRef) }, |
| 1919 |
{ "( 1.3.6.1.4.1.4203.666.1.55.29 " |
| 1920 |
"NAME 'monitorRuntimeConfig' " |
| 1921 |
"DESC 'TRUE if component allows runtime configuration' " |
| 1922 |
"EQUALITY booleanMatch " |
| 1923 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 " |
| 1924 |
"SINGLE-VALUE " |
| 1925 |
"USAGE dSAOperation )", SLAP_AT_HIDE, |
| 1926 |
offsetof(monitor_info_t, mi_ad_monitorRuntimeConfig) }, |
| 1927 |
{ "( 1.3.6.1.4.1.4203.666.1.55.30 " |
| 1928 |
"NAME 'monitorSuperiorDN' " |
| 1929 |
"DESC 'monitor superior DN' " |
| 1930 |
/* "SUP distinguishedName " */ |
| 1931 |
"EQUALITY distinguishedNameMatch " |
| 1932 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 " |
| 1933 |
"NO-USER-MODIFICATION " |
| 1934 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1935 |
offsetof(monitor_info_t, mi_ad_monitorSuperiorDN) }, |
| 1936 |
{ "( 1.3.6.1.4.1.4203.666.1.55.31 " |
| 1937 |
"NAME 'monitorConnectionOpsAsync' " |
| 1938 |
"DESC 'monitor number of asynchronous operations in execution within the connection' " |
| 1939 |
"SUP monitorCounter " |
| 1940 |
"NO-USER-MODIFICATION " |
| 1941 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1942 |
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsAsync) }, |
| 1943 |
{ "( 1.3.6.1.4.1.4203.666.1.55.32 " |
| 1944 |
"NAME 'monitorLogLevel' " |
| 1945 |
"DESC 'current slapd log level' " |
| 1946 |
"EQUALITY caseIgnoreMatch " |
| 1947 |
"SUBSTR caseIgnoreSubstringsMatch " |
| 1948 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " |
| 1949 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1950 |
offsetof(monitor_info_t, mi_ad_monitorLogLevel) }, |
| 1951 |
{ "( 1.3.6.1.4.1.4203.666.1.55.33 " |
| 1952 |
"NAME 'monitorDebugLevel' " |
| 1953 |
"DESC 'current slapd debug level' " |
| 1954 |
"EQUALITY caseIgnoreMatch " |
| 1955 |
"SUBSTR caseIgnoreSubstringsMatch " |
| 1956 |
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " |
| 1957 |
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, |
| 1958 |
offsetof(monitor_info_t, mi_ad_monitorDebugLevel) }, |
| 1959 |
{ NULL, 0, -1 } |
| 1960 |
}; |
| 1961 |
|
| 1962 |
static struct { |
| 1963 |
char *name; |
| 1964 |
char *oid; |
| 1965 |
} s_oid[] = { |
| 1966 |
{ "olmAttributes", "1.3.6.1.4.1.4203.666.1.55" }, |
| 1967 |
{ "olmSubSystemAttributes", "olmAttributes:0" }, |
| 1968 |
{ "olmGenericAttributes", "olmSubSystemAttributes:0" }, |
| 1969 |
{ "olmDatabaseAttributes", "olmSubSystemAttributes:1" }, |
| 1970 |
{ "olmOverlayAttributes", "olmSubSystemAttributes:2" }, |
| 1971 |
{ "olmModuleAttributes", "olmSubSystemAttributes:3" }, |
| 1972 |
|
| 1973 |
/* for example, back-mdb specific attrs |
| 1974 |
* are in "olmDatabaseAttributes:12" |
| 1975 |
* |
| 1976 |
* NOTE: developers, please record here OID assignments |
| 1977 |
* for other modules */ |
| 1978 |
|
| 1979 |
{ "olmObjectClasses", "1.3.6.1.4.1.4203.666.3.16" }, |
| 1980 |
{ "olmSubSystemObjectClasses", "olmObjectClasses:0" }, |
| 1981 |
{ "olmGenericObjectClasses", "olmSubSystemObjectClasses:0" }, |
| 1982 |
{ "olmDatabaseObjectClasses", "olmSubSystemObjectClasses:1" }, |
| 1983 |
{ "olmOverlayObjectClasses", "olmSubSystemObjectClasses:2" }, |
| 1984 |
{ "olmModuleObjectClasses", "olmSubSystemObjectClasses:3" }, |
| 1985 |
|
| 1986 |
/* for example, back-mdb specific objectClasses |
| 1987 |
* are in "olmDatabaseObjectClasses:12" |
| 1988 |
* |
| 1989 |
* NOTE: developers, please record here OID assignments |
| 1990 |
* for other modules */ |
| 1991 |
|
| 1992 |
{ NULL } |
| 1993 |
}; |
| 1994 |
|
| 1995 |
int i, rc; |
| 1996 |
monitor_info_t *mi = &monitor_info; |
| 1997 |
ConfigArgs c; |
| 1998 |
char *argv[ 3 ]; |
| 1999 |
|
| 2000 |
argv[ 0 ] = "monitor"; |
| 2001 |
c.argv = argv; |
| 2002 |
c.argc = 3; |
| 2003 |
c.fname = argv[0]; |
| 2004 |
|
| 2005 |
for ( i = 0; s_oid[ i ].name; i++ ) { |
| 2006 |
argv[ 1 ] = s_oid[ i ].name; |
| 2007 |
argv[ 2 ] = s_oid[ i ].oid; |
| 2008 |
|
| 2009 |
if ( parse_oidm( &c, 0, NULL ) != 0 ) { |
| 2010 |
Debug( LDAP_DEBUG_ANY, |
| 2011 |
"monitor_back_initialize: unable to add " |
| 2012 |
"objectIdentifier \"%s=%s\"\n", |
| 2013 |
s_oid[ i ].name, s_oid[ i ].oid ); |
| 2014 |
return 1; |
| 2015 |
} |
| 2016 |
} |
| 2017 |
|
| 2018 |
/* schema integration */ |
| 2019 |
for ( i = 0; mat[ i ].schema; i++ ) { |
| 2020 |
int code; |
| 2021 |
AttributeDescription **ad = |
| 2022 |
((AttributeDescription **)&(((char *)mi)[ mat[ i ].offset ])); |
| 2023 |
|
| 2024 |
*ad = NULL; |
| 2025 |
code = register_at( mat[ i ].schema, ad, 0 ); |
| 2026 |
|
| 2027 |
if ( code ) { |
| 2028 |
Debug( LDAP_DEBUG_ANY, |
| 2029 |
"monitor_back_db_init: register_at failed\n" ); |
| 2030 |
return -1; |
| 2031 |
} |
| 2032 |
(*ad)->ad_type->sat_flags |= mat[ i ].flags; |
| 2033 |
} |
| 2034 |
|
| 2035 |
for ( i = 0; moc[ i ].schema; i++ ) { |
| 2036 |
int code; |
| 2037 |
ObjectClass **Oc = |
| 2038 |
((ObjectClass **)&(((char *)mi)[ moc[ i ].offset ])); |
| 2039 |
|
| 2040 |
code = register_oc( moc[ i ].schema, Oc, 0 ); |
| 2041 |
if ( code ) { |
| 2042 |
Debug( LDAP_DEBUG_ANY, |
| 2043 |
"monitor_back_db_init: register_oc failed\n" ); |
| 2044 |
return -1; |
| 2045 |
} |
| 2046 |
(*Oc)->soc_flags |= moc[ i ].flags; |
| 2047 |
} |
| 2048 |
|
| 2049 |
bi->bi_controls = controls; |
| 2050 |
|
| 2051 |
bi->bi_init = 0; |
| 2052 |
bi->bi_open = 0; |
| 2053 |
bi->bi_config = monitor_back_config; |
| 2054 |
bi->bi_close = 0; |
| 2055 |
bi->bi_destroy = 0; |
| 2056 |
|
| 2057 |
bi->bi_db_init = monitor_back_db_init; |
| 2058 |
#if 0 |
| 2059 |
bi->bi_db_config = monitor_back_db_config; |
| 2060 |
#endif |
| 2061 |
bi->bi_db_open = monitor_back_db_open; |
| 2062 |
bi->bi_db_close = 0; |
| 2063 |
bi->bi_db_destroy = monitor_back_db_destroy; |
| 2064 |
|
| 2065 |
bi->bi_op_bind = monitor_back_bind; |
| 2066 |
bi->bi_op_unbind = 0; |
| 2067 |
bi->bi_op_search = monitor_back_search; |
| 2068 |
bi->bi_op_compare = monitor_back_compare; |
| 2069 |
bi->bi_op_modify = monitor_back_modify; |
| 2070 |
bi->bi_op_modrdn = 0; |
| 2071 |
bi->bi_op_add = 0; |
| 2072 |
bi->bi_op_delete = 0; |
| 2073 |
bi->bi_op_abandon = 0; |
| 2074 |
|
| 2075 |
bi->bi_extended = 0; |
| 2076 |
|
| 2077 |
bi->bi_entry_release_rw = monitor_back_release; |
| 2078 |
bi->bi_chk_referrals = 0; |
| 2079 |
bi->bi_operational = monitor_back_operational; |
| 2080 |
|
| 2081 |
/* |
| 2082 |
* hooks for slap tools |
| 2083 |
*/ |
| 2084 |
bi->bi_tool_entry_open = 0; |
| 2085 |
bi->bi_tool_entry_close = 0; |
| 2086 |
bi->bi_tool_entry_first = 0; |
| 2087 |
bi->bi_tool_entry_first_x = 0; |
| 2088 |
bi->bi_tool_entry_next = 0; |
| 2089 |
bi->bi_tool_entry_get = 0; |
| 2090 |
bi->bi_tool_entry_put = 0; |
| 2091 |
bi->bi_tool_entry_reindex = 0; |
| 2092 |
bi->bi_tool_sync = 0; |
| 2093 |
bi->bi_tool_dn2id_get = 0; |
| 2094 |
bi->bi_tool_entry_modify = 0; |
| 2095 |
|
| 2096 |
bi->bi_connection_init = 0; |
| 2097 |
bi->bi_connection_destroy = 0; |
| 2098 |
|
| 2099 |
bi->bi_extra = (void *)&monitor_extra; |
| 2100 |
|
| 2101 |
/* |
| 2102 |
* configuration objectClasses (fake) |
| 2103 |
*/ |
| 2104 |
bi->bi_cf_ocs = monitorocs; |
| 2105 |
|
| 2106 |
rc = config_register_schema( monitorcfg, monitorocs ); |
| 2107 |
if ( rc ) { |
| 2108 |
return rc; |
| 2109 |
} |
| 2110 |
|
| 2111 |
return 0; |
| 2112 |
} |
| 2113 |
|
| 2114 |
int |
| 2115 |
monitor_back_db_init( |
| 2116 |
BackendDB *be, |
| 2117 |
ConfigReply *c) |
| 2118 |
{ |
| 2119 |
int rc; |
| 2120 |
struct berval dn = BER_BVC( SLAPD_MONITOR_DN ), |
| 2121 |
pdn, |
| 2122 |
ndn; |
| 2123 |
BackendDB *be2; |
| 2124 |
|
| 2125 |
monitor_subsys_t *ms; |
| 2126 |
|
| 2127 |
/* |
| 2128 |
* database monitor can be defined once only |
| 2129 |
*/ |
| 2130 |
if ( be_monitor != NULL ) { |
| 2131 |
if (c) { |
| 2132 |
snprintf(c->msg, sizeof(c->msg),"only one monitor database allowed"); |
| 2133 |
} |
| 2134 |
return( -1 ); |
| 2135 |
} |
| 2136 |
be_monitor = be; |
| 2137 |
|
| 2138 |
/* |
| 2139 |
* register subsys |
| 2140 |
*/ |
| 2141 |
for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) { |
| 2142 |
if ( monitor_back_register_subsys( ms ) ) { |
| 2143 |
return -1; |
| 2144 |
} |
| 2145 |
} |
| 2146 |
|
| 2147 |
/* indicate system schema supported */ |
| 2148 |
SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR; |
| 2149 |
|
| 2150 |
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL ); |
| 2151 |
if( rc != LDAP_SUCCESS ) { |
| 2152 |
Debug( LDAP_DEBUG_ANY, |
| 2153 |
"unable to normalize/pretty monitor DN \"%s\" (%d)\n", |
| 2154 |
dn.bv_val, rc ); |
| 2155 |
return -1; |
| 2156 |
} |
| 2157 |
|
| 2158 |
ber_bvarray_add( &be->be_suffix, &pdn ); |
| 2159 |
ber_bvarray_add( &be->be_nsuffix, &ndn ); |
| 2160 |
|
| 2161 |
/* NOTE: only one monitor database is allowed, |
| 2162 |
* so we use static storage */ |
| 2163 |
ldap_pvt_thread_mutex_init( &monitor_info.mi_cache_lock ); |
| 2164 |
|
| 2165 |
be->be_private = &monitor_info; |
| 2166 |
|
| 2167 |
be2 = select_backend( &ndn, 0 ); |
| 2168 |
if ( be2 != be ) { |
| 2169 |
char *type = be2->bd_info->bi_type; |
| 2170 |
|
| 2171 |
if ( overlay_is_over( be2 ) ) { |
| 2172 |
slap_overinfo *oi = (slap_overinfo *)be2->bd_info->bi_private; |
| 2173 |
type = oi->oi_orig->bi_type; |
| 2174 |
} |
| 2175 |
|
| 2176 |
if (c) { |
| 2177 |
snprintf(c->msg, sizeof(c->msg), |
| 2178 |
"\"monitor\" database serving namingContext \"%s\" " |
| 2179 |
"is hidden by \"%s\" database serving namingContext \"%s\".\n", |
| 2180 |
pdn.bv_val, type, be2->be_nsuffix[ 0 ].bv_val ); |
| 2181 |
} |
| 2182 |
return -1; |
| 2183 |
} |
| 2184 |
|
| 2185 |
return 0; |
| 2186 |
} |
| 2187 |
|
| 2188 |
static void |
| 2189 |
monitor_back_destroy_limbo_entry( |
| 2190 |
entry_limbo_t *el, |
| 2191 |
int dispose ) |
| 2192 |
{ |
| 2193 |
if ( el->el_e ) { |
| 2194 |
entry_free( el->el_e ); |
| 2195 |
} |
| 2196 |
if ( el->el_a ) { |
| 2197 |
attrs_free( el->el_a ); |
| 2198 |
} |
| 2199 |
if ( !BER_BVISNULL( &el->el_nbase ) ) { |
| 2200 |
ber_memfree( el->el_nbase.bv_val ); |
| 2201 |
} |
| 2202 |
if ( !BER_BVISNULL( &el->el_filter ) ) { |
| 2203 |
ber_memfree( el->el_filter.bv_val ); |
| 2204 |
} |
| 2205 |
|
| 2206 |
/* NOTE: callbacks are not copied; so only free them |
| 2207 |
* if disposing of */ |
| 2208 |
if ( el->el_cb && dispose != 0 ) { |
| 2209 |
monitor_callback_t *next; |
| 2210 |
|
| 2211 |
for ( ; el->el_cb; el->el_cb = next ) { |
| 2212 |
next = el->el_cb->mc_next; |
| 2213 |
if ( el->el_cb->mc_dispose ) { |
| 2214 |
el->el_cb->mc_dispose( &el->el_cb->mc_private ); |
| 2215 |
} |
| 2216 |
ch_free( el->el_cb ); |
| 2217 |
} |
| 2218 |
} |
| 2219 |
|
| 2220 |
ch_free( el ); |
| 2221 |
} |
| 2222 |
|
| 2223 |
int |
| 2224 |
monitor_back_db_open( |
| 2225 |
BackendDB *be, |
| 2226 |
ConfigReply *cr) |
| 2227 |
{ |
| 2228 |
monitor_info_t *mi = (monitor_info_t *)be->be_private; |
| 2229 |
struct monitor_subsys_t **ms; |
| 2230 |
Entry *e, *root; |
| 2231 |
monitor_entry_t *mp; |
| 2232 |
int i; |
| 2233 |
struct berval bv, rdn = BER_BVC(SLAPD_MONITOR_DN); |
| 2234 |
struct tm tms; |
| 2235 |
static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; |
| 2236 |
struct berval desc[] = { |
| 2237 |
BER_BVC("This subtree contains monitoring/managing objects."), |
| 2238 |
BER_BVC("This object contains information about this server."), |
| 2239 |
BER_BVC("Most of the information is held in operational" |
| 2240 |
" attributes, which must be explicitly requested."), |
| 2241 |
BER_BVNULL }; |
| 2242 |
|
| 2243 |
int retcode = 0; |
| 2244 |
|
| 2245 |
assert( be_monitor != NULL ); |
| 2246 |
if ( be != be_monitor ) { |
| 2247 |
be_monitor = be; |
| 2248 |
} |
| 2249 |
|
| 2250 |
/* |
| 2251 |
* Start |
| 2252 |
*/ |
| 2253 |
ldap_pvt_gmtime( &starttime, &tms ); |
| 2254 |
lutil_gentime( tmbuf, sizeof(tmbuf), &tms ); |
| 2255 |
|
| 2256 |
mi->mi_startTime.bv_val = tmbuf; |
| 2257 |
mi->mi_startTime.bv_len = strlen( tmbuf ); |
| 2258 |
|
| 2259 |
if ( BER_BVISEMPTY( &be->be_rootdn ) ) { |
| 2260 |
BER_BVSTR( &mi->mi_creatorsName, SLAPD_ANONYMOUS ); |
| 2261 |
BER_BVSTR( &mi->mi_ncreatorsName, SLAPD_ANONYMOUS ); |
| 2262 |
} else { |
| 2263 |
mi->mi_creatorsName = be->be_rootdn; |
| 2264 |
mi->mi_ncreatorsName = be->be_rootndn; |
| 2265 |
} |
| 2266 |
|
| 2267 |
/* |
| 2268 |
* creates the "cn=Monitor" entry |
| 2269 |
*/ |
| 2270 |
e = monitor_entry_stub( NULL, NULL, &rdn, mi->mi_oc_monitorServer, |
| 2271 |
NULL, NULL ); |
| 2272 |
|
| 2273 |
if ( e == NULL) { |
| 2274 |
Debug( LDAP_DEBUG_ANY, |
| 2275 |
"unable to create \"%s\" entry\n", |
| 2276 |
SLAPD_MONITOR_DN ); |
| 2277 |
return( -1 ); |
| 2278 |
} |
| 2279 |
|
| 2280 |
attr_merge_normalize( e, slap_schema.si_ad_description, desc, NULL ); |
| 2281 |
|
| 2282 |
bv.bv_val = strchr( (char *) Versionstr, '$' ); |
| 2283 |
if ( bv.bv_val != NULL ) { |
| 2284 |
char *end; |
| 2285 |
|
| 2286 |
bv.bv_val++; |
| 2287 |
for ( ; bv.bv_val[ 0 ] == ' '; bv.bv_val++ ) |
| 2288 |
; |
| 2289 |
|
| 2290 |
end = strchr( bv.bv_val, '$' ); |
| 2291 |
if ( end != NULL ) { |
| 2292 |
end--; |
| 2293 |
|
| 2294 |
for ( ; end > bv.bv_val && end[ 0 ] == ' '; end-- ) |
| 2295 |
; |
| 2296 |
|
| 2297 |
end++; |
| 2298 |
|
| 2299 |
bv.bv_len = end - bv.bv_val; |
| 2300 |
|
| 2301 |
} else { |
| 2302 |
bv.bv_len = strlen( bv.bv_val ); |
| 2303 |
} |
| 2304 |
|
| 2305 |
if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, |
| 2306 |
&bv, NULL ) ) { |
| 2307 |
Debug( LDAP_DEBUG_ANY, |
| 2308 |
"unable to add monitoredInfo to \"%s\" entry\n", |
| 2309 |
SLAPD_MONITOR_DN ); |
| 2310 |
return( -1 ); |
| 2311 |
} |
| 2312 |
} |
| 2313 |
|
| 2314 |
mp = monitor_entrypriv_create(); |
| 2315 |
if ( mp == NULL ) { |
| 2316 |
return -1; |
| 2317 |
} |
| 2318 |
e->e_private = ( void * )mp; |
| 2319 |
|
| 2320 |
if ( monitor_cache_add( mi, e, NULL ) ) { |
| 2321 |
Debug( LDAP_DEBUG_ANY, |
| 2322 |
"unable to add entry \"%s\" to cache\n", |
| 2323 |
SLAPD_MONITOR_DN ); |
| 2324 |
return -1; |
| 2325 |
} |
| 2326 |
root = e; |
| 2327 |
|
| 2328 |
/* |
| 2329 |
* Create all the subsystem specific entries |
| 2330 |
*/ |
| 2331 |
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) { |
| 2332 |
int len = strlen( monitor_subsys[ i ]->mss_name ); |
| 2333 |
struct berval dn; |
| 2334 |
int rc; |
| 2335 |
|
| 2336 |
dn.bv_len = len + sizeof( "cn=" ) - 1; |
| 2337 |
dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 ); |
| 2338 |
strcpy( dn.bv_val, "cn=" ); |
| 2339 |
strcat( dn.bv_val, monitor_subsys[ i ]->mss_name ); |
| 2340 |
rc = dnPretty( NULL, &dn, &monitor_subsys[ i ]->mss_rdn, NULL ); |
| 2341 |
free( dn.bv_val ); |
| 2342 |
if ( rc != LDAP_SUCCESS ) { |
| 2343 |
Debug( LDAP_DEBUG_ANY, |
| 2344 |
"monitor RDN \"%s\" is invalid\n", |
| 2345 |
dn.bv_val ); |
| 2346 |
return( -1 ); |
| 2347 |
} |
| 2348 |
|
| 2349 |
e = monitor_entry_stub( &root->e_name, &root->e_nname, |
| 2350 |
&monitor_subsys[ i ]->mss_rdn, mi->mi_oc_monitorContainer, |
| 2351 |
NULL, NULL ); |
| 2352 |
|
| 2353 |
if ( e == NULL) { |
| 2354 |
Debug( LDAP_DEBUG_ANY, |
| 2355 |
"unable to create \"%s\" entry\n", |
| 2356 |
monitor_subsys[ i ]->mss_dn.bv_val ); |
| 2357 |
return( -1 ); |
| 2358 |
} |
| 2359 |
monitor_subsys[i]->mss_dn = e->e_name; |
| 2360 |
monitor_subsys[i]->mss_ndn = e->e_nname; |
| 2361 |
|
| 2362 |
if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_desc[ 0 ] ) ) { |
| 2363 |
attr_merge_normalize( e, slap_schema.si_ad_description, |
| 2364 |
monitor_subsys[ i ]->mss_desc, NULL ); |
| 2365 |
} |
| 2366 |
|
| 2367 |
mp = monitor_entrypriv_create(); |
| 2368 |
if ( mp == NULL ) { |
| 2369 |
return -1; |
| 2370 |
} |
| 2371 |
e->e_private = ( void * )mp; |
| 2372 |
mp->mp_info = monitor_subsys[ i ]; |
| 2373 |
mp->mp_flags = monitor_subsys[ i ]->mss_flags; |
| 2374 |
|
| 2375 |
if ( monitor_cache_add( mi, e, root ) ) { |
| 2376 |
Debug( LDAP_DEBUG_ANY, |
| 2377 |
"unable to add entry \"%s\" to cache\n", |
| 2378 |
monitor_subsys[ i ]->mss_dn.bv_val ); |
| 2379 |
return -1; |
| 2380 |
} |
| 2381 |
} |
| 2382 |
|
| 2383 |
assert( be != NULL ); |
| 2384 |
|
| 2385 |
be->be_private = mi; |
| 2386 |
|
| 2387 |
/* |
| 2388 |
* opens the monitor backend subsystems |
| 2389 |
*/ |
| 2390 |
for ( ms = monitor_subsys; ms[ 0 ] != NULL; ms++ ) { |
| 2391 |
if ( ms[ 0 ]->mss_open && ms[ 0 ]->mss_open( be, ms[ 0 ] ) ) { |
| 2392 |
return( -1 ); |
| 2393 |
} |
| 2394 |
ms[ 0 ]->mss_flags |= MONITOR_F_OPENED; |
| 2395 |
} |
| 2396 |
|
| 2397 |
monitor_subsys_opened = 1; |
| 2398 |
|
| 2399 |
if ( mi->mi_entry_limbo ) { |
| 2400 |
entry_limbo_t *el = mi->mi_entry_limbo; |
| 2401 |
|
| 2402 |
for ( ; el; ) { |
| 2403 |
entry_limbo_t *tmp; |
| 2404 |
int rc; |
| 2405 |
|
| 2406 |
switch ( el->el_type ) { |
| 2407 |
case LIMBO_ENTRY: |
| 2408 |
rc = monitor_back_register_entry( |
| 2409 |
el->el_e, |
| 2410 |
el->el_cb, |
| 2411 |
el->el_mss, |
| 2412 |
el->el_flags ); |
| 2413 |
break; |
| 2414 |
|
| 2415 |
case LIMBO_ENTRY_PARENT: |
| 2416 |
rc = monitor_back_register_entry_parent( |
| 2417 |
el->el_e, |
| 2418 |
el->el_cb, |
| 2419 |
el->el_mss, |
| 2420 |
el->el_flags, |
| 2421 |
&el->el_nbase, |
| 2422 |
el->el_scope, |
| 2423 |
&el->el_filter ); |
| 2424 |
break; |
| 2425 |
|
| 2426 |
|
| 2427 |
case LIMBO_ATTRS: |
| 2428 |
rc = monitor_back_register_entry_attrs( |
| 2429 |
el->el_ndn, |
| 2430 |
el->el_a, |
| 2431 |
el->el_cb, |
| 2432 |
&el->el_nbase, |
| 2433 |
el->el_scope, |
| 2434 |
&el->el_filter ); |
| 2435 |
break; |
| 2436 |
|
| 2437 |
case LIMBO_CB: |
| 2438 |
rc = monitor_back_register_entry_callback( |
| 2439 |
el->el_ndn, |
| 2440 |
el->el_cb, |
| 2441 |
&el->el_nbase, |
| 2442 |
el->el_scope, |
| 2443 |
&el->el_filter ); |
| 2444 |
break; |
| 2445 |
|
| 2446 |
case LIMBO_BACKEND: |
| 2447 |
rc = monitor_back_register_backend( el->el_bi ); |
| 2448 |
break; |
| 2449 |
|
| 2450 |
case LIMBO_DATABASE: |
| 2451 |
rc = monitor_back_register_database( el->el_be, el->el_ndn ); |
| 2452 |
break; |
| 2453 |
|
| 2454 |
case LIMBO_OVERLAY_INFO: |
| 2455 |
rc = monitor_back_register_overlay_info( el->el_on ); |
| 2456 |
break; |
| 2457 |
|
| 2458 |
case LIMBO_OVERLAY: |
| 2459 |
rc = monitor_back_register_overlay( el->el_be, el->el_on, el->el_ndn ); |
| 2460 |
break; |
| 2461 |
|
| 2462 |
case LIMBO_SUBSYS: |
| 2463 |
rc = monitor_back_register_subsys( el->el_mss ); |
| 2464 |
break; |
| 2465 |
|
| 2466 |
default: |
| 2467 |
assert( 0 ); |
| 2468 |
} |
| 2469 |
|
| 2470 |
tmp = el; |
| 2471 |
el = el->el_next; |
| 2472 |
monitor_back_destroy_limbo_entry( tmp, rc ); |
| 2473 |
|
| 2474 |
if ( rc != 0 ) { |
| 2475 |
/* try all, but report error at end */ |
| 2476 |
retcode = 1; |
| 2477 |
} |
| 2478 |
} |
| 2479 |
|
| 2480 |
mi->mi_entry_limbo = NULL; |
| 2481 |
} |
| 2482 |
|
| 2483 |
return retcode; |
| 2484 |
} |
| 2485 |
|
| 2486 |
int |
| 2487 |
monitor_back_config( |
| 2488 |
BackendInfo *bi, |
| 2489 |
const char *fname, |
| 2490 |
int lineno, |
| 2491 |
int argc, |
| 2492 |
char **argv ) |
| 2493 |
{ |
| 2494 |
/* |
| 2495 |
* eventually, will hold backend specific configuration parameters |
| 2496 |
*/ |
| 2497 |
return SLAP_CONF_UNKNOWN; |
| 2498 |
} |
| 2499 |
|
| 2500 |
#if 0 |
| 2501 |
int |
| 2502 |
monitor_back_db_config( |
| 2503 |
Backend *be, |
| 2504 |
const char *fname, |
| 2505 |
int lineno, |
| 2506 |
int argc, |
| 2507 |
char **argv ) |
| 2508 |
{ |
| 2509 |
monitor_info_t *mi = ( monitor_info_t * )be->be_private; |
| 2510 |
|
| 2511 |
/* |
| 2512 |
* eventually, will hold database specific configuration parameters |
| 2513 |
*/ |
| 2514 |
return SLAP_CONF_UNKNOWN; |
| 2515 |
} |
| 2516 |
#endif |
| 2517 |
|
| 2518 |
int |
| 2519 |
monitor_back_db_destroy( |
| 2520 |
BackendDB *be, |
| 2521 |
ConfigReply *cr) |
| 2522 |
{ |
| 2523 |
monitor_info_t *mi = ( monitor_info_t * )be->be_private; |
| 2524 |
|
| 2525 |
if ( mi == NULL ) { |
| 2526 |
return -1; |
| 2527 |
} |
| 2528 |
|
| 2529 |
/* |
| 2530 |
* FIXME: destroys all the data |
| 2531 |
*/ |
| 2532 |
/* NOTE: mi points to static storage; don't free it */ |
| 2533 |
|
| 2534 |
(void)monitor_cache_destroy( mi ); |
| 2535 |
|
| 2536 |
if ( monitor_subsys ) { |
| 2537 |
int i; |
| 2538 |
|
| 2539 |
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) { |
| 2540 |
if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_rdn ) ) { |
| 2541 |
ch_free( monitor_subsys[ i ]->mss_rdn.bv_val ); |
| 2542 |
} |
| 2543 |
|
| 2544 |
if ( monitor_subsys[ i ]->mss_destroy ) { |
| 2545 |
monitor_subsys[ i ]->mss_destroy( be, monitor_subsys[ i ] ); |
| 2546 |
} |
| 2547 |
} |
| 2548 |
|
| 2549 |
ch_free( monitor_subsys ); |
| 2550 |
} |
| 2551 |
|
| 2552 |
if ( mi->mi_entry_limbo ) { |
| 2553 |
entry_limbo_t *el = mi->mi_entry_limbo; |
| 2554 |
|
| 2555 |
for ( ; el; ) { |
| 2556 |
entry_limbo_t *tmp = el; |
| 2557 |
el = el->el_next; |
| 2558 |
monitor_back_destroy_limbo_entry( tmp, 1 ); |
| 2559 |
} |
| 2560 |
} |
| 2561 |
|
| 2562 |
ldap_pvt_thread_mutex_destroy( &monitor_info.mi_cache_lock ); |
| 2563 |
|
| 2564 |
be->be_private = NULL; |
| 2565 |
|
| 2566 |
return 0; |
| 2567 |
} |