| 1 |
/* translucent.c - translucent proxy module */ |
| 2 |
/* $OpenLDAP$ */ |
| 3 |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
| 4 |
* |
| 5 |
* Copyright 2004-2024 The OpenLDAP Foundation. |
| 6 |
* Portions Copyright 2005 Symas Corporation. |
| 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 the 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 Symas Corp. for inclusion in |
| 19 |
* OpenLDAP Software. This work was sponsored by Hewlett-Packard. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "portable.h" |
| 23 |
|
| 24 |
#ifdef SLAPD_OVER_TRANSLUCENT |
| 25 |
|
| 26 |
#include <stdio.h> |
| 27 |
|
| 28 |
#include <ac/string.h> |
| 29 |
#include <ac/socket.h> |
| 30 |
|
| 31 |
#include "slap.h" |
| 32 |
#include "lutil.h" |
| 33 |
|
| 34 |
#include "slap-config.h" |
| 35 |
|
| 36 |
/* config block */ |
| 37 |
typedef struct translucent_info { |
| 38 |
BackendDB db; /* captive backend */ |
| 39 |
AttributeName *local; /* valid attrs for local filters */ |
| 40 |
AttributeName *remote; /* valid attrs for remote filters */ |
| 41 |
int strict; |
| 42 |
int no_glue; |
| 43 |
int defer_db_open; |
| 44 |
int bind_local; |
| 45 |
int pwmod_local; |
| 46 |
} translucent_info; |
| 47 |
|
| 48 |
static ConfigLDAPadd translucent_ldadd; |
| 49 |
static ConfigCfAdd translucent_cfadd; |
| 50 |
|
| 51 |
static ConfigDriver translucent_cf_gen; |
| 52 |
|
| 53 |
enum { |
| 54 |
TRANS_LOCAL = 1, |
| 55 |
TRANS_REMOTE |
| 56 |
}; |
| 57 |
|
| 58 |
static ConfigTable translucentcfg[] = { |
| 59 |
{ "translucent_strict", "on|off", 1, 2, 0, |
| 60 |
ARG_ON_OFF|ARG_OFFSET, |
| 61 |
(void *)offsetof(translucent_info, strict), |
| 62 |
"( OLcfgOvAt:14.1 NAME 'olcTranslucentStrict' " |
| 63 |
"DESC 'Reveal attribute deletion constraint violations' " |
| 64 |
"EQUALITY booleanMatch " |
| 65 |
"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL }, |
| 66 |
{ "translucent_no_glue", "on|off", 1, 2, 0, |
| 67 |
ARG_ON_OFF|ARG_OFFSET, |
| 68 |
(void *)offsetof(translucent_info, no_glue), |
| 69 |
"( OLcfgOvAt:14.2 NAME 'olcTranslucentNoGlue' " |
| 70 |
"DESC 'Disable automatic glue records for ADD and MODRDN' " |
| 71 |
"EQUALITY booleanMatch " |
| 72 |
"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL }, |
| 73 |
{ "translucent_local", "attr[,attr...]", 1, 2, 0, |
| 74 |
ARG_MAGIC|TRANS_LOCAL, |
| 75 |
translucent_cf_gen, |
| 76 |
"( OLcfgOvAt:14.3 NAME 'olcTranslucentLocal' " |
| 77 |
"DESC 'Attributes to use in local search filter' " |
| 78 |
"EQUALITY caseIgnoreMatch " |
| 79 |
"SYNTAX OMsDirectoryString )", NULL, NULL }, |
| 80 |
{ "translucent_remote", "attr[,attr...]", 1, 2, 0, |
| 81 |
ARG_MAGIC|TRANS_REMOTE, |
| 82 |
translucent_cf_gen, |
| 83 |
"( OLcfgOvAt:14.4 NAME 'olcTranslucentRemote' " |
| 84 |
"DESC 'Attributes to use in remote search filter' " |
| 85 |
"EQUALITY caseIgnoreMatch " |
| 86 |
"SYNTAX OMsDirectoryString )", NULL, NULL }, |
| 87 |
{ "translucent_bind_local", "on|off", 1, 2, 0, |
| 88 |
ARG_ON_OFF|ARG_OFFSET, |
| 89 |
(void *)offsetof(translucent_info, bind_local), |
| 90 |
"( OLcfgOvAt:14.5 NAME 'olcTranslucentBindLocal' " |
| 91 |
"DESC 'Enable local bind' " |
| 92 |
"EQUALITY booleanMatch " |
| 93 |
"SYNTAX OMsBoolean SINGLE-VALUE)", NULL, NULL }, |
| 94 |
{ "translucent_pwmod_local", "on|off", 1, 2, 0, |
| 95 |
ARG_ON_OFF|ARG_OFFSET, |
| 96 |
(void *)offsetof(translucent_info, pwmod_local), |
| 97 |
"( OLcfgOvAt:14.6 NAME 'olcTranslucentPwModLocal' " |
| 98 |
"DESC 'Enable local RFC 3062 Password Modify extended operation' " |
| 99 |
"EQUALITY booleanMatch " |
| 100 |
"SYNTAX OMsBoolean SINGLE-VALUE)", NULL, NULL }, |
| 101 |
{ NULL, NULL, 0, 0, 0, ARG_IGNORED } |
| 102 |
}; |
| 103 |
|
| 104 |
static ConfigOCs translucentocs[] = { |
| 105 |
{ "( OLcfgOvOc:14.1 " |
| 106 |
"NAME 'olcTranslucentConfig' " |
| 107 |
"DESC 'Translucent configuration' " |
| 108 |
"SUP olcOverlayConfig " |
| 109 |
"MAY ( olcTranslucentStrict $ olcTranslucentNoGlue $" |
| 110 |
" olcTranslucentLocal $ olcTranslucentRemote $" |
| 111 |
" olcTranslucentBindLocal $ olcTranslucentPwModLocal ) )", |
| 112 |
Cft_Overlay, translucentcfg, NULL, translucent_cfadd }, |
| 113 |
{ "( OLcfgOvOc:14.2 " |
| 114 |
"NAME 'olcTranslucentDatabase' " |
| 115 |
"DESC 'Translucent target database configuration' " |
| 116 |
/* co_table is initialized in translucent_initialize() */ |
| 117 |
"AUXILIARY )", Cft_Misc, NULL, translucent_ldadd }, |
| 118 |
{ NULL, 0, NULL } |
| 119 |
}; |
| 120 |
/* for translucent_init() */ |
| 121 |
|
| 122 |
static int |
| 123 |
translucent_ldadd_cleanup( ConfigArgs *ca ) |
| 124 |
{ |
| 125 |
slap_overinst *on = ca->ca_private; |
| 126 |
translucent_info *ov = on->on_bi.bi_private; |
| 127 |
|
| 128 |
ov->defer_db_open = 0; |
| 129 |
return backend_startup_one( ca->be, &ca->reply ); |
| 130 |
} |
| 131 |
|
| 132 |
static int |
| 133 |
translucent_ldadd( CfEntryInfo *cei, Entry *e, ConfigArgs *ca ) |
| 134 |
{ |
| 135 |
slap_overinst *on; |
| 136 |
translucent_info *ov; |
| 137 |
|
| 138 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_ldadd\n" ); |
| 139 |
|
| 140 |
if ( cei->ce_type != Cft_Overlay || !cei->ce_bi || |
| 141 |
cei->ce_bi->bi_cf_ocs != translucentocs ) |
| 142 |
return LDAP_CONSTRAINT_VIOLATION; |
| 143 |
|
| 144 |
on = (slap_overinst *)cei->ce_bi; |
| 145 |
ov = on->on_bi.bi_private; |
| 146 |
ca->be = &ov->db; |
| 147 |
ca->ca_private = on; |
| 148 |
if ( CONFIG_ONLINE_ADD( ca )) |
| 149 |
config_push_cleanup( ca, translucent_ldadd_cleanup ); |
| 150 |
else |
| 151 |
ov->defer_db_open = 0; |
| 152 |
|
| 153 |
return LDAP_SUCCESS; |
| 154 |
} |
| 155 |
|
| 156 |
static int |
| 157 |
translucent_cfadd( Operation *op, SlapReply *rs, Entry *e, ConfigArgs *ca ) |
| 158 |
{ |
| 159 |
CfEntryInfo *cei = e->e_private; |
| 160 |
slap_overinst *on = (slap_overinst *)cei->ce_bi; |
| 161 |
translucent_info *ov = on->on_bi.bi_private; |
| 162 |
struct berval bv; |
| 163 |
|
| 164 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_cfadd\n" ); |
| 165 |
|
| 166 |
/* FIXME: should not hardcode "olcDatabase" here */ |
| 167 |
bv.bv_len = snprintf( ca->cr_msg, sizeof( ca->cr_msg ), |
| 168 |
"olcDatabase=" SLAP_X_ORDERED_FMT "%s", |
| 169 |
0, ov->db.bd_info->bi_type ); |
| 170 |
if ( bv.bv_len >= sizeof( ca->cr_msg ) ) { |
| 171 |
return -1; |
| 172 |
} |
| 173 |
bv.bv_val = ca->cr_msg; |
| 174 |
ca->be = &ov->db; |
| 175 |
ov->defer_db_open = 0; |
| 176 |
|
| 177 |
/* We can only create this entry if the database is table-driven |
| 178 |
*/ |
| 179 |
if ( ov->db.be_cf_ocs ) |
| 180 |
config_build_entry( op, rs, cei, ca, &bv, |
| 181 |
ov->db.be_cf_ocs, |
| 182 |
&translucentocs[1] ); |
| 183 |
|
| 184 |
return 0; |
| 185 |
} |
| 186 |
|
| 187 |
static int |
| 188 |
translucent_cf_gen( ConfigArgs *c ) |
| 189 |
{ |
| 190 |
slap_overinst *on = (slap_overinst *)c->bi; |
| 191 |
translucent_info *ov = on->on_bi.bi_private; |
| 192 |
AttributeName **an, *a2; |
| 193 |
int i; |
| 194 |
|
| 195 |
if ( c->type == TRANS_LOCAL ) |
| 196 |
an = &ov->local; |
| 197 |
else |
| 198 |
an = &ov->remote; |
| 199 |
|
| 200 |
if ( c->op == SLAP_CONFIG_EMIT ) { |
| 201 |
if ( !*an ) |
| 202 |
return 1; |
| 203 |
for ( i = 0; !BER_BVISNULL(&(*an)[i].an_name); i++ ) { |
| 204 |
value_add_one( &c->rvalue_vals, &(*an)[i].an_name ); |
| 205 |
} |
| 206 |
return ( i < 1 ); |
| 207 |
} else if ( c->op == LDAP_MOD_DELETE ) { |
| 208 |
if ( c->valx < 0 ) { |
| 209 |
anlist_free( *an, 1, NULL ); |
| 210 |
*an = NULL; |
| 211 |
} else { |
| 212 |
i = c->valx; |
| 213 |
ch_free( (*an)[i].an_name.bv_val ); |
| 214 |
do { |
| 215 |
(*an)[i] = (*an)[i+1]; |
| 216 |
i++; |
| 217 |
} while ( !BER_BVISNULL( &(*an)[i].an_name )); |
| 218 |
} |
| 219 |
return 0; |
| 220 |
} |
| 221 |
|
| 222 |
/* cn=config values could be deleted later, we only want one name |
| 223 |
* per value for valx to match. */ |
| 224 |
if ( c->op != SLAP_CONFIG_ADD && strchr( c->argv[1], ',' ) ) { |
| 225 |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, "%s: %s: " |
| 226 |
"Supplying multiple attribute names in a single value is " |
| 227 |
"unsupported and will be disallowed in a future version\n", |
| 228 |
c->log, c->argv[0] ); |
| 229 |
} |
| 230 |
|
| 231 |
a2 = str2anlist( *an, c->argv[1], "," ); |
| 232 |
if ( !a2 ) { |
| 233 |
snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s unable to parse attribute %s", |
| 234 |
c->argv[0], c->argv[1] ); |
| 235 |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
| 236 |
"%s: %s\n", c->log, c->cr_msg ); |
| 237 |
return ARG_BAD_CONF; |
| 238 |
} |
| 239 |
*an = a2; |
| 240 |
return 0; |
| 241 |
} |
| 242 |
|
| 243 |
static slap_overinst translucent; |
| 244 |
|
| 245 |
/* |
| 246 |
** glue_parent() |
| 247 |
** call syncrepl_add_glue() with the parent suffix; |
| 248 |
** |
| 249 |
*/ |
| 250 |
|
| 251 |
static struct berval glue[] = { BER_BVC("top"), BER_BVC("glue"), BER_BVNULL }; |
| 252 |
|
| 253 |
void glue_parent(Operation *op) { |
| 254 |
Operation nop = *op; |
| 255 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 256 |
struct berval ndn = BER_BVNULL; |
| 257 |
Attribute *a; |
| 258 |
Entry *e; |
| 259 |
struct berval pdn; |
| 260 |
|
| 261 |
dnParent( &op->o_req_ndn, &pdn ); |
| 262 |
ber_dupbv_x( &ndn, &pdn, op->o_tmpmemctx ); |
| 263 |
|
| 264 |
Debug(LDAP_DEBUG_TRACE, "=> glue_parent: fabricating glue for <%s>\n", ndn.bv_val ); |
| 265 |
|
| 266 |
e = entry_alloc(); |
| 267 |
e->e_id = NOID; |
| 268 |
ber_dupbv(&e->e_name, &ndn); |
| 269 |
ber_dupbv(&e->e_nname, &ndn); |
| 270 |
|
| 271 |
a = attr_alloc( slap_schema.si_ad_objectClass ); |
| 272 |
a->a_numvals = 2; |
| 273 |
a->a_vals = ch_malloc(sizeof(struct berval) * 3); |
| 274 |
ber_dupbv(&a->a_vals[0], &glue[0]); |
| 275 |
ber_dupbv(&a->a_vals[1], &glue[1]); |
| 276 |
ber_dupbv(&a->a_vals[2], &glue[2]); |
| 277 |
a->a_nvals = a->a_vals; |
| 278 |
a->a_next = e->e_attrs; |
| 279 |
e->e_attrs = a; |
| 280 |
|
| 281 |
a = attr_alloc( slap_schema.si_ad_structuralObjectClass ); |
| 282 |
a->a_numvals = 1; |
| 283 |
a->a_vals = ch_malloc(sizeof(struct berval) * 2); |
| 284 |
ber_dupbv(&a->a_vals[0], &glue[1]); |
| 285 |
ber_dupbv(&a->a_vals[1], &glue[2]); |
| 286 |
a->a_nvals = a->a_vals; |
| 287 |
a->a_next = e->e_attrs; |
| 288 |
e->e_attrs = a; |
| 289 |
|
| 290 |
nop.o_req_dn = ndn; |
| 291 |
nop.o_req_ndn = ndn; |
| 292 |
nop.ora_e = e; |
| 293 |
|
| 294 |
nop.o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig; |
| 295 |
syncrepl_add_glue(&nop, e); |
| 296 |
nop.o_bd->bd_info = (BackendInfo *) on; |
| 297 |
|
| 298 |
op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx ); |
| 299 |
|
| 300 |
return; |
| 301 |
} |
| 302 |
|
| 303 |
/* |
| 304 |
** free_attr_chain() |
| 305 |
** free only the Attribute*, not the contents; |
| 306 |
** |
| 307 |
*/ |
| 308 |
void free_attr_chain(Attribute *b) { |
| 309 |
Attribute *a; |
| 310 |
for(a=b; a; a=a->a_next) { |
| 311 |
a->a_vals = NULL; |
| 312 |
a->a_nvals = NULL; |
| 313 |
} |
| 314 |
attrs_free( b ); |
| 315 |
return; |
| 316 |
} |
| 317 |
|
| 318 |
/* |
| 319 |
** translucent_add() |
| 320 |
** if not bound as root, send ACCESS error; |
| 321 |
** if glue, glue_parent(); |
| 322 |
** return CONTINUE; |
| 323 |
** |
| 324 |
*/ |
| 325 |
|
| 326 |
static int translucent_add(Operation *op, SlapReply *rs) { |
| 327 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 328 |
translucent_info *ov = on->on_bi.bi_private; |
| 329 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_add: %s\n", |
| 330 |
op->o_req_dn.bv_val ); |
| 331 |
if(!be_isroot(op)) { |
| 332 |
op->o_bd->bd_info = (BackendInfo *) on->on_info; |
| 333 |
send_ldap_error(op, rs, LDAP_INSUFFICIENT_ACCESS, |
| 334 |
"user modification of overlay database not permitted"); |
| 335 |
op->o_bd->bd_info = (BackendInfo *) on; |
| 336 |
return(rs->sr_err); |
| 337 |
} |
| 338 |
if(!ov->no_glue) glue_parent(op); |
| 339 |
return(SLAP_CB_CONTINUE); |
| 340 |
} |
| 341 |
|
| 342 |
/* |
| 343 |
** translucent_modrdn() |
| 344 |
** if not bound as root, send ACCESS error; |
| 345 |
** if !glue, glue_parent(); |
| 346 |
** else return CONTINUE; |
| 347 |
** |
| 348 |
*/ |
| 349 |
|
| 350 |
static int translucent_modrdn(Operation *op, SlapReply *rs) { |
| 351 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 352 |
translucent_info *ov = on->on_bi.bi_private; |
| 353 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_modrdn: %s -> %s\n", |
| 354 |
op->o_req_dn.bv_val, op->orr_newrdn.bv_val ); |
| 355 |
if(!be_isroot(op)) { |
| 356 |
op->o_bd->bd_info = (BackendInfo *) on->on_info; |
| 357 |
send_ldap_error(op, rs, LDAP_INSUFFICIENT_ACCESS, |
| 358 |
"user modification of overlay database not permitted"); |
| 359 |
op->o_bd->bd_info = (BackendInfo *) on; |
| 360 |
return(rs->sr_err); |
| 361 |
} |
| 362 |
if(!ov->no_glue) { |
| 363 |
op->o_tag = LDAP_REQ_ADD; |
| 364 |
glue_parent(op); |
| 365 |
op->o_tag = LDAP_REQ_MODRDN; |
| 366 |
} |
| 367 |
return(SLAP_CB_CONTINUE); |
| 368 |
} |
| 369 |
|
| 370 |
/* |
| 371 |
** translucent_delete() |
| 372 |
** if not bound as root, send ACCESS error; |
| 373 |
** else return CONTINUE; |
| 374 |
** |
| 375 |
*/ |
| 376 |
|
| 377 |
static int translucent_delete(Operation *op, SlapReply *rs) { |
| 378 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 379 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_delete: %s\n", |
| 380 |
op->o_req_dn.bv_val ); |
| 381 |
if(!be_isroot(op)) { |
| 382 |
op->o_bd->bd_info = (BackendInfo *) on->on_info; |
| 383 |
send_ldap_error(op, rs, LDAP_INSUFFICIENT_ACCESS, |
| 384 |
"user modification of overlay database not permitted"); |
| 385 |
op->o_bd->bd_info = (BackendInfo *) on; |
| 386 |
return(rs->sr_err); |
| 387 |
} |
| 388 |
return(SLAP_CB_CONTINUE); |
| 389 |
} |
| 390 |
|
| 391 |
static int |
| 392 |
translucent_tag_cb( Operation *op, SlapReply *rs ) |
| 393 |
{ |
| 394 |
op->o_tag = LDAP_REQ_MODIFY; |
| 395 |
op->orm_modlist = op->o_callback->sc_private; |
| 396 |
rs->sr_tag = slap_req2res( op->o_tag ); |
| 397 |
|
| 398 |
return SLAP_CB_CONTINUE; |
| 399 |
} |
| 400 |
|
| 401 |
/* |
| 402 |
** translucent_modify() |
| 403 |
** modify in local backend if exists in both; |
| 404 |
** otherwise, add to local backend; |
| 405 |
** fail if not defined in captive backend; |
| 406 |
** |
| 407 |
*/ |
| 408 |
|
| 409 |
static int translucent_modify(Operation *op, SlapReply *rs) { |
| 410 |
SlapReply nrs = { REP_RESULT }; |
| 411 |
|
| 412 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 413 |
translucent_info *ov = on->on_bi.bi_private; |
| 414 |
Entry *e = NULL, *re = NULL; |
| 415 |
Attribute *a, *ax; |
| 416 |
Modifications *m, **mm; |
| 417 |
BackendDB *db; |
| 418 |
int del, rc, erc = 0; |
| 419 |
slap_callback cb = { 0 }; |
| 420 |
|
| 421 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_modify: %s\n", |
| 422 |
op->o_req_dn.bv_val ); |
| 423 |
|
| 424 |
if(ov->defer_db_open) { |
| 425 |
send_ldap_error(op, rs, LDAP_UNAVAILABLE, |
| 426 |
"remote DB not available"); |
| 427 |
return(rs->sr_err); |
| 428 |
} |
| 429 |
/* |
| 430 |
** fetch entry from the captive backend; |
| 431 |
** if it did not exist, fail; |
| 432 |
** release it, if captive backend supports this; |
| 433 |
** |
| 434 |
*/ |
| 435 |
|
| 436 |
db = op->o_bd; |
| 437 |
op->o_bd = &ov->db; |
| 438 |
ov->db.be_acl = op->o_bd->be_acl; |
| 439 |
rc = ov->db.bd_info->bi_entry_get_rw(op, &op->o_req_ndn, NULL, NULL, 0, &re); |
| 440 |
op->o_bd = db; |
| 441 |
if(rc != LDAP_SUCCESS || re == NULL ) { |
| 442 |
send_ldap_error((op), rs, LDAP_NO_SUCH_OBJECT, |
| 443 |
"attempt to modify nonexistent local record"); |
| 444 |
return(rs->sr_err); |
| 445 |
} |
| 446 |
/* |
| 447 |
** fetch entry from local backend; |
| 448 |
** if it exists: |
| 449 |
** foreach Modification: |
| 450 |
** if attr not present in local: |
| 451 |
** if Mod == LDAP_MOD_DELETE: |
| 452 |
** if remote attr not present, return NO_SUCH; |
| 453 |
** if remote attr present, drop this Mod; |
| 454 |
** else force this Mod to LDAP_MOD_ADD; |
| 455 |
** return CONTINUE; |
| 456 |
** |
| 457 |
*/ |
| 458 |
|
| 459 |
op->o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig; |
| 460 |
rc = be_entry_get_rw(op, &op->o_req_ndn, NULL, NULL, 0, &e); |
| 461 |
op->o_bd->bd_info = (BackendInfo *) on; |
| 462 |
|
| 463 |
if(e && rc == LDAP_SUCCESS) { |
| 464 |
Debug(LDAP_DEBUG_TRACE, "=> translucent_modify: found local entry\n" ); |
| 465 |
for(mm = &op->orm_modlist; *mm; ) { |
| 466 |
m = *mm; |
| 467 |
for(a = e->e_attrs; a; a = a->a_next) |
| 468 |
if(a->a_desc == m->sml_desc) break; |
| 469 |
if(a) { |
| 470 |
mm = &m->sml_next; |
| 471 |
continue; /* found local attr */ |
| 472 |
} |
| 473 |
if(m->sml_op == LDAP_MOD_DELETE) { |
| 474 |
for(a = re->e_attrs; a; a = a->a_next) |
| 475 |
if(a->a_desc == m->sml_desc) break; |
| 476 |
/* not found remote attr */ |
| 477 |
if(!a) { |
| 478 |
erc = LDAP_NO_SUCH_ATTRIBUTE; |
| 479 |
goto release; |
| 480 |
} |
| 481 |
if(ov->strict) { |
| 482 |
erc = LDAP_CONSTRAINT_VIOLATION; |
| 483 |
goto release; |
| 484 |
} |
| 485 |
Debug(LDAP_DEBUG_TRACE, |
| 486 |
"=> translucent_modify: silently dropping delete: %s\n", |
| 487 |
m->sml_desc->ad_cname.bv_val ); |
| 488 |
*mm = m->sml_next; |
| 489 |
m->sml_next = NULL; |
| 490 |
slap_mods_free(m, 1); |
| 491 |
continue; |
| 492 |
} |
| 493 |
m->sml_op = LDAP_MOD_ADD; |
| 494 |
mm = &m->sml_next; |
| 495 |
} |
| 496 |
erc = SLAP_CB_CONTINUE; |
| 497 |
release: |
| 498 |
if(re) { |
| 499 |
if(ov->db.bd_info->bi_entry_release_rw) { |
| 500 |
op->o_bd = &ov->db; |
| 501 |
ov->db.bd_info->bi_entry_release_rw(op, re, 0); |
| 502 |
op->o_bd = db; |
| 503 |
} else |
| 504 |
entry_free(re); |
| 505 |
} |
| 506 |
op->o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig; |
| 507 |
be_entry_release_r(op, e); |
| 508 |
op->o_bd->bd_info = (BackendInfo *) on; |
| 509 |
if(erc == SLAP_CB_CONTINUE) { |
| 510 |
return(erc); |
| 511 |
} else if(erc) { |
| 512 |
send_ldap_error(op, rs, erc, |
| 513 |
"attempt to delete nonexistent attribute"); |
| 514 |
return(erc); |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
/* don't leak remote entry copy */ |
| 519 |
if(re) { |
| 520 |
if(ov->db.bd_info->bi_entry_release_rw) { |
| 521 |
op->o_bd = &ov->db; |
| 522 |
ov->db.bd_info->bi_entry_release_rw(op, re, 0); |
| 523 |
op->o_bd = db; |
| 524 |
} else |
| 525 |
entry_free(re); |
| 526 |
} |
| 527 |
/* |
| 528 |
** foreach Modification: |
| 529 |
** if MOD_ADD or MOD_REPLACE, add Attribute; |
| 530 |
** if no Modifications were suitable: |
| 531 |
** if strict, throw CONSTRAINT_VIOLATION; |
| 532 |
** else, return early SUCCESS; |
| 533 |
** fabricate Entry with new Attribute chain; |
| 534 |
** glue_parent() for this Entry; |
| 535 |
** call bi_op_add() in local backend; |
| 536 |
** |
| 537 |
*/ |
| 538 |
|
| 539 |
Debug(LDAP_DEBUG_TRACE, "=> translucent_modify: fabricating local add\n" ); |
| 540 |
a = NULL; |
| 541 |
for(del = 0, ax = NULL, m = op->orm_modlist; m; m = m->sml_next) { |
| 542 |
Attribute atmp; |
| 543 |
if(((m->sml_op & LDAP_MOD_OP) != LDAP_MOD_ADD) && |
| 544 |
((m->sml_op & LDAP_MOD_OP) != LDAP_MOD_REPLACE)) { |
| 545 |
Debug(LDAP_DEBUG_ANY, |
| 546 |
"=> translucent_modify: silently dropped modification(%d): %s\n", |
| 547 |
m->sml_op, m->sml_desc->ad_cname.bv_val ); |
| 548 |
if((m->sml_op & LDAP_MOD_OP) == LDAP_MOD_DELETE) del++; |
| 549 |
continue; |
| 550 |
} |
| 551 |
atmp.a_desc = m->sml_desc; |
| 552 |
atmp.a_vals = m->sml_values; |
| 553 |
atmp.a_nvals = m->sml_nvalues ? m->sml_nvalues : atmp.a_vals; |
| 554 |
atmp.a_numvals = m->sml_numvals; |
| 555 |
atmp.a_flags = 0; |
| 556 |
a = attr_dup( &atmp ); |
| 557 |
a->a_next = ax; |
| 558 |
ax = a; |
| 559 |
} |
| 560 |
|
| 561 |
if(del && ov->strict) { |
| 562 |
attrs_free( a ); |
| 563 |
send_ldap_error(op, rs, LDAP_CONSTRAINT_VIOLATION, |
| 564 |
"attempt to delete attributes from local database"); |
| 565 |
return(rs->sr_err); |
| 566 |
} |
| 567 |
|
| 568 |
if(!ax) { |
| 569 |
if(ov->strict) { |
| 570 |
send_ldap_error(op, rs, LDAP_CONSTRAINT_VIOLATION, |
| 571 |
"modification contained other than ADD or REPLACE"); |
| 572 |
return(rs->sr_err); |
| 573 |
} |
| 574 |
/* rs->sr_text = "no valid modification found"; */ |
| 575 |
rs->sr_err = LDAP_SUCCESS; |
| 576 |
send_ldap_result(op, rs); |
| 577 |
return(rs->sr_err); |
| 578 |
} |
| 579 |
|
| 580 |
e = entry_alloc(); |
| 581 |
ber_dupbv( &e->e_name, &op->o_req_dn ); |
| 582 |
ber_dupbv( &e->e_nname, &op->o_req_ndn ); |
| 583 |
e->e_attrs = a; |
| 584 |
|
| 585 |
op->o_tag = LDAP_REQ_ADD; |
| 586 |
cb.sc_response = translucent_tag_cb; |
| 587 |
cb.sc_private = op->orm_modlist; |
| 588 |
op->oq_add.rs_e = e; |
| 589 |
|
| 590 |
glue_parent(op); |
| 591 |
|
| 592 |
cb.sc_next = op->o_callback; |
| 593 |
op->o_callback = &cb; |
| 594 |
rc = on->on_info->oi_orig->bi_op_add(op, &nrs); |
| 595 |
if ( op->ora_e == e ) |
| 596 |
entry_free( e ); |
| 597 |
op->o_callback = cb.sc_next; |
| 598 |
|
| 599 |
return(rc); |
| 600 |
} |
| 601 |
|
| 602 |
static int translucent_compare(Operation *op, SlapReply *rs) { |
| 603 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 604 |
translucent_info *ov = on->on_bi.bi_private; |
| 605 |
AttributeAssertion *ava = op->orc_ava; |
| 606 |
Entry *e = NULL; |
| 607 |
BackendDB *db; |
| 608 |
int rc; |
| 609 |
|
| 610 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_compare: <%s> %s:%s\n", |
| 611 |
op->o_req_dn.bv_val, ava->aa_desc->ad_cname.bv_val, ava->aa_value.bv_val); |
| 612 |
|
| 613 |
/* |
| 614 |
** if the local backend has an entry for this attribute: |
| 615 |
** CONTINUE and let it do the compare; |
| 616 |
** |
| 617 |
*/ |
| 618 |
rc = overlay_entry_get_ov(op, &op->o_req_ndn, NULL, ava->aa_desc, 0, &e, on); |
| 619 |
if(rc == LDAP_SUCCESS && e) { |
| 620 |
overlay_entry_release_ov(op, e, 0, on); |
| 621 |
return(SLAP_CB_CONTINUE); |
| 622 |
} |
| 623 |
|
| 624 |
if(ov->defer_db_open) { |
| 625 |
send_ldap_error(op, rs, LDAP_UNAVAILABLE, |
| 626 |
"remote DB not available"); |
| 627 |
return(rs->sr_err); |
| 628 |
} |
| 629 |
/* |
| 630 |
** call compare() in the captive backend; |
| 631 |
** return the result; |
| 632 |
** |
| 633 |
*/ |
| 634 |
db = op->o_bd; |
| 635 |
op->o_bd = &ov->db; |
| 636 |
ov->db.be_acl = op->o_bd->be_acl; |
| 637 |
rc = ov->db.bd_info->bi_op_compare(op, rs); |
| 638 |
op->o_bd = db; |
| 639 |
|
| 640 |
return(rc); |
| 641 |
} |
| 642 |
|
| 643 |
static int translucent_pwmod(Operation *op, SlapReply *rs) { |
| 644 |
SlapReply nrs = { REP_RESULT }; |
| 645 |
Operation nop; |
| 646 |
|
| 647 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 648 |
translucent_info *ov = on->on_bi.bi_private; |
| 649 |
Entry *e = NULL, *re = NULL; |
| 650 |
BackendDB *db; |
| 651 |
int rc = 0; |
| 652 |
slap_callback cb = { 0 }; |
| 653 |
|
| 654 |
if (!ov->pwmod_local) { |
| 655 |
rs->sr_err = LDAP_CONSTRAINT_VIOLATION, |
| 656 |
rs->sr_text = "attempt to modify password in local database"; |
| 657 |
return rs->sr_err; |
| 658 |
} |
| 659 |
|
| 660 |
/* |
| 661 |
** fetch entry from the captive backend; |
| 662 |
** if it did not exist, fail; |
| 663 |
** release it, if captive backend supports this; |
| 664 |
** |
| 665 |
*/ |
| 666 |
db = op->o_bd; |
| 667 |
op->o_bd = &ov->db; |
| 668 |
ov->db.be_acl = op->o_bd->be_acl; |
| 669 |
rc = ov->db.bd_info->bi_entry_get_rw(op, &op->o_req_ndn, NULL, NULL, 0, &re); |
| 670 |
if(rc != LDAP_SUCCESS || re == NULL ) { |
| 671 |
send_ldap_error((op), rs, LDAP_NO_SUCH_OBJECT, |
| 672 |
"attempt to modify nonexistent local record"); |
| 673 |
return(rs->sr_err); |
| 674 |
} |
| 675 |
op->o_bd = db; |
| 676 |
/* |
| 677 |
** fetch entry from local backend; |
| 678 |
** if it exists: |
| 679 |
** return CONTINUE; |
| 680 |
*/ |
| 681 |
|
| 682 |
op->o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig; |
| 683 |
rc = be_entry_get_rw(op, &op->o_req_ndn, NULL, NULL, 0, &e); |
| 684 |
op->o_bd->bd_info = (BackendInfo *) on; |
| 685 |
|
| 686 |
if(e && rc == LDAP_SUCCESS) { |
| 687 |
if(re) { |
| 688 |
if(ov->db.bd_info->bi_entry_release_rw) { |
| 689 |
op->o_bd = &ov->db; |
| 690 |
ov->db.bd_info->bi_entry_release_rw(op, re, 0); |
| 691 |
op->o_bd = db; |
| 692 |
} else { |
| 693 |
entry_free(re); |
| 694 |
} |
| 695 |
} |
| 696 |
op->o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig; |
| 697 |
be_entry_release_r(op, e); |
| 698 |
op->o_bd->bd_info = (BackendInfo *) on; |
| 699 |
return SLAP_CB_CONTINUE; |
| 700 |
} |
| 701 |
|
| 702 |
/* don't leak remote entry copy */ |
| 703 |
if(re) { |
| 704 |
if(ov->db.bd_info->bi_entry_release_rw) { |
| 705 |
op->o_bd = &ov->db; |
| 706 |
ov->db.bd_info->bi_entry_release_rw(op, re, 0); |
| 707 |
op->o_bd = db; |
| 708 |
} else { |
| 709 |
entry_free(re); |
| 710 |
} |
| 711 |
} |
| 712 |
/* |
| 713 |
** glue_parent() for this Entry; |
| 714 |
** call bi_op_add() in local backend; |
| 715 |
** |
| 716 |
*/ |
| 717 |
e = entry_alloc(); |
| 718 |
ber_dupbv( &e->e_name, &op->o_req_dn ); |
| 719 |
ber_dupbv( &e->e_nname, &op->o_req_ndn ); |
| 720 |
e->e_attrs = NULL; |
| 721 |
|
| 722 |
nop = *op; |
| 723 |
nop.o_tag = LDAP_REQ_ADD; |
| 724 |
cb.sc_response = slap_null_cb; |
| 725 |
nop.oq_add.rs_e = e; |
| 726 |
|
| 727 |
glue_parent(&nop); |
| 728 |
|
| 729 |
nop.o_callback = &cb; |
| 730 |
rc = on->on_info->oi_orig->bi_op_add(&nop, &nrs); |
| 731 |
if ( nop.ora_e == e ) { |
| 732 |
entry_free( e ); |
| 733 |
} |
| 734 |
|
| 735 |
if ( rc == LDAP_SUCCESS ) { |
| 736 |
return SLAP_CB_CONTINUE; |
| 737 |
} |
| 738 |
|
| 739 |
return rc; |
| 740 |
} |
| 741 |
|
| 742 |
static int translucent_exop(Operation *op, SlapReply *rs) { |
| 743 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 744 |
translucent_info *ov = on->on_bi.bi_private; |
| 745 |
const struct berval bv_exop_pwmod = BER_BVC(LDAP_EXOP_MODIFY_PASSWD); |
| 746 |
|
| 747 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_exop: %s\n", |
| 748 |
op->o_req_dn.bv_val ); |
| 749 |
|
| 750 |
if(ov->defer_db_open) { |
| 751 |
send_ldap_error(op, rs, LDAP_UNAVAILABLE, |
| 752 |
"remote DB not available"); |
| 753 |
return(rs->sr_err); |
| 754 |
} |
| 755 |
|
| 756 |
if ( bvmatch( &bv_exop_pwmod, &op->ore_reqoid ) ) { |
| 757 |
return translucent_pwmod( op, rs ); |
| 758 |
} |
| 759 |
|
| 760 |
return SLAP_CB_CONTINUE; |
| 761 |
} |
| 762 |
|
| 763 |
/* |
| 764 |
** translucent_search_cb() |
| 765 |
** merge local data with remote data |
| 766 |
** |
| 767 |
** Four cases: |
| 768 |
** 1: remote search, no local filter |
| 769 |
** merge data and send immediately |
| 770 |
** 2: remote search, with local filter |
| 771 |
** merge data and save |
| 772 |
** 3: local search, no remote filter |
| 773 |
** merge data and send immediately |
| 774 |
** 4: local search, with remote filter |
| 775 |
** check list, merge, send, delete |
| 776 |
*/ |
| 777 |
|
| 778 |
#define RMT_SIDE 0 |
| 779 |
#define LCL_SIDE 1 |
| 780 |
#define USE_LIST 2 |
| 781 |
|
| 782 |
typedef struct trans_ctx { |
| 783 |
BackendDB *db; |
| 784 |
slap_overinst *on; |
| 785 |
Filter *orig; |
| 786 |
TAvlnode *list; |
| 787 |
int step; |
| 788 |
int slimit; |
| 789 |
AttributeName *attrs; |
| 790 |
} trans_ctx; |
| 791 |
|
| 792 |
static int translucent_search_cb(Operation *op, SlapReply *rs) { |
| 793 |
trans_ctx *tc; |
| 794 |
BackendDB *db; |
| 795 |
slap_overinst *on; |
| 796 |
translucent_info *ov; |
| 797 |
Entry *le, *re; |
| 798 |
Attribute *a, *ax, *an, *as = NULL; |
| 799 |
int rc; |
| 800 |
int test_f = 0; |
| 801 |
|
| 802 |
tc = op->o_callback->sc_private; |
| 803 |
|
| 804 |
/* We took over the op, don't let it complete yet */ |
| 805 |
if ( rs->sr_type == REP_RESULT ) |
| 806 |
return 0; |
| 807 |
|
| 808 |
if(rs->sr_type != REP_SEARCH || !rs->sr_entry) |
| 809 |
return(SLAP_CB_CONTINUE); |
| 810 |
|
| 811 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_search_cb: %s\n", |
| 812 |
rs->sr_entry->e_name.bv_val ); |
| 813 |
|
| 814 |
op->ors_slimit = tc->slimit + ( tc->slimit > 0 ? 1 : 0 ); |
| 815 |
if ( op->ors_attrs == slap_anlist_all_attributes ) { |
| 816 |
op->ors_attrs = tc->attrs; |
| 817 |
rs->sr_attrs = tc->attrs; |
| 818 |
rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs ); |
| 819 |
} |
| 820 |
|
| 821 |
on = tc->on; |
| 822 |
ov = on->on_bi.bi_private; |
| 823 |
|
| 824 |
db = op->o_bd; |
| 825 |
re = NULL; |
| 826 |
|
| 827 |
/* If we have local, get remote */ |
| 828 |
if ( tc->step & LCL_SIDE ) { |
| 829 |
le = rs->sr_entry; |
| 830 |
/* If entry is already on list, use it */ |
| 831 |
if ( tc->step & USE_LIST ) { |
| 832 |
re = ldap_tavl_delete( &tc->list, le, entry_dn_cmp ); |
| 833 |
if ( re ) { |
| 834 |
rs_flush_entry( op, rs, on ); |
| 835 |
rc = test_filter( op, re, tc->orig ); |
| 836 |
if ( rc == LDAP_COMPARE_TRUE ) { |
| 837 |
rs->sr_flags |= REP_ENTRY_MUSTBEFREED; |
| 838 |
rs->sr_entry = re; |
| 839 |
|
| 840 |
if ( tc->slimit >= 0 && rs->sr_nentries >= tc->slimit ) { |
| 841 |
return LDAP_SIZELIMIT_EXCEEDED; |
| 842 |
} |
| 843 |
|
| 844 |
return SLAP_CB_CONTINUE; |
| 845 |
} else { |
| 846 |
entry_free( re ); |
| 847 |
rs->sr_entry = NULL; |
| 848 |
return 0; |
| 849 |
} |
| 850 |
} |
| 851 |
} |
| 852 |
op->o_bd = &ov->db; |
| 853 |
rc = be_entry_get_rw( op, &rs->sr_entry->e_nname, NULL, NULL, 0, &re ); |
| 854 |
if ( rc == LDAP_SUCCESS && re ) { |
| 855 |
Entry *tmp = entry_dup( re ); |
| 856 |
be_entry_release_r( op, re ); |
| 857 |
re = tmp; |
| 858 |
test_f = 1; |
| 859 |
} |
| 860 |
} else { |
| 861 |
/* Else we have remote, get local */ |
| 862 |
op->o_bd = tc->db; |
| 863 |
le = NULL; |
| 864 |
rc = overlay_entry_get_ov(op, &rs->sr_entry->e_nname, NULL, NULL, 0, &le, on); |
| 865 |
if ( rc == LDAP_SUCCESS && le ) { |
| 866 |
re = entry_dup( rs->sr_entry ); |
| 867 |
rs_flush_entry( op, rs, on ); |
| 868 |
} else { |
| 869 |
le = NULL; |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
/* |
| 874 |
** if we got remote and local entry: |
| 875 |
** foreach local attr: |
| 876 |
** foreach remote attr: |
| 877 |
** if match, remote attr with local attr; |
| 878 |
** if new local, add to list; |
| 879 |
** append new local attrs to remote; |
| 880 |
** |
| 881 |
*/ |
| 882 |
|
| 883 |
if ( re && le ) { |
| 884 |
for(ax = le->e_attrs; ax; ax = ax->a_next) { |
| 885 |
for(a = re->e_attrs; a; a = a->a_next) { |
| 886 |
if(a->a_desc == ax->a_desc) { |
| 887 |
test_f = 1; |
| 888 |
if(a->a_vals != a->a_nvals) |
| 889 |
ber_bvarray_free(a->a_nvals); |
| 890 |
ber_bvarray_free(a->a_vals); |
| 891 |
ber_bvarray_dup_x( &a->a_vals, ax->a_vals, NULL ); |
| 892 |
if ( ax->a_vals == ax->a_nvals ) { |
| 893 |
a->a_nvals = a->a_vals; |
| 894 |
} else { |
| 895 |
ber_bvarray_dup_x( &a->a_nvals, ax->a_nvals, NULL ); |
| 896 |
} |
| 897 |
break; |
| 898 |
} |
| 899 |
} |
| 900 |
if(a) continue; |
| 901 |
an = attr_dup(ax); |
| 902 |
an->a_next = as; |
| 903 |
as = an; |
| 904 |
} |
| 905 |
/* Dispose of local entry */ |
| 906 |
if ( tc->step & LCL_SIDE ) { |
| 907 |
rs_flush_entry(op, rs, on); |
| 908 |
} else { |
| 909 |
overlay_entry_release_ov(op, le, 0, on); |
| 910 |
} |
| 911 |
|
| 912 |
/* literally append, so locals are always last */ |
| 913 |
if(as) { |
| 914 |
if(re->e_attrs) { |
| 915 |
for(ax = re->e_attrs; ax->a_next; ax = ax->a_next); |
| 916 |
ax->a_next = as; |
| 917 |
} else { |
| 918 |
re->e_attrs = as; |
| 919 |
} |
| 920 |
} |
| 921 |
/* If both filters, save entry for later */ |
| 922 |
if ( tc->step == (USE_LIST|RMT_SIDE) ) { |
| 923 |
ldap_tavl_insert( &tc->list, re, entry_dn_cmp, ldap_avl_dup_error ); |
| 924 |
rs->sr_entry = NULL; |
| 925 |
rc = 0; |
| 926 |
} else { |
| 927 |
/* send it now */ |
| 928 |
rs->sr_entry = re; |
| 929 |
rs->sr_flags |= REP_ENTRY_MUSTBEFREED; |
| 930 |
if ( test_f ) { |
| 931 |
rc = test_filter( op, rs->sr_entry, tc->orig ); |
| 932 |
if ( rc == LDAP_COMPARE_TRUE ) { |
| 933 |
rc = SLAP_CB_CONTINUE; |
| 934 |
} else { |
| 935 |
rc = 0; |
| 936 |
} |
| 937 |
} else { |
| 938 |
rc = SLAP_CB_CONTINUE; |
| 939 |
} |
| 940 |
} |
| 941 |
} else if ( le ) { |
| 942 |
/* Only a local entry: remote was deleted |
| 943 |
* Ought to delete the local too... |
| 944 |
*/ |
| 945 |
rc = 0; |
| 946 |
} else if ( tc->step & USE_LIST ) { |
| 947 |
/* Only a remote entry, but both filters: |
| 948 |
* Test the complete filter |
| 949 |
*/ |
| 950 |
rc = test_filter( op, rs->sr_entry, tc->orig ); |
| 951 |
if ( rc == LDAP_COMPARE_TRUE ) { |
| 952 |
rc = SLAP_CB_CONTINUE; |
| 953 |
} else { |
| 954 |
rc = 0; |
| 955 |
} |
| 956 |
} else { |
| 957 |
/* Only a remote entry, only remote filter: |
| 958 |
* just pass thru |
| 959 |
*/ |
| 960 |
rc = SLAP_CB_CONTINUE; |
| 961 |
} |
| 962 |
|
| 963 |
op->o_bd = db; |
| 964 |
|
| 965 |
if ( rc == SLAP_CB_CONTINUE && tc->slimit >= 0 && rs->sr_nentries >= tc->slimit ) { |
| 966 |
return LDAP_SIZELIMIT_EXCEEDED; |
| 967 |
} |
| 968 |
|
| 969 |
return rc; |
| 970 |
} |
| 971 |
|
| 972 |
/* Dup the filter, excluding invalid elements */ |
| 973 |
static Filter * |
| 974 |
trans_filter_dup(Operation *op, Filter *f, AttributeName *an) |
| 975 |
{ |
| 976 |
Filter *n = NULL; |
| 977 |
|
| 978 |
if ( !f ) |
| 979 |
return NULL; |
| 980 |
|
| 981 |
switch( f->f_choice & SLAPD_FILTER_MASK ) { |
| 982 |
case SLAPD_FILTER_COMPUTED: |
| 983 |
n = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
| 984 |
n->f_choice = f->f_choice; |
| 985 |
n->f_result = f->f_result; |
| 986 |
n->f_next = NULL; |
| 987 |
break; |
| 988 |
|
| 989 |
case LDAP_FILTER_PRESENT: |
| 990 |
if ( ad_inlist( f->f_desc, an )) { |
| 991 |
n = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
| 992 |
n->f_choice = f->f_choice; |
| 993 |
n->f_desc = f->f_desc; |
| 994 |
n->f_next = NULL; |
| 995 |
} |
| 996 |
break; |
| 997 |
|
| 998 |
case LDAP_FILTER_EQUALITY: |
| 999 |
case LDAP_FILTER_GE: |
| 1000 |
case LDAP_FILTER_LE: |
| 1001 |
case LDAP_FILTER_APPROX: |
| 1002 |
case LDAP_FILTER_EXT: |
| 1003 |
if ( !f->f_av_desc || ad_inlist( f->f_av_desc, an )) { |
| 1004 |
AttributeAssertion *nava; |
| 1005 |
|
| 1006 |
n = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
| 1007 |
n->f_choice = f->f_choice; |
| 1008 |
|
| 1009 |
nava = op->o_tmpalloc( sizeof(AttributeAssertion), op->o_tmpmemctx ); |
| 1010 |
*nava = *f->f_ava; |
| 1011 |
n->f_ava = nava; |
| 1012 |
|
| 1013 |
ber_dupbv_x( &n->f_av_value, &f->f_av_value, op->o_tmpmemctx ); |
| 1014 |
n->f_next = NULL; |
| 1015 |
} |
| 1016 |
break; |
| 1017 |
|
| 1018 |
case LDAP_FILTER_SUBSTRINGS: |
| 1019 |
if ( !f->f_av_desc || ad_inlist( f->f_av_desc, an )) { |
| 1020 |
SubstringsAssertion *nsub; |
| 1021 |
|
| 1022 |
n = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
| 1023 |
n->f_choice = f->f_choice; |
| 1024 |
|
| 1025 |
nsub = op->o_tmpalloc( sizeof(SubstringsAssertion), op->o_tmpmemctx ); |
| 1026 |
*nsub = *f->f_sub; |
| 1027 |
n->f_sub = nsub; |
| 1028 |
|
| 1029 |
if ( !BER_BVISNULL( &f->f_sub_initial )) |
| 1030 |
ber_dupbv_x( &n->f_sub_initial, &f->f_sub_initial, op->o_tmpmemctx ); |
| 1031 |
|
| 1032 |
ber_bvarray_dup_x( &n->f_sub_any, f->f_sub_any, op->o_tmpmemctx ); |
| 1033 |
|
| 1034 |
if ( !BER_BVISNULL( &f->f_sub_final )) |
| 1035 |
ber_dupbv_x( &n->f_sub_final, &f->f_sub_final, op->o_tmpmemctx ); |
| 1036 |
|
| 1037 |
n->f_next = NULL; |
| 1038 |
} |
| 1039 |
break; |
| 1040 |
|
| 1041 |
case LDAP_FILTER_AND: |
| 1042 |
case LDAP_FILTER_OR: |
| 1043 |
case LDAP_FILTER_NOT: { |
| 1044 |
Filter **p; |
| 1045 |
|
| 1046 |
n = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
| 1047 |
n->f_choice = f->f_choice; |
| 1048 |
n->f_next = NULL; |
| 1049 |
|
| 1050 |
for ( p = &n->f_list, f = f->f_list; f; f = f->f_next ) { |
| 1051 |
*p = trans_filter_dup( op, f, an ); |
| 1052 |
if ( !*p ) |
| 1053 |
continue; |
| 1054 |
p = &(*p)->f_next; |
| 1055 |
} |
| 1056 |
/* nothing valid in this list */ |
| 1057 |
if ( !n->f_list ) { |
| 1058 |
op->o_tmpfree( n, op->o_tmpmemctx ); |
| 1059 |
return NULL; |
| 1060 |
} |
| 1061 |
/* Only 1 element in this list */ |
| 1062 |
if ((n->f_choice & SLAPD_FILTER_MASK) != LDAP_FILTER_NOT && |
| 1063 |
!n->f_list->f_next ) { |
| 1064 |
f = n->f_list; |
| 1065 |
*n = *f; |
| 1066 |
op->o_tmpfree( f, op->o_tmpmemctx ); |
| 1067 |
} |
| 1068 |
break; |
| 1069 |
} |
| 1070 |
} |
| 1071 |
return n; |
| 1072 |
} |
| 1073 |
|
| 1074 |
static void |
| 1075 |
trans_filter_free( Operation *op, Filter *f ) |
| 1076 |
{ |
| 1077 |
Filter *n, *p, *next; |
| 1078 |
|
| 1079 |
f->f_choice &= SLAPD_FILTER_MASK; |
| 1080 |
|
| 1081 |
switch( f->f_choice ) { |
| 1082 |
case LDAP_FILTER_AND: |
| 1083 |
case LDAP_FILTER_OR: |
| 1084 |
case LDAP_FILTER_NOT: |
| 1085 |
/* Free in reverse order */ |
| 1086 |
n = NULL; |
| 1087 |
for ( p = f->f_list; p; p = next ) { |
| 1088 |
next = p->f_next; |
| 1089 |
p->f_next = n; |
| 1090 |
n = p; |
| 1091 |
} |
| 1092 |
for ( p = n; p; p = next ) { |
| 1093 |
next = p->f_next; |
| 1094 |
trans_filter_free( op, p ); |
| 1095 |
} |
| 1096 |
break; |
| 1097 |
case LDAP_FILTER_EQUALITY: |
| 1098 |
case LDAP_FILTER_GE: |
| 1099 |
case LDAP_FILTER_LE: |
| 1100 |
case LDAP_FILTER_APPROX: |
| 1101 |
case LDAP_FILTER_SUBSTRINGS: |
| 1102 |
case LDAP_FILTER_EXT: |
| 1103 |
op->o_tmpfree( f->f_av_value.bv_val, op->o_tmpmemctx ); |
| 1104 |
op->o_tmpfree( f->f_ava, op->o_tmpmemctx ); |
| 1105 |
break; |
| 1106 |
default: |
| 1107 |
break; |
| 1108 |
} |
| 1109 |
op->o_tmpfree( f, op->o_tmpmemctx ); |
| 1110 |
} |
| 1111 |
|
| 1112 |
static int |
| 1113 |
translucent_search_cleanup( Operation *op, SlapReply *rs ) |
| 1114 |
{ |
| 1115 |
trans_ctx *tc = op->o_callback->sc_private; |
| 1116 |
|
| 1117 |
op->ors_filter = tc->orig; |
| 1118 |
return LDAP_SUCCESS; |
| 1119 |
} |
| 1120 |
|
| 1121 |
/* |
| 1122 |
** translucent_search() |
| 1123 |
** search via captive backend; |
| 1124 |
** override results with any local data; |
| 1125 |
** |
| 1126 |
*/ |
| 1127 |
|
| 1128 |
static int translucent_search(Operation *op, SlapReply *rs) { |
| 1129 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 1130 |
translucent_info *ov = on->on_bi.bi_private; |
| 1131 |
slap_callback cb = { NULL, NULL, NULL, NULL }; |
| 1132 |
trans_ctx tc; |
| 1133 |
Filter *fl, *fr; |
| 1134 |
struct berval fbv; |
| 1135 |
int rc = 0; |
| 1136 |
|
| 1137 |
if ( op->o_managedsait > SLAP_CONTROL_IGNORED ) |
| 1138 |
return SLAP_CB_CONTINUE; |
| 1139 |
|
| 1140 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_search: <%s> %s\n", |
| 1141 |
op->o_req_dn.bv_val, op->ors_filterstr.bv_val ); |
| 1142 |
|
| 1143 |
if(ov->defer_db_open) { |
| 1144 |
send_ldap_error(op, rs, LDAP_UNAVAILABLE, |
| 1145 |
"remote DB not available"); |
| 1146 |
return(rs->sr_err); |
| 1147 |
} |
| 1148 |
|
| 1149 |
fr = ov->remote ? trans_filter_dup( op, op->ors_filter, ov->remote ) : NULL; |
| 1150 |
fl = ov->local ? trans_filter_dup( op, op->ors_filter, ov->local ) : NULL; |
| 1151 |
cb.sc_response = (slap_response *) translucent_search_cb; |
| 1152 |
cb.sc_cleanup = (slap_response *) translucent_search_cleanup; |
| 1153 |
cb.sc_private = &tc; |
| 1154 |
|
| 1155 |
ov->db.be_acl = op->o_bd->be_acl; |
| 1156 |
tc.db = op->o_bd; |
| 1157 |
tc.on = on; |
| 1158 |
tc.orig = op->ors_filter; |
| 1159 |
tc.list = NULL; |
| 1160 |
tc.step = 0; |
| 1161 |
tc.slimit = op->ors_slimit; |
| 1162 |
tc.attrs = NULL; |
| 1163 |
fbv = op->ors_filterstr; |
| 1164 |
|
| 1165 |
if ( fr || !fl ) { |
| 1166 |
Operation op2; |
| 1167 |
Opheader oh; |
| 1168 |
|
| 1169 |
op2 = *op; |
| 1170 |
oh = *op->o_hdr; |
| 1171 |
oh.oh_conn = op->o_conn; |
| 1172 |
oh.oh_connid = op->o_connid; |
| 1173 |
op2.o_bd = &ov->db; |
| 1174 |
op2.o_hdr = &oh; |
| 1175 |
op2.o_extra = op->o_extra; |
| 1176 |
op2.o_callback = &cb; |
| 1177 |
op2.ors_attrs = slap_anlist_all_attributes; |
| 1178 |
|
| 1179 |
tc.attrs = op->ors_attrs; |
| 1180 |
op->ors_slimit = SLAP_NO_LIMIT; |
| 1181 |
op->ors_attrs = slap_anlist_all_attributes; |
| 1182 |
tc.step |= RMT_SIDE; |
| 1183 |
if ( fl ) { |
| 1184 |
tc.step |= USE_LIST; |
| 1185 |
op->ors_filter = fr; |
| 1186 |
filter2bv_x( op, fr, &op2.ors_filterstr ); |
| 1187 |
} |
| 1188 |
rc = ov->db.bd_info->bi_op_search( &op2, rs ); |
| 1189 |
if ( op->ors_attrs == slap_anlist_all_attributes ) |
| 1190 |
op->ors_attrs = tc.attrs; |
| 1191 |
if ( fl ) { |
| 1192 |
op->o_tmpfree( op2.ors_filterstr.bv_val, op2.o_tmpmemctx ); |
| 1193 |
} |
| 1194 |
} |
| 1195 |
|
| 1196 |
cb.sc_next = op->o_callback; |
| 1197 |
op->o_callback = &cb; |
| 1198 |
|
| 1199 |
if ( fl && !rc ) { |
| 1200 |
tc.step |= LCL_SIDE; |
| 1201 |
op->ors_filter = fl; |
| 1202 |
filter2bv_x( op, fl, &op->ors_filterstr ); |
| 1203 |
rc = overlay_op_walk( op, rs, op_search, on->on_info, on->on_next ); |
| 1204 |
op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx ); |
| 1205 |
} |
| 1206 |
op->ors_filterstr = fbv; |
| 1207 |
op->o_callback = cb.sc_next; |
| 1208 |
rs->sr_attrs = op->ors_attrs; |
| 1209 |
rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs ); |
| 1210 |
|
| 1211 |
/* Send out anything remaining on the list and finish */ |
| 1212 |
if ( tc.step & USE_LIST ) { |
| 1213 |
if ( tc.list ) { |
| 1214 |
TAvlnode *av; |
| 1215 |
|
| 1216 |
av = ldap_tavl_end( tc.list, TAVL_DIR_LEFT ); |
| 1217 |
while ( av ) { |
| 1218 |
rs->sr_entry = av->avl_data; |
| 1219 |
if ( rc == LDAP_SUCCESS && LDAP_COMPARE_TRUE == |
| 1220 |
test_filter( op, rs->sr_entry, op->ors_filter )) |
| 1221 |
{ |
| 1222 |
rs->sr_flags = REP_ENTRY_MUSTBEFREED; |
| 1223 |
rc = send_search_entry( op, rs ); |
| 1224 |
} else { |
| 1225 |
entry_free( rs->sr_entry ); |
| 1226 |
} |
| 1227 |
av = ldap_tavl_next( av, TAVL_DIR_RIGHT ); |
| 1228 |
} |
| 1229 |
ldap_tavl_free( tc.list, NULL ); |
| 1230 |
rs->sr_flags = 0; |
| 1231 |
rs->sr_entry = NULL; |
| 1232 |
} |
| 1233 |
} |
| 1234 |
|
| 1235 |
send_ldap_result( op, rs ); |
| 1236 |
op->ors_slimit = tc.slimit; |
| 1237 |
|
| 1238 |
/* Free in reverse order */ |
| 1239 |
if ( fl ) |
| 1240 |
trans_filter_free( op, fl ); |
| 1241 |
if ( fr ) |
| 1242 |
trans_filter_free( op, fr ); |
| 1243 |
|
| 1244 |
return rc; |
| 1245 |
} |
| 1246 |
|
| 1247 |
|
| 1248 |
/* |
| 1249 |
** translucent_bind() |
| 1250 |
** pass bind request to captive backend; |
| 1251 |
** |
| 1252 |
*/ |
| 1253 |
|
| 1254 |
static int translucent_bind(Operation *op, SlapReply *rs) { |
| 1255 |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
| 1256 |
translucent_info *ov = on->on_bi.bi_private; |
| 1257 |
BackendDB *db; |
| 1258 |
slap_callback sc = { 0 }, *save_cb; |
| 1259 |
int rc; |
| 1260 |
|
| 1261 |
Debug(LDAP_DEBUG_TRACE, "translucent_bind: <%s> method %d\n", |
| 1262 |
op->o_req_dn.bv_val, op->orb_method ); |
| 1263 |
|
| 1264 |
if(ov->defer_db_open) { |
| 1265 |
send_ldap_error(op, rs, LDAP_UNAVAILABLE, |
| 1266 |
"remote DB not available"); |
| 1267 |
return(rs->sr_err); |
| 1268 |
} |
| 1269 |
|
| 1270 |
if (ov->bind_local) { |
| 1271 |
sc.sc_response = slap_null_cb; |
| 1272 |
save_cb = op->o_callback; |
| 1273 |
op->o_callback = ≻ |
| 1274 |
} |
| 1275 |
|
| 1276 |
db = op->o_bd; |
| 1277 |
op->o_bd = &ov->db; |
| 1278 |
ov->db.be_acl = op->o_bd->be_acl; |
| 1279 |
rc = ov->db.bd_info->bi_op_bind(op, rs); |
| 1280 |
op->o_bd = db; |
| 1281 |
|
| 1282 |
if (ov->bind_local) { |
| 1283 |
op->o_callback = save_cb; |
| 1284 |
if (rc != LDAP_SUCCESS) { |
| 1285 |
rc = SLAP_CB_CONTINUE; |
| 1286 |
} |
| 1287 |
} |
| 1288 |
|
| 1289 |
return rc; |
| 1290 |
} |
| 1291 |
|
| 1292 |
/* |
| 1293 |
** translucent_connection_destroy() |
| 1294 |
** pass disconnect notification to captive backend; |
| 1295 |
** |
| 1296 |
*/ |
| 1297 |
|
| 1298 |
static int translucent_connection_destroy(BackendDB *be, Connection *conn) { |
| 1299 |
slap_overinst *on = (slap_overinst *) be->bd_info; |
| 1300 |
translucent_info *ov = on->on_bi.bi_private; |
| 1301 |
int rc = 0; |
| 1302 |
|
| 1303 |
Debug(LDAP_DEBUG_TRACE, "translucent_connection_destroy\n" ); |
| 1304 |
|
| 1305 |
rc = ov->db.bd_info->bi_connection_destroy(&ov->db, conn); |
| 1306 |
|
| 1307 |
return(rc); |
| 1308 |
} |
| 1309 |
|
| 1310 |
/* |
| 1311 |
** translucent_db_config() |
| 1312 |
** pass config directives to captive backend; |
| 1313 |
** parse unrecognized directives ourselves; |
| 1314 |
** |
| 1315 |
*/ |
| 1316 |
|
| 1317 |
static int translucent_db_config( |
| 1318 |
BackendDB *be, |
| 1319 |
const char *fname, |
| 1320 |
int lineno, |
| 1321 |
int argc, |
| 1322 |
char **argv |
| 1323 |
) |
| 1324 |
{ |
| 1325 |
slap_overinst *on = (slap_overinst *) be->bd_info; |
| 1326 |
translucent_info *ov = on->on_bi.bi_private; |
| 1327 |
|
| 1328 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_db_config: %s\n", |
| 1329 |
argc ? argv[0] : "" ); |
| 1330 |
|
| 1331 |
/* Something for the captive database? */ |
| 1332 |
if ( ov->db.bd_info && ov->db.bd_info->bi_db_config ) |
| 1333 |
return ov->db.bd_info->bi_db_config( &ov->db, fname, lineno, |
| 1334 |
argc, argv ); |
| 1335 |
return SLAP_CONF_UNKNOWN; |
| 1336 |
} |
| 1337 |
|
| 1338 |
/* |
| 1339 |
** translucent_db_init() |
| 1340 |
** initialize the captive backend; |
| 1341 |
** |
| 1342 |
*/ |
| 1343 |
|
| 1344 |
static int translucent_db_init(BackendDB *be, ConfigReply *cr) { |
| 1345 |
slap_overinst *on = (slap_overinst *) be->bd_info; |
| 1346 |
translucent_info *ov; |
| 1347 |
|
| 1348 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_db_init\n" ); |
| 1349 |
|
| 1350 |
ov = ch_calloc(1, sizeof(translucent_info)); |
| 1351 |
on->on_bi.bi_private = ov; |
| 1352 |
ov->db = *be; |
| 1353 |
ov->db.be_private = NULL; |
| 1354 |
ov->defer_db_open = 1; |
| 1355 |
|
| 1356 |
if ( !backend_db_init( "ldap", &ov->db, -1, NULL )) { |
| 1357 |
Debug( LDAP_DEBUG_CONFIG, "translucent: unable to open captive back-ldap\n" ); |
| 1358 |
return 1; |
| 1359 |
} |
| 1360 |
SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK; |
| 1361 |
SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD; |
| 1362 |
|
| 1363 |
return 0; |
| 1364 |
} |
| 1365 |
|
| 1366 |
/* |
| 1367 |
** translucent_db_open() |
| 1368 |
** if the captive backend has an open() method, call it; |
| 1369 |
** |
| 1370 |
*/ |
| 1371 |
|
| 1372 |
static int translucent_db_open(BackendDB *be, ConfigReply *cr) { |
| 1373 |
slap_overinst *on = (slap_overinst *) be->bd_info; |
| 1374 |
translucent_info *ov = on->on_bi.bi_private; |
| 1375 |
int rc; |
| 1376 |
|
| 1377 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_db_open\n" ); |
| 1378 |
|
| 1379 |
/* need to inherit something from the original database... */ |
| 1380 |
ov->db.be_def_limit = be->be_def_limit; |
| 1381 |
ov->db.be_limits = be->be_limits; |
| 1382 |
ov->db.be_acl = be->be_acl; |
| 1383 |
ov->db.be_dfltaccess = be->be_dfltaccess; |
| 1384 |
|
| 1385 |
if ( ov->defer_db_open ) |
| 1386 |
return 0; |
| 1387 |
|
| 1388 |
rc = backend_startup_one( &ov->db, cr ); |
| 1389 |
|
| 1390 |
if(rc) Debug(LDAP_DEBUG_TRACE, |
| 1391 |
"translucent: bi_db_open() returned error %d\n", rc ); |
| 1392 |
|
| 1393 |
return(rc); |
| 1394 |
} |
| 1395 |
|
| 1396 |
/* |
| 1397 |
** translucent_db_close() |
| 1398 |
** if the captive backend has a close() method, call it |
| 1399 |
** |
| 1400 |
*/ |
| 1401 |
|
| 1402 |
static int |
| 1403 |
translucent_db_close( BackendDB *be, ConfigReply *cr ) |
| 1404 |
{ |
| 1405 |
slap_overinst *on = (slap_overinst *) be->bd_info; |
| 1406 |
translucent_info *ov = on->on_bi.bi_private; |
| 1407 |
int rc = 0; |
| 1408 |
|
| 1409 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_db_close\n" ); |
| 1410 |
|
| 1411 |
if ( ov && ov->db.bd_info && ov->db.bd_info->bi_db_close ) { |
| 1412 |
rc = ov->db.bd_info->bi_db_close(&ov->db, NULL); |
| 1413 |
} |
| 1414 |
|
| 1415 |
return(rc); |
| 1416 |
} |
| 1417 |
|
| 1418 |
/* |
| 1419 |
** translucent_db_destroy() |
| 1420 |
** if the captive backend has a db_destroy() method, call it; |
| 1421 |
** free any config data |
| 1422 |
** |
| 1423 |
*/ |
| 1424 |
|
| 1425 |
static int |
| 1426 |
translucent_db_destroy( BackendDB *be, ConfigReply *cr ) |
| 1427 |
{ |
| 1428 |
slap_overinst *on = (slap_overinst *) be->bd_info; |
| 1429 |
translucent_info *ov = on->on_bi.bi_private; |
| 1430 |
int rc = 0; |
| 1431 |
|
| 1432 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_db_destroy\n" ); |
| 1433 |
|
| 1434 |
if ( ov ) { |
| 1435 |
if ( ov->remote ) |
| 1436 |
anlist_free( ov->remote, 1, NULL ); |
| 1437 |
if ( ov->local ) |
| 1438 |
anlist_free( ov->local, 1, NULL ); |
| 1439 |
if ( ov->db.be_private != NULL ) { |
| 1440 |
backend_stopdown_one( &ov->db ); |
| 1441 |
} |
| 1442 |
|
| 1443 |
ldap_pvt_thread_mutex_destroy( &ov->db.be_pcsn_st.be_pcsn_mutex ); |
| 1444 |
ch_free(ov); |
| 1445 |
on->on_bi.bi_private = NULL; |
| 1446 |
} |
| 1447 |
|
| 1448 |
return(rc); |
| 1449 |
} |
| 1450 |
|
| 1451 |
/* |
| 1452 |
** translucent_initialize() |
| 1453 |
** initialize the slap_overinst with our entry points; |
| 1454 |
** |
| 1455 |
*/ |
| 1456 |
|
| 1457 |
int translucent_initialize() { |
| 1458 |
|
| 1459 |
int rc; |
| 1460 |
|
| 1461 |
/* olcDatabaseDummy is defined in slapd, and Windows |
| 1462 |
will not let us initialize a struct element with a data pointer |
| 1463 |
from another library, so we have to initialize this element |
| 1464 |
"by hand". */ |
| 1465 |
translucentocs[1].co_table = olcDatabaseDummy; |
| 1466 |
|
| 1467 |
Debug(LDAP_DEBUG_TRACE, "==> translucent_initialize\n" ); |
| 1468 |
|
| 1469 |
translucent.on_bi.bi_type = "translucent"; |
| 1470 |
translucent.on_bi.bi_db_init = translucent_db_init; |
| 1471 |
translucent.on_bi.bi_db_config = translucent_db_config; |
| 1472 |
translucent.on_bi.bi_db_open = translucent_db_open; |
| 1473 |
translucent.on_bi.bi_db_close = translucent_db_close; |
| 1474 |
translucent.on_bi.bi_db_destroy = translucent_db_destroy; |
| 1475 |
translucent.on_bi.bi_op_bind = translucent_bind; |
| 1476 |
translucent.on_bi.bi_op_add = translucent_add; |
| 1477 |
translucent.on_bi.bi_op_modify = translucent_modify; |
| 1478 |
translucent.on_bi.bi_op_modrdn = translucent_modrdn; |
| 1479 |
translucent.on_bi.bi_op_delete = translucent_delete; |
| 1480 |
translucent.on_bi.bi_op_search = translucent_search; |
| 1481 |
translucent.on_bi.bi_op_compare = translucent_compare; |
| 1482 |
translucent.on_bi.bi_connection_destroy = translucent_connection_destroy; |
| 1483 |
translucent.on_bi.bi_extended = translucent_exop; |
| 1484 |
|
| 1485 |
translucent.on_bi.bi_cf_ocs = translucentocs; |
| 1486 |
rc = config_register_schema ( translucentcfg, translucentocs ); |
| 1487 |
if ( rc ) return rc; |
| 1488 |
|
| 1489 |
return(overlay_register(&translucent)); |
| 1490 |
} |
| 1491 |
|
| 1492 |
#if SLAPD_OVER_TRANSLUCENT == SLAPD_MOD_DYNAMIC && defined(PIC) |
| 1493 |
int init_module(int argc, char *argv[]) { |
| 1494 |
return translucent_initialize(); |
| 1495 |
} |
| 1496 |
#endif |
| 1497 |
|
| 1498 |
#endif /* SLAPD_OVER_TRANSLUCENT */ |