#ifdef LDAP_SLAPI
#include "slapi/slapi.h"
-static void init_add_pblock( Operation *op, struct berval *dn, Entry *e, int manageDSAit );
+static void init_add_pblock( Operation *op, struct berval *dn, Entry *e,
+ int manageDSAit );
static int call_add_preop_plugins( Operation *op );
static void call_add_postop_plugins( Operation *op );
#endif /* LDAP_SLAPI */
{
BerElement *ber = op->o_ber;
char *last;
- struct berval dn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
ber_len_t len;
ber_tag_t tag;
Entry *e;
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
- rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
+ rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
+ op->o_tmpmemctx );
if( rs->sr_err != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
int repl_user = be_isupdate( op );
#ifndef SLAPD_MULTIMASTER
if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#else
- if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ))
#endif
{
int update = op->o_bd->be_update_ndn.bv_len;
/* check if the values we're adding already exist */
if( mr == NULL || !mr->smr_match ) {
- for ( i = 0; mods->sml_bvalues[i].bv_val != NULL; i++ ) {
+ for ( i = 1; mods->sml_values[i].bv_val != NULL; i++ ) {
/* test asserted values against themselves */
for( j = 0; j < i; j++ ) {
- if ( bvmatch( &mods->sml_bvalues[i],
- &mods->sml_bvalues[j] ) ) {
+ if ( bvmatch( &mods->sml_values[i],
+ &mods->sml_values[j] ) )
+ {
/* value exists already */
snprintf( textbuf, textlen,
"%s: value #%d provided more than once",
int rc = LDAP_SUCCESS;
int match;
- for ( i = 0; mods->sml_values[i].bv_val != NULL; i++ ) {
+ for ( i = 1; mods->sml_values[i].bv_val != NULL; i++ ) {
/* test asserted values against themselves */
for( j = 0; j < i; j++ ) {
rc = value_match( &match, mods->sml_desc, mr,
- SLAP_MR_EQUALITY | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
+ SLAP_MR_EQUALITY
+ | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
| SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
| SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
mods->sml_nvalues
/* move ad to attr structure */
attr->a_desc = mods->sml_desc;
- if ( !dup )
- mods->sml_desc = NULL;
+ if ( !dup ) mods->sml_desc = NULL;
/* move values to attr structure */
/* should check for duplicates */
if ( dup ) {
int i;
- for ( i = 0; mods->sml_values[i].bv_val; i++ ) ;
+ for ( i = 0; mods->sml_values[i].bv_val; i++ ) /* EMPTY */;
attr->a_vals = (BerVarray) ch_calloc( i+1, sizeof( BerValue ));
- for ( i = 0; mods->sml_values[i].bv_val; i++ )
+ for ( i = 0; mods->sml_values[i].bv_val; i++ ) {
ber_dupbv( &attr->a_vals[i], &mods->sml_values[i] );
+ }
attr->a_vals[i].bv_len = 0;
attr->a_vals[i].bv_val = NULL;
} else {
if ( mods->sml_nvalues ) {
if ( dup ) {
int i;
- for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) ;
+ for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) /* EMPTY */;
attr->a_nvals = (BerVarray) ch_calloc( i+1, sizeof( BerValue ));
- for ( i = 0; mods->sml_nvalues[i].bv_val; i++ )
+ for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) {
ber_dupbv( &attr->a_nvals[i], &mods->sml_nvalues[i] );
+ }
attr->a_nvals[i].bv_len = 0;
attr->a_nvals[i].bv_val = NULL;
} else {
mod->sml_type = a_new_desc->ad_cname;
- for ( count = 0; a_new->a_vals[count].bv_val; count++ );
+ for ( count = 0; a_new->a_vals[count].bv_val; count++ ) /* EMPTY */;
- mod->sml_bvalues = (struct berval*) malloc(
- (count+1) * sizeof( struct berval) );
+ mod->sml_values = (struct berval*) malloc(
+ (count+1) * sizeof( struct berval) );
/* see slap_mods_check() comments...
* if a_vals == a_nvals, there is no normalizer.
}
for ( i = 0; i < count; i++ ) {
- ber_dupbv(mod->sml_bvalues+i, a_new->a_vals+i);
+ ber_dupbv(mod->sml_values+i, a_new->a_vals+i);
if ( mod->sml_nvalues ) {
ber_dupbv( mod->sml_nvalues+i, a_new->a_vals+i );
}
}
- mod->sml_bvalues[count].bv_val = 0;
- mod->sml_bvalues[count].bv_len = 0;
+ mod->sml_values[count].bv_val = NULL;
+ mod->sml_values[count].bv_len = 0;
if ( mod->sml_nvalues ) {
- mod->sml_nvalues[count].bv_val = 0;
+ mod->sml_nvalues[count].bv_val = NULL;
mod->sml_nvalues[count].bv_len = 0;
}
BUILD_OPT = "--enable-bdb"
BUILD_MOD = @BUILD_BDB@
-BUILD_MOD_DYNAMIC = @BUILD_BDB_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_BDB@_DEFS)
* no parent!
* if not attempting to add entry at suffix or with parent ""
*/
- if ((( !be_isroot( op ) && !be_isupdate(op)) || pdn.bv_len > 0 )
- && !is_entry_glue( op->oq_add.rs_e ))
+ if ((( !be_isroot( op ) && !be_shadow_update(op) )
+ || pdn.bv_len > 0 ) && !is_entry_glue( op->oq_add.rs_e ))
{
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, DETAIL1, "bdb_add: %s denied\n",
}
if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) && !(
- ( ad->ad_type->sat_approx
+ ad->ad_type->sat_approx
&& ad->ad_type->sat_approx->smr_indexer
- && ad->ad_type->sat_approx->smr_filter )
- && ( ad->ad_type->sat_equality
- && ad->ad_type->sat_equality->smr_indexer
- && ad->ad_type->sat_equality->smr_filter ) ) )
+ && ad->ad_type->sat_approx->smr_filter ) )
{
fprintf( stderr, "%s: line %d: "
"approx index of attribute \"%s\" disallowed\n",
}
se_id = atoi( argv[1] );
- se_size = atoi( argv[2] );
if ( se_id < 0 || se_id > 999 ) {
#ifdef NEW_LOGGING
return( 1 );
}
- if ( se_size < 0 || se_size > 999 ) {
+ se_size = atoi( argv[2] );
+ if ( se_size < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, CRIT,
"%s: line %d: session log size %d is negative\n",
)
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
- struct berval ctxcsn_ndn = { 0, NULL };
+ struct berval ctxcsn_ndn = BER_BVNULL;
EntryInfo *ctxcsn_ei = NULL;
DB_LOCK ctxcsn_lock;
struct berval max_committed_csn;
modvals[1].bv_len = 0;
mod.sml_op = LDAP_MOD_REPLACE;
- mod.sml_bvalues = modvals;
+ mod.sml_values = modvals;
mod.sml_nvalues = NULL;
mod.sml_desc = slap_schema.si_ad_contextCSN;
mod.sml_type = mod.sml_desc->ad_cname;
/* no parent, must be root to delete */
if( ! be_isroot( op ) ) {
if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
- || be_isupdate( op ) ) {
+ || be_shadow_update( op ) ) {
p = (Entry *)&slap_entry_root;
/* check parent for "children" acl */
break;
case LDAP_FILTER_APPROX:
- if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
- goto done;
+ if ( desc->ad_type->sat_approx ) {
+ if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
+ goto done;
+ }
+ break;
}
+
+ /* Use EQUALITY rule and index for approximate match */
/* fall thru */
case LDAP_FILTER_EQUALITY:
{ NULL, NULL, 0, 0 }
};
-struct berval bdb_uuid = { 0, NULL };
+struct berval bdb_uuid = BER_BVNULL;
typedef void * db_malloc(size_t);
typedef void * db_realloc(void *, size_t);
return 0;
}
-#if (defined(SLAPD_BDB_DYNAMIC) && !defined(BDB_HIER)) || \
- (defined(SLAPD_HDB_DYNAMIC) && defined(BDB_HIER))
+#if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
+ (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
int init_module( int argc, char *argv[] ) {
BackendInfo bi;
backend_add( &bi );
return 0;
}
-#endif /* SLAPD_BDB_DYNAMIC */
+#endif /* SLAPD_BDB */
int
bdb_initialize(
isroot = be_isroot( op );
if ( ! isroot ) {
if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
- || be_isupdate( op ) ) {
+ || be_shadow_update( op ) ) {
p = (Entry *)&slap_entry_root;
ID id, cursor;
ID candidates[BDB_IDL_UM_SIZE];
ID scopes[BDB_IDL_DB_SIZE];
- Entry *e = NULL, base;
- Entry *matched = NULL;
- EntryInfo *ei;
- struct berval realbase = { 0, NULL };
+ Entry *e = NULL, base, e_root = {0};
+ Entry *matched = NULL;
+ EntryInfo *ei, ei_root = {0};
+ struct berval realbase = BER_BVNULL;
int manageDSAit;
int tentries = 0;
ID lastid = NOID;
AttributeName *attrs;
- Filter contextcsnand, contextcsnle, cookief, csnfnot,
- csnfeq, csnfand, csnfge;
+ Filter contextcsnand, contextcsnle, cookief, csnfnot,
+ csnfeq, csnfand, csnfge;
AttributeAssertion aa_ge, aa_eq, aa_le;
- int entry_count = 0;
- struct berval *search_context_csn = NULL;
+ struct berval *search_context_csn = NULL;
DB_LOCK ctxcsn_lock;
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
int num_ctrls = 0;
if ( sop->o_req_ndn.bv_len == 0 ) {
/* DIT root special case */
- e = (Entry *) &slap_entry_root;
+ ei_root.bei_e = &e_root;
+ ei_root.bei_parent = &ei_root;
+ e_root.e_private = &ei_root;
+ e_root.e_id = 1;
+ ei = &ei_root;
rs->sr_err = LDAP_SUCCESS;
} else {
dn2entry_retry:
}
if ( e == NULL ) {
- struct berval matched_dn = { 0, NULL };
+ struct berval matched_dn = BER_BVNULL;
if ( matched != NULL ) {
BerVarray erefs;
return rs->sr_err;
}
- if ( !manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) {
+ if ( !manageDSAit && e != &e_root && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
struct berval matched_dn;
BerVarray erefs;
base.e_nname = realbase;
base.e_id = e->e_id;
- if ( e != &slap_entry_root ) {
+ if ( e != &e_root ) {
bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
}
e = NULL;
if ( get_pagedresults(sop) ) {
if ( sop->o_pagedresults_state.ps_cookie == 0 ) {
id = 0;
+
} else {
if ( sop->o_pagedresults_size == 0 ) {
rs->sr_err = LDAP_SUCCESS;
if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
/* check size limit */
- if ( --sop->ors_slimit == -1 &&
- sop->o_sync_slog_size == -1 )
+ if ( --sop->ors_slimit == -1 &&
+ sop->o_sync_slog_size == -1 )
{
if (!IS_PSEARCH) {
bdb_cache_return_entry_r( bdb->bi_dbenv,
rs->sr_attrs = sop->oq_search.rs_attrs;
rs->sr_ctrls = NULL;
rs->sr_flags = 0;
+ rs->sr_err = LDAP_SUCCESS;
result = send_search_entry( sop, rs );
}
}
LDAPControl ctrl, *ctrls[2];
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
- struct berval cookie = { 0, NULL };
+ struct berval cookie = BER_BVNULL;
PagedResultsCookie respcookie;
#ifdef NEW_LOGGING
respcookie = ( PagedResultsCookie )lastid;
op->o_conn->c_pagedresults_state.ps_cookie = respcookie;
+ op->o_conn->c_pagedresults_state.ps_count = op->o_pagedresults_state.ps_count + rs->sr_nentries;
cookie.bv_len = sizeof( respcookie );
cookie.bv_val = (char *)&respcookie;
done:
(void) ber_free_buf( ber );
-}
+}
+
BUILD_OPT = "--enable-dnssrv"
BUILD_MOD = @BUILD_DNSSRV@
-BUILD_MOD_DYNAMIC = @BUILD_DNSSRV_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_DNSSRV@_DEFS)
#include "slap.h"
#include "external.h"
-#ifdef SLAPD_DNSSRV_DYNAMIC
+#if SLAPD_DNSSRV == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[])
{
return 0;
}
-#endif /* SLAPD_DNSSRV_DYNAMIC */
+#endif /* SLAPD_DNSSRV */
int
dnssrv_back_initialize(
BUILD_OPT = "--enable-hdb"
BUILD_MOD = @BUILD_HDB@
-BUILD_MOD_DYNAMIC = @BUILD_HDB_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_HDB@_DEFS)
BUILD_OPT = "--enable-ldap"
BUILD_MOD = @BUILD_LDAP@
-BUILD_MOD_DYNAMIC = @BUILD_LDAP_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_LDAP@_DEFS)
#include "slap.h"
#include "back-ldap.h"
-#ifdef SLAPD_LDAP_DYNAMIC
+#if SLAPD_LDAP == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[]) {
BackendInfo bi;
return 0;
}
-#endif /* SLAPD_LDAP_DYNAMIC */
+#endif /* SLAPD_LDAP */
int
ldap_back_initialize(
Modifications *ml;
int i, j, rc;
struct berval mapped;
- struct berval mdn = { 0, NULL };
+ struct berval mdn = BER_BVNULL;
ber_int_t msgid;
dncookie dc;
int isupdate;
dc.ctx = "modifyAttrDN";
#endif
- isupdate = be_isupdate( op );
+ isupdate = be_shadow_update( op );
for (i=0, ml=op->oq_modify.rs_modlist; ml; ml=ml->sml_next) {
int is_oc = 0;
mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES;
mods[i].mod_type = mapped.bv_val;
- if ( ml->sml_bvalues != NULL ) {
+ if ( ml->sml_values != NULL ) {
if ( is_oc ) {
- for (j = 0; ml->sml_bvalues[j].bv_val; j++);
- mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) *
+ for (j = 0; ml->sml_values[j].bv_val; j++);
+ mods[i].mod_values = (struct berval **)ch_malloc((j+1) *
sizeof(struct berval *));
- for (j = 0; ml->sml_bvalues[j].bv_val; j++) {
+ for (j = 0; ml->sml_values[j].bv_val; j++) {
ldap_back_map(&li->rwmap.rwm_oc,
- &ml->sml_bvalues[j],
+ &ml->sml_values[j],
&mapped, BACKLDAP_MAP);
if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
continue;
}
- mods[i].mod_bvalues[j] = &mapped;
+ mods[i].mod_values[j] = &mapped;
}
- mods[i].mod_bvalues[j] = NULL;
+ mods[i].mod_values[j] = NULL;
} else {
if ( ml->sml_desc->ad_type->sat_syntax ==
slap_schema.si_syn_distinguishedName ) {
- ldap_dnattr_rewrite( &dc, ml->sml_bvalues );
+ ldap_dnattr_rewrite( &dc, ml->sml_values );
}
- if ( ml->sml_bvalues == NULL ) {
+ if ( ml->sml_values == NULL ) {
continue;
}
- for (j = 0; ml->sml_bvalues[j].bv_val; j++);
- mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) *
+ for (j = 0; ml->sml_values[j].bv_val; j++);
+ mods[i].mod_values = (struct berval **)ch_malloc((j+1) *
sizeof(struct berval *));
- for (j = 0; ml->sml_bvalues[j].bv_val; j++)
- mods[i].mod_bvalues[j] = &ml->sml_bvalues[j];
- mods[i].mod_bvalues[j] = NULL;
+ for (j = 0; ml->sml_values[j].bv_val; j++)
+ mods[i].mod_values[j] = &ml->sml_values[j];
+ mods[i].mod_values[j] = NULL;
}
} else {
- mods[i].mod_bvalues = NULL;
+ mods[i].mod_values = NULL;
}
i++;
free( mdn.bv_val );
}
for (i=0; modv[i]; i++) {
- ch_free(modv[i]->mod_bvalues);
+ ch_free(modv[i]->mod_values);
}
ch_free( mods );
ch_free( modv );
BUILD_OPT = "--enable-ldbm"
BUILD_MOD = @BUILD_LDBM@
-BUILD_MOD_DYNAMIC = @BUILD_LDBM_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_LDBM@_DEFS)
} else {
assert( pdn.bv_val == NULL || *pdn.bv_val == '\0' );
- if (( !be_isroot( op ) && !be_isupdate( op )) &&
- !is_entry_glue( op->oq_add.rs_e ))
+ if (( !be_isroot(op) && !be_shadow_update(op) )
+ && !is_entry_glue( op->oq_add.rs_e ))
{
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
}
if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) && !(
- ( ad->ad_type->sat_approx
+ ad->ad_type->sat_approx
&& ad->ad_type->sat_approx->smr_indexer
- && ad->ad_type->sat_approx->smr_filter )
- && ( ad->ad_type->sat_equality
- && ad->ad_type->sat_equality->smr_indexer
- && ad->ad_type->sat_equality->smr_filter ) ) )
+ && ad->ad_type->sat_approx->smr_filter ) )
{
fprintf( stderr, "%s: line %d: "
"approx index of attribute \"%s\" disallowed\n",
} else {
/* no parent, must be root to delete */
if( ! be_isroot( op ) ) {
- if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) || be_isupdate( op ) ) {
+ if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
+ || be_shadow_update( op ) ) {
p = (Entry *)&slap_entry_root;
rc = access_allowed( op, p,
break;
case LDAP_FILTER_APPROX:
- if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
- goto done;
+ if ( desc->ad_type->sat_approx ) {
+ if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
+ goto done;
+ }
+ break;
}
+
+ /* Use EQUALITY rule and index for approximate match */
/* fall thru */
case LDAP_FILTER_EQUALITY:
#include "slap.h"
#include "back-ldbm.h"
-#ifdef SLAPD_LDBM_DYNAMIC
+#if SLAPD_LDBM == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[]) {
BackendInfo bi;
return 0;
}
-#endif /* SLAPD_LDBM_DYNAMIC */
+#endif /* SLAPD_LDBM */
int
ldbm_back_initialize(
AttributeDescription *entry = slap_schema.si_ad_entry;
struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
struct berval p_dn, p_ndn;
- struct berval new_dn = { 0, NULL}, new_ndn = { 0, NULL };
- struct berval old_ndn = { 0, NULL };
+ struct berval new_dn = BER_BVNULL, new_ndn = BER_BVNULL;
+ struct berval old_ndn = BER_BVNULL;
Entry *e, *p = NULL;
Entry *matched;
/* LDAP v2 supporting correct attribute handling. */
/* no parent, must be root to modify rdn */
isroot = be_isroot( op );
if ( ! isroot ) {
- if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) || be_isupdate( op ) ) {
+ if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
+ || be_shadow_update( op ) ) {
int can_access;
p = (Entry *)&slap_entry_root;
}
if ( ! isroot ) {
- if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) || be_isupdate( op ) ) {
+ if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
+ || be_shadow_update( op ) ) {
int can_access;
np = (Entry *)&slap_entry_root;
BUILD_OPT = "--enable-meta"
BUILD_MOD = @BUILD_META@
-BUILD_MOD_DYNAMIC = @BUILD_META_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_META@_DEFS)
#include "../back-ldap/back-ldap.h"
#include "back-meta.h"
-#ifdef SLAPD_META_DYNAMIC
+#if SLAPD_META == SLAPD_MOD_DYNAMIC
int
init_module( int argc, char *argv[] ) {
return 0;
}
-#endif /* SLAPD_META_DYNAMIC */
+#endif /* SLAPD_META */
int
meta_back_initialize(
BUILD_OPT = "--enable-monitor"
BUILD_MOD = @BUILD_MONITOR@
-BUILD_MOD_DYNAMIC = @BUILD_MONITOR_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_MONITOR@_DEFS)
-TIME SUBSISTEM
+TIME SUBSYSTEM
It contains two subentries with the start time and the current time
of the server.
}, { -1, NULL }
};
-#ifdef SLAPD_MONITOR_DYNAMIC
+#if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
int
init_module( int argc, char *argv[] )
return 0;
}
-#endif /* SLAPD_MONITOR_DYNAMIC */
+#endif /* SLAPD_MONITOR */
int
monitor_back_initialize(
be_monitor = be;
/* indicate system schema supported */
- SLAP_DBFLAGS(be) |= SLAP_BFLAG_MONITOR;
+ SLAP_BFLAGS(be) |= SLAP_BFLAG_MONITOR;
dn.bv_val = SLAPD_MONITOR_DN;
dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1;
struct berval s;
struct berval n;
} int_2_level[] = {
- { LDAP_DEBUG_TRACE, BER_BVC("Trace"), { 0, NULL } },
- { LDAP_DEBUG_PACKETS, BER_BVC("Packets"), { 0, NULL } },
- { LDAP_DEBUG_ARGS, BER_BVC("Args"), { 0, NULL } },
- { LDAP_DEBUG_CONNS, BER_BVC("Conns"), { 0, NULL } },
- { LDAP_DEBUG_BER, BER_BVC("BER"), { 0, NULL } },
- { LDAP_DEBUG_FILTER, BER_BVC("Filter"), { 0, NULL } },
- { LDAP_DEBUG_CONFIG, BER_BVC("Config"), { 0, NULL } }, /* useless */
- { LDAP_DEBUG_ACL, BER_BVC("ACL"), { 0, NULL } },
- { LDAP_DEBUG_STATS, BER_BVC("Stats"), { 0, NULL } },
- { LDAP_DEBUG_STATS2, BER_BVC("Stats2"), { 0, NULL } },
- { LDAP_DEBUG_SHELL, BER_BVC("Shell"), { 0, NULL } },
- { LDAP_DEBUG_PARSE, BER_BVC("Parse"), { 0, NULL } },
- { LDAP_DEBUG_CACHE, BER_BVC("Cache"), { 0, NULL } },
- { LDAP_DEBUG_INDEX, BER_BVC("Index"), { 0, NULL } },
- { 0, { 0, NULL }, { 0, NULL } }
+ { LDAP_DEBUG_TRACE, BER_BVC("Trace"), BER_BVNULL },
+ { LDAP_DEBUG_PACKETS, BER_BVC("Packets"), BER_BVNULL },
+ { LDAP_DEBUG_ARGS, BER_BVC("Args"), BER_BVNULL },
+ { LDAP_DEBUG_CONNS, BER_BVC("Conns"), BER_BVNULL },
+ { LDAP_DEBUG_BER, BER_BVC("BER"), BER_BVNULL },
+ { LDAP_DEBUG_FILTER, BER_BVC("Filter"), BER_BVNULL },
+ { LDAP_DEBUG_CONFIG, BER_BVC("Config"), BER_BVNULL }, /* useless */
+ { LDAP_DEBUG_ACL, BER_BVC("ACL"), BER_BVNULL },
+ { LDAP_DEBUG_STATS, BER_BVC("Stats"), BER_BVNULL },
+ { LDAP_DEBUG_STATS2, BER_BVC("Stats2"), BER_BVNULL },
+ { LDAP_DEBUG_SHELL, BER_BVC("Shell"), BER_BVNULL },
+ { LDAP_DEBUG_PARSE, BER_BVC("Parse"), BER_BVNULL },
+ { LDAP_DEBUG_CACHE, BER_BVC("Cache"), BER_BVNULL },
+ { LDAP_DEBUG_INDEX, BER_BVC("Index"), BER_BVNULL },
+ { 0, BER_BVNULL, BER_BVNULL }
};
static int loglevel2int( struct berval *l );
struct berval desc[] = {
BER_BVC("This entry allows to set the log level runtime."),
BER_BVC("Set the attribute 'managedInfo' to the desired log levels."),
- { 0, NULL }
+ BER_BVNULL
};
ldap_pvt_thread_mutex_init( &monitor_log_mutex );
*/
if ( is_at_operational( mod->sm_desc->ad_type ) ) {
( void ) attr_delete( &e->e_attrs, mod->sm_desc );
- rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues,
- mod->sm_nvalues );
+ rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues );
if ( rc != 0 ) {
rc = LDAP_OTHER;
break;
{
int i;
- for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) {
+ for ( i = 0; mod->sm_values && mod->sm_values[i].bv_val != NULL; i++ ) {
int l;
- l = loglevel2int( &mod->sm_bvalues[i] );
+ l = loglevel2int( &mod->sm_values[i] );
if ( !l ) {
return LDAP_CONSTRAINT_VIOLATION;
}
}
assert( int_2_level[ l ].s.bv_len
- == mod->sm_bvalues[i].bv_len );
+ == mod->sm_values[i].bv_len );
- AC_MEMCPY( mod->sm_bvalues[i].bv_val,
+ AC_MEMCPY( mod->sm_values[i].bv_val,
int_2_level[ l ].s.bv_val,
int_2_level[ l ].s.bv_len );
return LDAP_INAPPROPRIATE_MATCHING;
}
- for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
+ for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) {
int rc;
int j;
const char *text = NULL;
rc = asserted_value_validate_normalize(
mod->sm_desc, mr, SLAP_MR_EQUALITY,
- &mod->sm_bvalues[i], &asserted, &text, NULL );
+ &mod->sm_values[i], &asserted, &text, NULL );
if ( rc != LDAP_SUCCESS ) {
return rc;
for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
- 0,
- &a->a_vals[j], &asserted, &text );
+ 0, &a->a_vals[j], &asserted, &text );
if ( rc == LDAP_SUCCESS && match == 0 ) {
free( asserted.bv_val );
}
/* no - add them */
- rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, mod->sm_nvalues );
+ rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues );
if ( rc != LDAP_SUCCESS ) {
/* this should return result of attr_mergeit */
return rc;
*newlevel &= ~nl;
/* delete the entire attribute */
- if ( mod->sm_bvalues == NULL ) {
+ if ( mod->sm_values == NULL ) {
int rc = attr_delete( &e->e_attrs, mod->sm_desc );
if ( rc ) {
}
/* find each value to delete */
- for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
+ for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) {
int rc;
const char *text = NULL;
rc = asserted_value_validate_normalize(
mod->sm_desc, mr, SLAP_MR_EQUALITY,
- &mod->sm_bvalues[i], &asserted, &text, NULL );
+ &mod->sm_values[i], &asserted, &text, NULL );
if( rc != LDAP_SUCCESS ) return rc;
return rc;
}
- if ( mod->sm_bvalues != NULL ) {
- rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues,
- mod->sm_nvalues );
+ if ( mod->sm_values != NULL ) {
+ rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues );
if ( rc != LDAP_SUCCESS ) {
return rc;
}
BER_BVC( "Search" ),
BER_BVC( "Abandon" ),
BER_BVC( "Extended" ),
- { 0, NULL }
+ BER_BVNULL
};
int
BUILD_OPT = "--enable-null"
BUILD_MOD = @BUILD_NULL@
-BUILD_MOD_DYNAMIC = @BUILD_NULL_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_NULL@_DEFS)
return 0;
}
-#ifdef SLAPD_NULL_DYNAMIC
-int back_null_LTX_init_module(
+#if SLAPD_NULL == SLAPD_MOD_DYNAMIC
+int init_module(
int argc,
char *argv[] )
{
backend_add(&bi);
return 0;
}
-#endif /* SLAPD_NULL_DYNAMIC */
+#endif /* SLAPD_NULL */
BUILD_OPT = "--enable-passwd"
BUILD_MOD = @BUILD_PASSWD@
-BUILD_MOD_DYNAMIC = @BUILD_PASSWD_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_PASSWD@_DEFS)
ldap_pvt_thread_mutex_t passwd_mutex;
-#ifdef SLAPD_PASSWD_DYNAMIC
+#if SLAPD_PASSWD == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[]) {
BackendInfo bi;
return 0;
}
-#endif /* SLAPD_PASSWD_DYNAMIC */
+#endif /* SLAPD_PASSWD */
int
passwd_back_initialize(
BUILD_OPT = "--enable-perl"
BUILD_MOD = @BUILD_PERL@
-BUILD_MOD_DYNAMIC = @BUILD_PERL_DYNAMIC@
PERL_CPPFLAGS = @PERL_CPPFLAGS@
mod_DEFS = -DSLAPD_IMPORT
PerlInterpreter *PERL_INTERPRETER = NULL;
ldap_pvt_thread_mutex_t perl_interpreter_mutex;
-#ifdef SLAPD_PERL_DYNAMIC
+#if SLAPD_PERL == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[])
{
return 0;
}
-#endif /* SLAPD_PERL_DYNAMIC */
+#endif /* SLAPD_PERL */
/**********************************************************
BUILD_OPT = "--enable-shell"
BUILD_MOD = @BUILD_SHELL@
-BUILD_MOD_DYNAMIC = @BUILD_SHELL_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_SHELL@_DEFS)
#include "slap.h"
#include "shell.h"
-#ifdef SLAPD_SHELL_DYNAMIC
+#if SLAPD_SHELL == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[]) {
BackendInfo bi;
return 0;
}
-#endif /* SLAPD_SHELL_DYNAMIC */
+#endif /* SLAPD_SHELL */
int
shell_back_initialize(
SRCS = init.c config.c search.c bind.c compare.c operational.c \
entry-id.c schema-map.c sql-wrap.c modify.c util.c \
- add.c delete.c modrdn.c
+ add.c delete.c modrdn.c api.c
OBJS = init.lo config.lo search.lo bind.lo compare.lo operational.lo \
entry-id.lo schema-map.lo sql-wrap.lo modify.lo util.lo \
- add.lo delete.lo modrdn.lo
+ add.lo delete.lo modrdn.lo api.lo
LDAP_INCDIR= ../../../include
LDAP_LIBDIR= ../../../libraries
BUILD_OPT = "--enable-sql"
BUILD_MOD = @BUILD_SQL@
-BUILD_MOD_DYNAMIC = @BUILD_SQL_DYNAMIC@
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_SQL@_DEFS)
"mappings for objectClass \"%s\"\n",
ad->ad_cname.bv_val, BACKSQL_OC_NAME( oc ), 0 );
- if ( backsql_attr_skip( ad, c_mod->sm_bvalues ) ) {
+ if ( backsql_attr_skip( ad, c_mod->sm_values ) ) {
continue;
}
break;
}
- rc = backsql_BindParamID( asth, 1, &e_id->keyval );
+#ifdef BACKSQL_ARBITRARY_KEY
+ rc = backsql_BindParamStr( asth, 1,
+ e_id->eid_keyval.bv_val,
+ BACKSQL_MAX_KEY_LEN );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ rc = backsql_BindParamID( asth, 1, &e_id->eid_keyval );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
" backsql_modify_internal(): "
pno = 0;
}
po = ( BACKSQL_IS_DEL( at->bam_param_order ) ) > 0;
+#ifdef BACKSQL_ARBITRARY_KEY
+ SQLBindParameter( sth, pno + 1 + po,
+ SQL_PARAM_INPUT,
+ SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, e_id->eid_keyval.bv_val,
+ 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, pno + 1 + po,
SQL_PARAM_INPUT,
SQL_C_ULONG, SQL_INTEGER,
- 0, 0, &e_id->keyval, 0, 0 );
+ 0, 0, &e_id->eid_keyval, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
/*
* check for syntax needed here
Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): "
"adding new values for attribute \"%s\"\n",
at->bam_ad->ad_cname.bv_val, 0, 0 );
- for ( i = 0, at_val = c_mod->sm_bvalues;
+ for ( i = 0, at_val = c_mod->sm_values;
at_val->bv_val != NULL;
i++, at_val++ ) {
if ( BACKSQL_IS_ADD( at->bam_expect_return ) ) {
pno = 0;
}
po = ( BACKSQL_IS_ADD( at->bam_param_order ) ) > 0;
+#ifdef BACKSQL_ARBITRARY_KEY
+ SQLBindParameter( sth, pno + 1 + po,
+ SQL_PARAM_INPUT,
+ SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, e_id->eid_keyval.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, pno + 1 + po,
SQL_PARAM_INPUT,
SQL_C_ULONG, SQL_INTEGER,
- 0, 0, &e_id->keyval, 0, 0 );
+ 0, 0, &e_id->eid_keyval, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
/*
* check for syntax needed here
break;
}
- if ( c_mod->sm_bvalues == NULL ) {
+ if ( c_mod->sm_values == NULL ) {
Debug( LDAP_DEBUG_TRACE,
" backsql_modify_internal(): "
"no values given to delete "
"deleting values for attribute \"%s\"\n",
at->bam_ad->ad_cname.bv_val, 0, 0 );
- for ( i = 0, at_val = c_mod->sm_bvalues;
+ for ( i = 0, at_val = c_mod->sm_values;
at_val->bv_val != NULL;
i++, at_val++ ) {
if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) {
pno = 0;
}
po = ( BACKSQL_IS_DEL( at->bam_param_order ) ) > 0;
+#ifdef BACKSQL_ARBITRARY_KEY
+ SQLBindParameter( sth, pno + 1 + po,
+ SQL_PARAM_INPUT,
+ SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, e_id->eid_keyval.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, pno + 1 + po,
SQL_PARAM_INPUT,
SQL_C_ULONG, SQL_INTEGER,
- 0, 0, &e_id->keyval, 0, 0 );
+ 0, 0, &e_id->eid_keyval, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
/*
* check for syntax needed here
RETCODE rc;
backsql_oc_map_rec *oc = NULL;
backsql_at_map_rec *at_rec = NULL;
- backsql_entryID e_id, parent_id;
+ backsql_entryID parent_id = BACKSQL_ENTRYID_INIT;
Entry p;
Attribute *at;
struct berval *at_val;
SQLUSMALLINT pno, po;
/* procedure return code */
int prc;
+ struct berval realdn, realpdn;
Debug( LDAP_DEBUG_TRACE, "==>backsql_add(): adding entry \"%s\"\n",
op->oq_add.rs_e->e_name.bv_val, 0, 0 );
/*
* Check if entry exists
*/
- rs->sr_err = backsql_dn2id( bi, &e_id, dbh, &op->oq_add.rs_e->e_name );
+ realdn = op->oq_add.rs_e->e_name;
+ if ( backsql_api_dn2odbc( op, rs, &realdn ) ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
+ "backsql_api_dn2odbc failed\n",
+ 0, 0, 0 );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "SQL-backend error";
+ goto done;
+ }
+
+ rs->sr_err = backsql_dn2id( bi, NULL, dbh, &realdn );
if ( rs->sr_err == LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_add(): "
"entry \"%s\" exists\n",
* Check if parent exists
*/
dnParent( &op->oq_add.rs_e->e_name, &pdn );
- rs->sr_err = backsql_dn2id( bi, &parent_id, dbh, &pdn );
+ realpdn = pdn;
+ if ( backsql_api_dn2odbc( op, rs, &realpdn ) ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
+ "backsql_api_dn2odbc failed\n",
+ 0, 0, 0 );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "SQL-backend error";
+ goto done;
+ }
+
+ rs->sr_err = backsql_dn2id( bi, &parent_id, dbh, &realpdn );
if ( rs->sr_err != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_add(): "
"could not lookup parent entry for new record \"%s\"\n",
struct berval dn;
char *matched = NULL;
+ if ( realpdn.bv_val != pdn.bv_val ) {
+ ch_free( realpdn.bv_val );
+ }
+
dn = pdn;
dnParent( &dn, &pdn );
/*
* Empty DN ("") defaults to LDAP_SUCCESS
*/
- rs->sr_err = backsql_dn2id( bi, &parent_id, dbh, &pdn );
+ realpdn = pdn;
+ if ( backsql_api_dn2odbc( op, rs, &realpdn ) ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
+ "backsql_api_dn2odbc failed\n",
+ 0, 0, 0 );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "SQL-backend error";
+ goto done;
+ }
+
+ rs->sr_err = backsql_dn2id( bi, NULL, dbh, &realpdn );
switch ( rs->sr_err ) {
case LDAP_NO_SUCH_OBJECT:
if ( pdn.bv_len > 0 ) {
BACKSQL_MAX_DN_LEN );
SQLBindParameter( sth, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &oc->bom_id, 0, 0 );
+#ifdef BACKSQL_ARBITRARY_KEY
+ SQLBindParameter( sth, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, parent_id.eid_id.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, 3, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
- 0, 0, &parent_id.id, 0, 0 );
+ 0, 0, &parent_id.eid_id, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, 4, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &new_keyval, 0, 0 );
Debug( LDAP_DEBUG_TRACE, " backsql_add(): executing \"%s\" for dn \"%s\"\n",
bi->insentry_query, op->oq_add.rs_e->e_name.bv_val, 0 );
- Debug( LDAP_DEBUG_TRACE, " for oc_map_id=%ld, parent_id=%ld, "
- "keyval=%ld\n", oc->bom_id, parent_id.id, new_keyval );
+#ifdef BACKSQL_ARBITRARY_KEY
+ Debug( LDAP_DEBUG_TRACE, " for oc_map_id=%ld, "
+ "parent_id=%s, keyval=%ld\n",
+ oc->bom_id, parent_id.eid_id.bv_val, new_keyval );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ Debug( LDAP_DEBUG_TRACE, " for oc_map_id=%ld, "
+ "parent_id=%ld, keyval=%ld\n",
+ oc->bom_id, parent_id.eid_id, new_keyval );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
#ifndef BACKSQL_REALLOC_STMT
rc = SQLExecDirect( sth, bi->insentry_query, SQL_NTS );
#else /* BACKSQL_REALLOC_STMT */
done:;
send_ldap_result( op, rs );
+ if ( realdn.bv_val != op->oq_add.rs_e->e_name.bv_val ) {
+ ch_free( realdn.bv_val );
+ }
+ if ( realpdn.bv_val != pdn.bv_val ) {
+ ch_free( realpdn.bv_val );
+ }
+ if ( parent_id.eid_dn.bv_val != NULL ) {
+ backsql_free_entryID( &parent_id, 0 );
+ }
+
Debug( LDAP_DEBUG_TRACE, "<==backsql_add(): %d%s%s\n",
rs->sr_err,
rs->sr_text ? ": " : "",
*/
#undef BACKSQL_TRACE
+/*
+ * define to enable varchars as unique keys in user tables
+ */
+#undef BACKSQL_ARBITRARY_KEY
+
+/*
+ * API
+ */
+typedef struct backsql_api {
+ char *ba_name;
+ int (*ba_dn2odbc)( Operation *op, SlapReply *rs, struct berval *dn );
+ int (*ba_odbc2dn)( Operation *op, SlapReply *rs, struct berval *dn );
+ struct backsql_api *ba_next;
+} backsql_api;
+
/*
* Entry ID structure
*/
typedef struct backsql_entryID {
- unsigned long id;
- unsigned long keyval;
- unsigned long oc_id;
- struct berval dn;
- struct backsql_entryID *next;
+ /* #define BACKSQL_ARBITRARY_KEY to allow a non-numeric key.
+ * It is required by some special applications that use
+ * strings as keys for the main table.
+ * In this case, #define BACKSQL_MAX_KEY_LEN consistently
+ * with the key size definition */
+#ifdef BACKSQL_ARBITRARY_KEY
+ struct berval eid_id;
+ struct berval eid_keyval;
+#define BACKSQL_MAX_KEY_LEN 64
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ /* The original numeric key is maintained as default. */
+ unsigned long eid_id;
+ unsigned long eid_keyval;
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+
+ unsigned long eid_oc_id;
+ struct berval eid_dn;
+ struct backsql_entryID *eid_next;
} backsql_entryID;
+#ifdef BACKSQL_ARBITRARY_KEY
+#define BACKSQL_ENTRYID_INIT { BER_BVNULL, BER_BVNULL, 0, BER_BVNULL, NULL }
+#else /* ! BACKSQL_ARBITRARY_KEY */
+#define BACKSQL_ENTRYID_INIT { 0, 0, 0, BER_BVNULL, NULL }
+#endif /* BACKSQL_ARBITRARY_KEY */
+
/*
* "structural" objectClass mapping structure
*/
typedef struct backsql_srch_info {
Operation *bsi_op;
+ SlapReply *bsi_rs;
int bsi_flags;
#define BSQL_SF_ALL_OPER 0x0001
struct berval *bsi_base_dn;
int bsi_scope;
+#define BACKSQL_SCOPE_BASE_LIKE ( LDAP_SCOPE_BASE | 0x1000 )
Filter *bsi_filter;
int bsi_slimit,
bsi_tlimit;
char *has_children_query;
MatchingRule *bi_caseIgnoreMatch;
+ MatchingRule *bi_telephoneNumberMatch;
struct berval upper_func;
struct berval upper_func_open;
((si)->bsql_flags & BSQLF_DONTCHECK_LDAPINFO_DN_RU)
#define BACKSQL_USE_REVERSE_DN(si) \
((si)->bsql_flags & BSQLF_USE_REVERSE_DN)
+#define BACKSQL_CANUPPERCASE(si) \
+ ((si)->upper_func.bv_val)
struct berval strcast_func;
Avlnode *db_conns;
ldap_pvt_thread_mutex_t dbconn_mutex;
ldap_pvt_thread_mutex_t schema_mutex;
SQLHENV db_env;
+
+ backsql_api *si_api;
} backsql_info;
#define BACKSQL_SUCCESS( rc ) \
backsql_bind( Operation *op, SlapReply *rs )
{
backsql_info *bi = (backsql_info*)op->o_bd->be_private;
- backsql_entryID user_id;
+ backsql_entryID user_id = BACKSQL_ENTRYID_INIT;
SQLHDBC dbh;
AttributeDescription *password = slap_schema.si_ad_userPassword;
Entry *e, user_entry;
backsql_srch_info bsi;
AttributeName anlist[2];
int rc;
+ struct berval dn;
Debug( LDAP_DEBUG_TRACE, "==>backsql_bind()\n", 0, 0, 0 );
return 1;
}
- rc = backsql_dn2id( bi, &user_id, dbh, &op->o_req_ndn );
+ dn = op->o_req_dn;
+ if ( backsql_api_dn2odbc( op, rs, &dn ) ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
+ "backsql_api_dn2odbc failed\n",
+ 0, 0, 0 );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "SQL-backend error";
+ goto error_return;
+ }
+
+ rc = backsql_dn2id( bi, &user_id, dbh, &dn );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_bind(): "
"could not retrieve bind dn id - no such entry\n",
anlist[0].an_name = password->ad_cname;
anlist[0].an_desc = password;
anlist[1].an_name.bv_val = NULL;
- backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE,
- -1, -1, -1, NULL, dbh, op, anlist );
+
+ backsql_init_search( &bsi, &dn, LDAP_SCOPE_BASE,
+ -1, -1, -1, NULL, dbh, op, rs, anlist );
e = backsql_id2entry( &bsi, &user_entry, &user_id );
if ( e == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_bind(): "
"error in backsql_id2entry() - auth failed\n",
0, 0, 0 );
rs->sr_err = LDAP_OTHER;
- send_ldap_result( op, rs );
- return 1;
+ goto error_return;
}
if ( ! access_allowed( op, e, password, NULL, ACL_AUTH, NULL ) ) {
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
- send_ldap_result( op, rs );
- return 1;
+ goto error_return;
}
if ( ( a = attr_find( e->e_attrs, password ) ) == NULL ) {
rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
- send_ldap_result( op, rs );
- return 1;
+ goto error_return;
}
if ( slap_passwd_check( op->o_conn, a, &op->oq_bind.rb_cred, &rs->sr_text ) != 0 ) {
rs->sr_err = LDAP_INVALID_CREDENTIALS;
+ goto error_return;
+ }
+
+error_return:;
+ if ( rs->sr_err ) {
send_ldap_result( op, rs );
return 1;
}
+
+ if ( dn.bv_val != op->o_req_dn.bv_val ) {
+ ch_free( dn.bv_val );
+ }
Debug(LDAP_DEBUG_TRACE,"<==backsql_bind()\n",0,0,0);
return 0;
backsql_compare( Operation *op, SlapReply *rs )
{
backsql_info *bi = (backsql_info*)op->o_bd->be_private;
- backsql_entryID user_id;
+ backsql_entryID user_id = BACKSQL_ENTRYID_INIT;
SQLHDBC dbh;
Entry *e = NULL, user_entry;
Attribute *a = NULL, *a_op = NULL;
backsql_srch_info bsi;
int rc;
AttributeName anlist[2];
+ struct berval dn;
user_entry.e_name.bv_val = NULL;
user_entry.e_name.bv_len = 0;
goto return_results;
}
- rc = backsql_dn2id( bi, &user_id, dbh, &op->o_req_ndn );
+ dn = op->o_req_dn;
+ if ( backsql_api_dn2odbc( op, rs, &dn ) ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
+ "backsql_api_dn2odbc failed\n",
+ 0, 0, 0 );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "SQL-backend error";
+ goto return_results;
+ }
+
+ rc = backsql_dn2id( bi, &user_id, dbh, &dn );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
"could not retrieve compare dn id - no such entry\n",
e = &user_entry;
} else {
- backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE,
- -1, -1, -1, NULL, dbh, op, anlist );
+ backsql_init_search( &bsi, &dn, LDAP_SCOPE_BASE,
+ -1, -1, -1, NULL, dbh, op, rs, anlist );
e = backsql_id2entry( &bsi, &user_entry, &user_id );
if ( e == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
return_results:;
send_ldap_result( op, rs );
+ if ( dn.bv_val != op->o_req_dn.bv_val ) {
+ ch_free( dn.bv_val );
+ }
+
if ( e != NULL ) {
if ( e->e_name.bv_val != NULL ) {
free( e->e_name.bv_val );
"fail_if_no_mapping=%s\n",
BACKSQL_FAIL_IF_NO_MAPPING( si ) ? "yes" : "no", 0, 0 );
+ } else if ( !strcasecmp( argv[ 0 ], "sqllayer") ) {
+ if ( backsql_api_config( si, argv[ 1 ] ) ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<==backsql_db_config (%s line %d): "
+ "unable to load sqllayer \"%s\"\n",
+ fname, lineno, argv[ 1 ] );
+ return 1;
+ }
+
} else {
return SLAP_CONF_UNKNOWN;
}
SQLHSTMT sth;
RETCODE rc;
backsql_oc_map_rec *oc = NULL;
- backsql_entryID e_id;
+ backsql_entryID e_id = BACKSQL_ENTRYID_INIT;
Entry e;
/* first parameter no */
SQLUSMALLINT pno;
goto done;
}
- oc = backsql_id2oc( bi, e_id.oc_id );
+ oc = backsql_id2oc( bi, e_id.eid_oc_id );
if ( oc == NULL ) {
Debug( LDAP_DEBUG_TRACE, " backsql_delete(): "
"cannot determine objectclass of entry -- aborting\n",
pno = 0;
}
+#ifdef BACKSQL_ARBITRARY_KEY
SQLBindParameter( sth, pno + 1, SQL_PARAM_INPUT,
- SQL_C_ULONG, SQL_INTEGER, 0, 0, &e_id.keyval, 0, 0 );
+ SQL_C_CHAR, SQL_VARCHAR, 0, 0, e_id.eid_keyval.bv_val,
+ 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ SQLBindParameter( sth, pno + 1, SQL_PARAM_INPUT,
+ SQL_C_ULONG, SQL_INTEGER, 0, 0, &e_id.eid_keyval,
+ 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
rc = SQLExecute( sth );
if ( rc != SQL_SUCCESS ) {
goto done;
}
+#ifdef BACKSQL_ARBITRARY_KEY
+ SQLBindParameter( sth, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, e_id.eid_id.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
- 0, 0, &e_id.id, 0, 0 );
+ 0, 0, &e_id.eid_id, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
rc = SQLExecute( sth );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_delete(): "
assert( id );
- next = id->next;
+ next = id->eid_next;
- if ( id->dn.bv_val != NULL ) {
- free( id->dn.bv_val );
+ if ( id->eid_dn.bv_val != NULL ) {
+ free( id->eid_dn.bv_val );
}
+#ifdef BACKSQL_ARBITRARY_KEY
+ if ( id->eid_id.bv_val ) {
+ free( id->eid_id.bv_val );
+ }
+
+ if ( id->eid_keyval.bv_val ) {
+ free( id->eid_keyval.bv_val );
+ }
+#endif /* BACKSQL_ARBITRARY_KEY */
+
if ( freeit ) {
free( id );
}
/* TimesTen */
char upperdn[ BACKSQL_MAX_DN_LEN + 1 ];
- char *toBind;
+ struct berval toBind;
int i, j;
- Debug( LDAP_DEBUG_TRACE, "==>backsql_dn2id(): dn='%s'\n",
- dn->bv_val, 0, 0 );
+ /*
+ * NOTE: id can be NULL; in this case, the function
+ * simply checks whether the DN can be successfully
+ * turned into an ID, returning LDAP_SUCCESS for
+ * positive cases, or the most appropriate error
+ */
- assert( id );
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_dn2id(): dn=\"%s\"%s\n",
+ dn->bv_val, id == NULL ? " (no ID)" : "", 0 );
if ( dn->bv_len > BACKSQL_MAX_DN_LEN ) {
Debug( LDAP_DEBUG_TRACE,
}
/* begin TimesTen */
- Debug(LDAP_DEBUG_TRACE, "id_query '%s'\n", bi->id_query, 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "id_query \"%s\"\n", bi->id_query, 0, 0);
assert( bi->id_query );
rc = backsql_Prepare( dbh, &sth, bi->id_query, 0 );
if ( rc != SQL_SUCCESS ) {
upperdn[ i ] = '\0';
ldap_pvt_str2upper( upperdn );
- Debug( LDAP_DEBUG_TRACE, "==>backsql_dn2id(): upperdn='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_dn2id(): upperdn=\"%s\"\n",
upperdn, 0, 0 );
- toBind = upperdn;
+ ber_str2bv( upperdn, 0, 0, &toBind );
+
} else {
if ( BACKSQL_USE_REVERSE_DN( bi ) ) {
AC_MEMCPY( upperdn, dn->bv_val, dn->bv_len + 1 );
ldap_pvt_str2upper( upperdn );
Debug( LDAP_DEBUG_TRACE,
- "==>backsql_dn2id(): upperdn='%s'\n",
+ "==>backsql_dn2id(): upperdn=\"%s\"\n",
upperdn, 0, 0 );
- toBind = upperdn;
+ ber_str2bv( upperdn, 0, 0, &toBind );
} else {
- toBind = dn->bv_val;
+ toBind = *dn;
}
}
- rc = backsql_BindParamStr( sth, 1, toBind, BACKSQL_MAX_DN_LEN );
+ rc = backsql_BindParamStr( sth, 1, toBind.bv_val, BACKSQL_MAX_DN_LEN );
if ( rc != SQL_SUCCESS) {
/* end TimesTen */
Debug( LDAP_DEBUG_TRACE, "backsql_dn2id(): "
"error binding dn=\"%s\" parameter:\n",
- toBind, 0, 0 );
+ toBind.bv_val, 0, 0 );
backsql_PrintErrors( SQL_NULL_HENV, dbh, sth, rc );
SQLFreeStmt( sth, SQL_DROP );
return LDAP_OTHER;
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_dn2id(): "
"error executing query (\"%s\", \"%s\"):\n",
- bi->id_query, toBind, 0 );
+ bi->id_query, toBind.bv_val, 0 );
backsql_PrintErrors( SQL_NULL_HENV, dbh, sth, rc );
SQLFreeStmt( sth, SQL_DROP );
return LDAP_OTHER;
backsql_BindRowAsStrings( sth, &row );
rc = SQLFetch( sth );
if ( BACKSQL_SUCCESS( rc ) ) {
- id->id = strtol( row.cols[ 0 ], NULL, 0 );
- id->keyval = strtol( row.cols[ 1 ], NULL, 0 );
- id->oc_id = strtol( row.cols[ 2 ], NULL, 0 );
- ber_dupbv( &id->dn, dn );
- id->next = NULL;
-
res = LDAP_SUCCESS;
+ Debug( LDAP_DEBUG_TRACE, "<==backsql_dn2id(): id=%s keyval=%s oc_id=%s\n",
+ row.cols[ 0 ], row.cols[ 1 ], row.cols[ 2 ] );
+
+ if ( id != NULL ) {
+#ifdef BACKSQL_ARBITRARY_KEY
+ ber_str2bv( row.cols[ 0 ], 0, 1, &id->eid_id );
+ ber_str2bv( row.cols[ 1 ], 0, 1, &id->eid_keyval );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ id->eid_id = strtol( row.cols[ 0 ], NULL, 0 );
+ id->eid_keyval = strtol( row.cols[ 1 ], NULL, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+ id->eid_oc_id = strtol( row.cols[ 2 ], NULL, 0 );
+
+ ber_dupbv( &id->eid_dn, dn );
+ id->eid_next = NULL;
+ }
} else {
res = LDAP_NO_SUCH_OBJECT;
+ Debug( LDAP_DEBUG_TRACE, "<==backsql_dn2id(): no match\n",
+ 0, 0, 0 );
}
backsql_FreeRow( &row );
SQLFreeStmt( sth, SQL_DROP );
- if ( res == LDAP_SUCCESS ) {
- Debug( LDAP_DEBUG_TRACE, "<==backsql_dn2id(): id=%ld\n",
- id->id, 0, 0 );
- } else {
- Debug( LDAP_DEBUG_TRACE, "<==backsql_dn2id(): no match\n",
- 0, 0, 0 );
- }
return res;
}
RETCODE rc;
int res = LDAP_SUCCESS;
- Debug( LDAP_DEBUG_TRACE, "==>backsql_count_children(): dn='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_count_children(): dn=\"%s\"\n",
dn->bv_val, 0, 0 );
if ( dn->bv_len > BACKSQL_MAX_DN_LEN ) {
}
/* begin TimesTen */
- Debug(LDAP_DEBUG_TRACE, "children id query '%s'\n",
+ Debug(LDAP_DEBUG_TRACE, "children id query \"%s\"\n",
bi->has_children_query, 0, 0);
assert( bi->has_children_query );
rc = backsql_Prepare( dbh, &sth, bi->has_children_query, 0 );
assert( at );
assert( bsi );
-
+
+#ifdef BACKSQL_ARBITRARY_KEY
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_get_attr_vals(): "
+ "oc=\"%s\" attr=\"%s\" keyval=%s\n",
+ BACKSQL_OC_NAME( bsi->bsi_oc ), at->bam_ad->ad_cname.bv_val,
+ bsi->bsi_c_eid->eid_keyval.bv_val );
+#else /* ! BACKSQL_ARBITRARY_KEY */
Debug( LDAP_DEBUG_TRACE, "==>backsql_get_attr_vals(): "
- "oc='%s' attr='%s' keyval=%ld\n",
+ "oc=\"%s\" attr=\"%s\" keyval=%ld\n",
BACKSQL_OC_NAME( bsi->bsi_oc ), at->bam_ad->ad_cname.bv_val,
- bsi->bsi_c_eid->keyval );
+ bsi->bsi_c_eid->eid_keyval );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
rc = backsql_Prepare( bsi->bsi_dbh, &sth, at->bam_query, 0 );
if ( rc != SQL_SUCCESS ) {
return 1;
}
- rc = backsql_BindParamID( sth, 1, &bsi->bsi_c_eid->keyval );
+#ifdef BACKSQL_ARBITRARY_KEY
+ rc = backsql_BindParamStr( sth, 1, bsi->bsi_c_eid->eid_keyval.bv_val,
+ BACKSQL_MAX_KEY_LEN );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ rc = backsql_BindParamID( sth, 1, &bsi->bsi_c_eid->eid_keyval );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
"error binding key value parameter\n", 0, 0, 0 );
rc = SQLExecute( sth );
if ( ! BACKSQL_SUCCESS( rc ) ) {
Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
- "error executing attribute query '%s'\n",
+ "error executing attribute query \"%s\"\n",
at->bam_query, 0, 0 );
backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, sth, rc );
SQLFreeStmt( sth, SQL_DROP );
(int)row.col_prec[ i ], 0, 0 );
} else {
Debug( LDAP_DEBUG_TRACE, "NULL value "
- "in this row for attribute '%s'\n",
+ "in this row for attribute \"%s\"\n",
row.col_names[ i ].bv_val, 0, 0 );
#endif /* BACKSQL_TRACE */
}
Debug( LDAP_DEBUG_TRACE, "==>backsql_id2entry()\n", 0, 0, 0 );
- rc = dnPrettyNormal( NULL, &eid->dn, &e->e_name, &e->e_nname,
+ rc = dnPrettyNormal( NULL, &eid->eid_dn, &e->e_name, &e->e_nname,
bsi->bsi_op->o_tmpmemctx );
if ( rc != LDAP_SUCCESS ) {
return NULL;
}
- bsi->bsi_oc = backsql_id2oc( bsi->bsi_op->o_bd->be_private, eid->oc_id );
+ bsi->bsi_oc = backsql_id2oc( bsi->bsi_op->o_bd->be_private,
+ eid->eid_oc_id );
bsi->bsi_e = e;
bsi->bsi_c_eid = eid;
e->e_attrs = NULL;
e->e_private = NULL;
-
- e->e_id = eid->id;
+
+#ifndef BACKSQL_ARBITRARY_KEY
+ e->e_id = eid->eid_id;
+#endif /* ! BACKSQL_ARBITRARY_KEY */
if ( bsi->bsi_attrs != NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
rc = backsql_supad2at( bsi->bsi_oc, attr->an_desc, &vat );
if ( rc != 0 || vat == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
- "attribute '%s' is not defined "
- "for objectlass '%s'\n",
+ "attribute \"%s\" is not defined "
+ "for objectlass \"%s\"\n",
attr->an_name.bv_val,
BACKSQL_OC_NAME( bsi->bsi_oc ), 0 );
continue;
#include "ldap_pvt.h"
#include "proto-sql.h"
-#ifdef SLAPD_SQL_DYNAMIC
+#if SLAPD_SQL == SLAPD_MOD_DYNAMIC
int
init_module(
return 0;
}
-#endif /* SLAPD_SQL_DYNAMIC */
+#endif /* SLAPD_SQL == SLAPD_MOD_DYNAMIC */
int
sql_back_initialize(
bi->bi_connection_init = 0;
bi->bi_connection_destroy = backsql_connection_destroy;
-
+
Debug( LDAP_DEBUG_TRACE,"<==backsql_initialize()\n", 0, 0, 0 );
return 0;
}
if ( backsql_split_pattern( backsql_def_concat_func,
&si->concat_func, 2 ) ) {
Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
- "unable to parse pattern '%s'",
+ "unable to parse pattern \"%s\"",
backsql_def_concat_func, 0, 0 );
return 1;
}
/* normalize filter values only if necessary */
si->bi_caseIgnoreMatch = mr_find( "caseIgnoreMatch" );
+ assert( si->bi_caseIgnoreMatch );
+
+ si->bi_telephoneNumberMatch = mr_find( "telephoneNumberMatch" );
+ assert( si->bi_telephoneNumberMatch );
if ( si->dbuser == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
si->subtree_cond = bb.bb_val;
Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
- "setting '%s' as default\n",
+ "setting \"%s\" as default\n",
si->subtree_cond.bv_val, 0, 0 );
}
si->children_cond = bb.bb_val;
Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
- "setting '%s' as default\n",
+ "setting \"%s\" as default\n",
si->children_cond.bv_val, 0, 0 );
}
"(use \"oc_query\" directive in slapd.conf)\n",
0, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
- "setting '%s' by default\n", si->oc_query, 0, 0 );
+ "setting \"%s\" by default\n", si->oc_query, 0, 0 );
}
if ( si->at_query == NULL ) {
"(use \"at_query\" directive in slapd.conf)\n",
0, 0, 0 );
Debug(LDAP_DEBUG_TRACE, "backsql_db_open(): "
- "setting '%s' by default\n",
+ "setting \"%s\" by default\n",
backsql_def_at_query, 0, 0 );
si->at_query = ch_strdup( backsql_def_at_query );
}
"(use \"insentry_query\" directive in slapd.conf)\n",
0, 0, 0 );
Debug(LDAP_DEBUG_TRACE, "backsql_db_open(): "
- "setting '%s' by default\n",
+ "setting \"%s\" by default\n",
backsql_def_insentry_query, 0, 0 );
si->insentry_query = ch_strdup( backsql_def_insentry_query );
}
"(use \"delentry_query\" directive in slapd.conf)\n",
0, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
- "setting '%s' by default\n",
+ "setting \"%s\" by default\n",
backsql_def_delentry_query, 0, 0 );
si->delentry_query = ch_strdup( backsql_def_delentry_query );
}
backsql_info *bi = (backsql_info*)op->o_bd->be_private;
SQLHDBC dbh;
backsql_oc_map_rec *oc = NULL;
- backsql_entryID e_id;
+ backsql_entryID e_id = BACKSQL_ENTRYID_INIT;
Entry e;
/*
return 1;
}
+#ifdef BACKSQL_ARBITRARY_KEY
+ Debug( LDAP_DEBUG_TRACE, " backsql_modify(): "
+ "modifying entry \"%s\" (id=%s)\n",
+ e_id.eid_dn.bv_val, e_id.eid_id.bv_val, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
Debug( LDAP_DEBUG_TRACE, " backsql_modify(): "
"modifying entry \"%s\" (id=%ld)\n",
- e_id.dn.bv_val, e_id.id, 0 );
+ e_id.eid_dn.bv_val, e_id.eid_id, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
- oc = backsql_id2oc( bi, e_id.oc_id );
+ oc = backsql_id2oc( bi, e_id.eid_oc_id );
if ( oc == NULL ) {
Debug( LDAP_DEBUG_TRACE, " backsql_modify(): "
"cannot determine objectclass of entry -- aborting\n",
SQLHDBC dbh;
SQLHSTMT sth;
RETCODE rc;
- backsql_entryID e_id, pe_id, new_pid;
+ backsql_entryID e_id = BACKSQL_ENTRYID_INIT,
+ pe_id = BACKSQL_ENTRYID_INIT,
+ new_pid = BACKSQL_ENTRYID_INIT;
backsql_oc_map_rec *oc = NULL;
struct berval p_dn, p_ndn,
*new_pdn = NULL, *new_npdn = NULL,
return 1;
}
+#ifdef BACKSQL_ARBITRARY_KEY
+ Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): entry id=%s\n",
+ e_id.eid_id.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): entry id=%ld\n",
- e_id.id, 0, 0 );
+ e_id.eid_id, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
if ( backsql_has_children( bi, dbh, &op->o_req_ndn ) == LDAP_COMPARE_TRUE ) {
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
goto modrdn_return;
}
+#ifdef BACKSQL_ARBITRARY_KEY
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
- "old parent entry id is %ld\n", pe_id.id, 0, 0 );
+ "old parent entry id is %s\n", pe_id.eid_id.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
+ "old parent entry id is %ld\n", pe_id.eid_id, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+
+ backsql_free_entryID( &pe_id, 0 );
rs->sr_err = backsql_dn2id( bi, &new_pid, dbh, new_npdn );
if ( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
goto modrdn_return;
}
-
+
+#ifdef BACKSQL_ARBITRARY_KEY
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
- "new parent entry id=%ld\n", new_pid.id, 0, 0 );
+ "new parent entry id=%s\n", new_pid.eid_id.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
+ "new parent entry id=%ld\n", new_pid.eid_id, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
"executing delentry_query\n", 0, 0, 0 );
SQLAllocStmt( dbh, &sth );
+#ifdef BACKSQL_ARBITRARY_KEY
+ SQLBindParameter( sth, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, e_id.eid_id.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
- 0, 0, &e_id.id, 0, 0 );
+ 0, 0, &e_id.eid_id, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
rc = SQLExecDirect( sth, bi->delentry_query, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
"executing insentry_query\n", 0, 0, 0 );
backsql_BindParamStr( sth, 1, new_dn.bv_val, BACKSQL_MAX_DN_LEN );
SQLBindParameter( sth, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
- 0, 0, &e_id.oc_id, 0, 0 );
+ 0, 0, &e_id.eid_oc_id, 0, 0 );
+#ifdef BACKSQL_ARBITRARY_KEY
+ SQLBindParameter( sth, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, new_pid.eid_id.bv_val, 0, 0 );
+ SQLBindParameter( sth, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, e_id.eid_keyval.bv_val, 0, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, 3, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
- 0, 0, &new_pid.id, 0, 0 );
+ 0, 0, &new_pid.eid_id, 0, 0 );
SQLBindParameter( sth, 4, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
- 0, 0, &e_id.keyval, 0, 0 );
+ 0, 0, &e_id.eid_keyval, 0, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
rc = SQLExecDirect( sth, bi->insentry_query, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
goto modrdn_return;
}
- oc = backsql_id2oc( bi, e_id.oc_id );
+ oc = backsql_id2oc( bi, e_id.eid_oc_id );
rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, mod );
if ( rs->sr_err == LDAP_SUCCESS ) {
if ( old_rdn != NULL ) {
ldap_rdnfree( old_rdn );
}
- if( mod != NULL ) {
+ if ( mod != NULL ) {
Modifications *tmp;
for (; mod; mod=tmp ) {
tmp = mod->sml_next;
}
}
+ if ( new_pid.eid_dn.bv_val ) {
+ backsql_free_entryID( &pe_id, 0 );
+ }
+
send_ldap_result( op, rs );
Debug( LDAP_DEBUG_TRACE, "<==backsql_modrdn()\n", 0, 0, 0 );
Attribute **aa = a;
int rc = 0;
- Debug( LDAP_DEBUG_TRACE, "==>backsql_operational(): entry '%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_operational(): entry \"%s\"\n",
rs->sr_entry->e_nname.bv_val, 0, 0 );
backsql_entryID *e_id,
Modifications *modlist );
+/*
+ * api.c
+ */
+int backsql_api_config( backsql_info *si, const char *name );
+int backsql_api_register( backsql_api *ba );
+int backsql_api_dn2odbc( Operation *op, SlapReply *rs, struct berval *dn );
+int backsql_api_odbc2dn( Operation *op, SlapReply *rs, struct berval *dn );
+
/*
* entry-id.c
*/
void backsql_init_search( backsql_srch_info *bsi,
struct berval *nbase, int scope, int slimit, int tlimit,
time_t stoptime, Filter *filter, SQLHDBC dbh,
- Operation *op, AttributeName *attrs );
+ Operation *op, SlapReply *rs, AttributeName *attrs );
/*
* sql-wrap.h
rc = backsql_Prepare( dbh, &oc_sth, si->oc_query, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): "
- "error preparing oc_query: '%s'\n",
+ "error preparing oc_query: \"%s\"\n",
si->oc_query, 0, 0 );
backsql_PrintErrors( si->db_env, dbh, oc_sth, rc );
return LDAP_OTHER;
}
- Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): at_query '%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): at_query \"%s\"\n",
si->at_query, 0, 0 );
rc = backsql_Prepare( dbh, &at_sth, si->at_query, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): "
- "error preparing at_query: '%s'\n",
+ "error preparing at_query: \"%s\"\n",
si->at_query, 0, 0 );
backsql_PrintErrors( si->db_env, dbh, at_sth, rc );
return LDAP_OTHER;
oc_map->bom_oc = oc_find( oc_row.cols[ 1 ] );
if ( oc_map->bom_oc == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): "
- "objectClass '%s' is not defined in schema\n",
+ "objectClass \"%s\" is not defined in schema\n",
oc_row.cols[ 1 ], 0, 0 );
return LDAP_OTHER; /* undefined objectClass ? */
}
}
oc_id = oc_map->bom_id;
Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): "
- "objectClass '%s': keytbl='%s' keycol='%s'\n",
+ "objectClass \"%s\": keytbl=\"%s\" keycol=\"%s\"\n",
BACKSQL_OC_NAME( oc_map ),
oc_map->bom_keytbl.bv_val, oc_map->bom_keycol.bv_val );
if ( oc_map->bom_create_proc ) {
- Debug( LDAP_DEBUG_TRACE, "create_proc='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "create_proc=\"%s\"\n",
oc_map->bom_create_proc, 0, 0 );
}
if ( oc_map->bom_create_keyval ) {
- Debug( LDAP_DEBUG_TRACE, "create_keyval='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "create_keyval=\"%s\"\n",
oc_map->bom_create_keyval, 0, 0 );
}
if ( oc_map->bom_delete_proc ) {
- Debug( LDAP_DEBUG_TRACE, "delete_proc='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "delete_proc=\"%s\"\n",
oc_map->bom_delete_proc, 0, 0 );
}
Debug( LDAP_DEBUG_TRACE, "expect_return: "
Debug( LDAP_DEBUG_TRACE,
"attributeType:\n"
- "\tname='%s'\n"
- "\tsel_expr='%s'\n"
- "\tfrom='%s'\n",
+ "\tname=\"%s\"\n"
+ "\tsel_expr=\"%s\"\n"
+ "\tfrom=\"%s\"\n",
at_row.cols[ 0 ], at_row.cols[ 1 ],
at_row.cols[ 2 ] );
Debug( LDAP_DEBUG_TRACE,
- "\tjoin_where='%s'\n"
- "\tadd_proc='%s'\n"
- "\tdelete_proc='%s'\n",
+ "\tjoin_where=\"%s\"\n"
+ "\tadd_proc=\"%s\"\n"
+ "\tdelete_proc=\"%s\"\n",
at_row.cols[ 3 ], at_row.cols[ 4 ],
at_row.cols[ 5 ]);
/* TimesTen */
- Debug( LDAP_DEBUG_TRACE, "\tsel_expr_u='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "\tsel_expr_u=\"%s\"\n",
at_row.cols[ 8 ], 0, 0 );
at_map = (backsql_at_map_rec *)ch_calloc( 1,
sizeof( backsql_at_map_rec ) );
&at_map->bam_ad, &text );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): "
- "attribute '%s' for objectClass '%s' "
+ "attribute \"%s\" for objectClass \"%s\" "
"is not defined in schema: %s\n",
at_row.cols[ 0 ],
BACKSQL_OC_NAME( oc_map ), text );
NULL, 0 );
backsql_make_attr_query( oc_map, at_map );
Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): "
- "preconstructed query '%s'\n",
+ "preconstructed query \"%s\"\n",
at_map->bam_query, 0, 0 );
at_map->bam_next = NULL;
if ( avl_insert( &oc_map->bom_attrs, at_map, backsql_cmp_attr, backsql_dup_attr ) == BACKSQL_DUPLICATE ) {
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "==>backsql_oc2oc(): "
- "searching for objectclass with name='%s'\n",
+ "searching for objectclass with name=\"%s\"\n",
objclass, 0, 0 );
#endif /* BACKSQL_TRACE */
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
Debug( LDAP_DEBUG_TRACE, "<==backsql_oc2oc(): "
- "found name='%s', id=%d\n",
+ "found name=\"%s\", id=%d\n",
BACKSQL_OC_NAME( res ), res->id, 0 );
} else {
Debug( LDAP_DEBUG_TRACE, "<==backsql_oc2oc(): "
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "==>oc_with_name(): "
- "searching for objectclass with name='%s'\n",
+ "searching for objectclass with name=\"%s\"\n",
objclass, 0, 0 );
#endif /* BACKSQL_TRACE */
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
Debug( LDAP_DEBUG_TRACE, "<==oc_with_name(): "
- "found name='%s', id=%d\n",
+ "found name=\"%s\", id=%d\n",
BACKSQL_OC_NAME( res ), res->bom_id, 0 );
} else {
Debug( LDAP_DEBUG_TRACE, "<==oc_with_name(): "
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
Debug( LDAP_DEBUG_TRACE, "<==oc_with_name(): "
- "found name='%s', id=%d\n",
+ "found name=\"%s\", id=%d\n",
BACKSQL_OC_NAME( res ), res->bom_id, 0 );
} else {
Debug( LDAP_DEBUG_TRACE, "<==oc_with_name(): "
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "==>backsql_ad2at(): "
- "searching for attribute '%s' for objectclass '%s'\n",
+ "searching for attribute \"%s\" for objectclass \"%s\"\n",
attr, BACKSQL_OC_NAME( objclass ), 0 );
#endif /* BACKSQL_TRACE */
#ifdef BACKSQL_TRACE
if ( res != NULL ) {
Debug( LDAP_DEBUG_TRACE, "<==backsql_ad2at(): "
- "found name='%s', sel_expr='%s'\n",
+ "found name=\"%s\", sel_expr=\"%s\"\n",
res->bam_ad->ad_cname.bv_val,
res->bam_sel_expr.bv_val, 0 );
} else {
{
backsql_at_map_rec *at = v_at;
- Debug( LDAP_DEBUG_TRACE, "==>free_attr(): '%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "==>free_attr(): \"%s\"\n",
at->bam_ad->ad_cname.bv_val, 0, 0 );
ch_free( at->bam_sel_expr.bv_val );
if ( at->bam_from_tbls.bv_val != NULL ) {
{
backsql_oc_map_rec *oc = v_oc;
- Debug( LDAP_DEBUG_TRACE, "==>free_oc(): '%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "==>free_oc(): \"%s\"\n",
BACKSQL_OC_NAME( oc ), 0, 0 );
avl_free( oc->bom_attrs, backsql_free_attr );
ch_free( oc->bom_keytbl.bv_val );
#define BACKSQL_CONTINUE 1
static int backsql_process_filter( backsql_srch_info *bsi, Filter *f );
-
+static int backsql_process_filter_eq( backsql_srch_info *bsi,
+ backsql_at_map_rec *at,
+ int casefold, struct berval *filter_value );
+static int backsql_process_filter_like( backsql_srch_info *bsi,
+ backsql_at_map_rec *at,
+ int casefold, struct berval *filter_value );
static int backsql_process_filter_attr( backsql_srch_info *bsi, Filter *f,
backsql_at_map_rec *at );
an = &bsi->bsi_attrs[ n_attrs ];
Debug( LDAP_DEBUG_TRACE, "==>backsql_attrlist_add(): "
- "attribute '%s' is in list\n",
+ "attribute \"%s\" is in list\n",
an->an_name.bv_val, 0, 0 );
/*
* We can live with strcmp because the attribute
}
Debug( LDAP_DEBUG_TRACE, "==>backsql_attrlist_add(): "
- "adding '%s' to list\n", ad->ad_cname.bv_val, 0, 0 );
+ "adding \"%s\" to list\n", ad->ad_cname.bv_val, 0, 0 );
an = (AttributeName *)ch_realloc( bsi->bsi_attrs,
sizeof( AttributeName ) * ( n_attrs + 2 ) );
Filter *filter,
SQLHDBC dbh,
Operation *op,
+ SlapReply *rs,
AttributeName *attrs )
{
AttributeName *p;
-
+
bsi->bsi_base_dn = base;
bsi->bsi_scope = scope;
bsi->bsi_slimit = slimit;
bsi->bsi_filter = filter;
bsi->bsi_dbh = dbh;
bsi->bsi_op = op;
+ bsi->bsi_rs = rs;
bsi->bsi_flags = 0;
/*
backsql_process_sub_filter( backsql_srch_info *bsi, Filter *f,
backsql_at_map_rec *at )
{
-#ifdef BACKSQL_UPPERCASE_FILTER
backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
-#endif /* BACKSQL_UPPERCASE_FILTER */
int i;
int casefold = 0;
casefold = 1;
}
+ if ( SLAP_MR_ASSOCIATED( f->f_sub_desc->ad_type->sat_substr,
+ bi->bi_telephoneNumberMatch ) )
+ {
+
+ struct berval bv;
+ ber_len_t i, s, a;
+
+ /*
+ * to check for matching telephone numbers
+ * with intermixed chars, e.g. val='1234'
+ * use
+ *
+ * val LIKE '%1%2%3%4%'
+ */
+
+ bv.bv_len = 0;
+ if ( f->f_sub_initial.bv_val ) {
+ bv.bv_len += f->f_sub_initial.bv_len;
+ }
+ if ( f->f_sub_any != NULL ) {
+ for ( a = 0; f->f_sub_any[ a ].bv_val != NULL; a++ ) {
+ bv.bv_len += f->f_sub_any[ a ].bv_len;
+ }
+ }
+ if ( f->f_sub_final.bv_val ) {
+ bv.bv_len += f->f_sub_final.bv_len;
+ }
+ bv.bv_len = 2 * bv.bv_len - 1;
+ bv.bv_val = ch_malloc( bv.bv_len + 1 );
+
+ s = 0;
+ if ( f->f_sub_initial.bv_val ) {
+ bv.bv_val[ s ] = f->f_sub_initial.bv_val[ 0 ];
+ for ( i = 1; i < f->f_sub_initial.bv_len; i++ ) {
+ bv.bv_val[ s + 2 * i - 1 ] = '%';
+ bv.bv_val[ s + 2 * i ] = f->f_sub_initial.bv_val[ i ];
+ }
+ bv.bv_val[ s + 2 * i - 1 ] = '%';
+ s += 2 * i;
+ }
+
+ if ( f->f_sub_any != NULL ) {
+ for ( a = 0; f->f_sub_any[ a ].bv_val != NULL; a++ ) {
+ bv.bv_val[ s ] = f->f_sub_any[ a ].bv_val[ 0 ];
+ for ( i = 1; i < f->f_sub_any[ a ].bv_len; i++ ) {
+ bv.bv_val[ s + 2 * i - 1 ] = '%';
+ bv.bv_val[ s + 2 * i ] = f->f_sub_any[ a ].bv_val[ i ];
+ }
+ bv.bv_val[ s + 2 * i - 1 ] = '%';
+ s += 2 * i;
+ }
+ }
+
+ if ( f->f_sub_final.bv_val ) {
+ bv.bv_val[ s ] = f->f_sub_final.bv_val[ 0 ];
+ for ( i = 1; i < f->f_sub_final.bv_len; i++ ) {
+ bv.bv_val[ s + 2 * i - 1 ] = '%';
+ bv.bv_val[ s + 2 * i ] = f->f_sub_final.bv_val[ i ];
+ }
+ bv.bv_val[ s + 2 * i - 1 ] = '%';
+ s += 2 * i;
+ }
+
+ bv.bv_val[ s - 1 ] = '\0';
+
+ (void)backsql_process_filter_like( bsi, at, casefold, &bv );
+ ch_free( bv.bv_val );
+
+ return 1;
+ }
+
/*
* When dealing with case-sensitive strings
* we may omit normalization; however, normalized
backsql_strfcat( &bsi->bsi_flt_where, "c", '(' /* ) */ );
/* TimesTen */
- Debug( LDAP_DEBUG_TRACE, "expr: '%s%s%s'\n", at->bam_sel_expr.bv_val,
+ Debug( LDAP_DEBUG_TRACE, "backsql_process_sub_filter(%s):\n",
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
+ Debug(LDAP_DEBUG_TRACE, " expr: '%s%s%s'\n", at->bam_sel_expr.bv_val,
at->bam_sel_expr_u.bv_val ? "' '" : "",
at->bam_sel_expr_u.bv_val ? at->bam_sel_expr_u.bv_val : "" );
if ( casefold && BACKSQL_AT_CANUPPERCASE( at ) ) {
if ( f->f_sub_initial.bv_val != NULL ) {
ber_len_t start;
+#ifdef BACKSQL_TRACE
+ Debug( LDAP_DEBUG_TRACE,
+ "==>backsql_process_sub_filter(%s): "
+ "sub_initial=\"%s\"\n", at->bam_ad->ad_cname.bv_val,
+ f->f_sub_initial.bv_val, 0 );
+#endif /* BACKSQL_TRACE */
+
start = bsi->bsi_flt_where.bb_val.bv_len;
backsql_strfcat( &bsi->bsi_flt_where, "b",
&f->f_sub_initial );
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE,
"==>backsql_process_sub_filter(%s): "
- "sub_any='%s'\n", at->bam_ad->ad_cname.bv_val,
- f->f_sub_any[ i ].bv_val, 0 );
+ "sub_any[%d]=\"%s\"\n", at->bam_ad->ad_cname.bv_val,
+ i, f->f_sub_any[ i ].bv_val );
#endif /* BACKSQL_TRACE */
start = bsi->bsi_flt_where.bb_val.bv_len;
ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
}
}
+ }
- if ( f->f_sub_final.bv_val != NULL ) {
- ber_len_t start;
+ if ( f->f_sub_final.bv_val != NULL ) {
+ ber_len_t start;
- start = bsi->bsi_flt_where.bb_val.bv_len;
- backsql_strfcat( &bsi->bsi_flt_where, "b",
- &f->f_sub_final );
- if ( casefold && BACKSQL_AT_CANUPPERCASE( at ) ) {
- ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
- }
+#ifdef BACKSQL_TRACE
+ Debug( LDAP_DEBUG_TRACE,
+ "==>backsql_process_sub_filter(%s): "
+ "sub_final=\"%s\"\n", at->bam_ad->ad_cname.bv_val,
+ f->f_sub_final.bv_val, 0 );
+#endif /* BACKSQL_TRACE */
+
+ start = bsi->bsi_flt_where.bb_val.bv_len;
+ backsql_strfcat( &bsi->bsi_flt_where, "b",
+ &f->f_sub_final );
+ if ( casefold && BACKSQL_AT_CANUPPERCASE( at ) ) {
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
}
}
return rc;
}
+static int
+backsql_process_filter_eq( backsql_srch_info *bsi, backsql_at_map_rec *at,
+ int casefold, struct berval *filter_value )
+{
+ /*
+ * maybe we should check type of at->sel_expr here somehow,
+ * to know whether upper_func is applicable, but for now
+ * upper_func stuff is made for Oracle, where UPPER is
+ * safely applicable to NUMBER etc.
+ */
+ if ( casefold && BACKSQL_AT_CANUPPERCASE( at ) ) {
+ ber_len_t start;
+
+ backsql_strfcat( &bsi->bsi_flt_where, "cbl",
+ '(', /* ) */
+ &at->bam_sel_expr_u,
+ (ber_len_t)sizeof( "='" ) - 1,
+ "='" );
+
+ start = bsi->bsi_flt_where.bb_val.bv_len;
+
+ backsql_strfcat( &bsi->bsi_flt_where, "bl",
+ filter_value,
+ (ber_len_t)sizeof( /* (' */ "')" ) - 1,
+ /* (' */ "')" );
+
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
+
+ } else {
+ backsql_strfcat( &bsi->bsi_flt_where, "cblbl",
+ '(', /* ) */
+ &at->bam_sel_expr,
+ (ber_len_t)sizeof( "='" ) - 1, "='",
+ filter_value,
+ (ber_len_t)sizeof( /* (' */ "')" ) - 1,
+ /* (' */ "')" );
+ }
+
+ return 1;
+}
+
+static int
+backsql_process_filter_like( backsql_srch_info *bsi, backsql_at_map_rec *at,
+ int casefold, struct berval *filter_value )
+{
+ /*
+ * maybe we should check type of at->sel_expr here somehow,
+ * to know whether upper_func is applicable, but for now
+ * upper_func stuff is made for Oracle, where UPPER is
+ * safely applicable to NUMBER etc.
+ */
+ if ( casefold && BACKSQL_AT_CANUPPERCASE( at ) ) {
+ ber_len_t start;
+
+ backsql_strfcat( &bsi->bsi_flt_where, "cbl",
+ '(', /* ) */
+ &at->bam_sel_expr_u,
+ (ber_len_t)sizeof( " LIKE '%" ) - 1,
+ " LIKE '%" );
+
+ start = bsi->bsi_flt_where.bb_val.bv_len;
+
+ backsql_strfcat( &bsi->bsi_flt_where, "bl",
+ filter_value,
+ (ber_len_t)sizeof( /* (' */ "%')" ) - 1,
+ /* (' */ "%')" );
+
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
+
+ } else {
+ backsql_strfcat( &bsi->bsi_flt_where, "cblbl",
+ '(', /* ) */
+ &at->bam_sel_expr,
+ (ber_len_t)sizeof( " LIKE '%" ) - 1,
+ " LIKE '%",
+ filter_value,
+ (ber_len_t)sizeof( /* (' */ "%')" ) - 1,
+ /* (' */ "%')" );
+ }
+
+ return 1;
+}
+
static int
backsql_process_filter_attr( backsql_srch_info *bsi, Filter *f, backsql_at_map_rec *at )
{
+ backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
int casefold = 0;
struct berval *filter_value = NULL;
MatchingRule *matching_rule = NULL;
casefold = 1;
}
- /*
- * maybe we should check type of at->sel_expr here somehow,
- * to know whether upper_func is applicable, but for now
- * upper_func stuff is made for Oracle, where UPPER is
- * safely applicable to NUMBER etc.
- */
- if ( casefold && BACKSQL_AT_CANUPPERCASE( at ) ) {
- ber_len_t start;
+ if ( SLAP_MR_ASSOCIATED( matching_rule,
+ bi->bi_telephoneNumberMatch ) )
+ {
+ struct berval bv;
+ ber_len_t i;
- backsql_strfcat( &bsi->bsi_flt_where, "cbl",
- '(', /* ) */
- &at->bam_sel_expr_u,
- (ber_len_t)sizeof( "='" ) - 1,
- "='" );
+ /*
+ * to check for matching telephone numbers
+ * with intermized chars, e.g. val='1234'
+ * use
+ *
+ * val LIKE '%1%2%3%4%'
+ */
- start = bsi->bsi_flt_where.bb_val.bv_len;
+ bv.bv_len = 2 * filter_value->bv_len - 1;
+ bv.bv_val = ch_malloc( bv.bv_len + 1 );
- backsql_strfcat( &bsi->bsi_flt_where, "bl",
- filter_value,
- (ber_len_t)sizeof( /* (' */ "')" ) - 1,
- /* (' */ "')" );
+ bv.bv_val[ 0 ] = filter_value->bv_val[ 0 ];
+ for ( i = 1; i < filter_value->bv_len; i++ ) {
+ bv.bv_val[ 2 * i - 1 ] = '%';
+ bv.bv_val[ 2 * i ] = filter_value->bv_val[ i ];
+ }
+ bv.bv_val[ 2 * i - 1 ] = '\0';
- ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
+ (void)backsql_process_filter_like( bsi, at, casefold, &bv );
+ ch_free( bv.bv_val );
- } else {
- backsql_strfcat( &bsi->bsi_flt_where, "cblbl",
- '(', /* ) */
- &at->bam_sel_expr,
- (ber_len_t)sizeof( "='" ) - 1, "='",
- filter_value,
- (ber_len_t)sizeof( /* (' */ "')" ) - 1,
- /* (' */ "')" );
+ break;
}
+
+ /*
+ * maybe we should check type of at->sel_expr here somehow,
+ * to know whether upper_func is applicable, but for now
+ * upper_func stuff is made for Oracle, where UPPER is
+ * safely applicable to NUMBER etc.
+ */
+ (void)backsql_process_filter_eq( bsi, at, casefold, filter_value );
break;
case LDAP_FILTER_GE:
* upper_func stuff is made for Oracle, where UPPER is
* safely applicable to NUMBER etc.
*/
- if ( at->bam_sel_expr_u.bv_val ) {
- ber_len_t start;
-
- backsql_strfcat( &bsi->bsi_flt_where, "cbl",
- '(', /* ) */
- &at->bam_sel_expr_u,
- (ber_len_t)sizeof( " LIKE '%" ) - 1,
- " LIKE '%" );
-
- start = bsi->bsi_flt_where.bb_val.bv_len;
-
- backsql_strfcat( &bsi->bsi_flt_where, "bl",
- &f->f_av_value,
- (ber_len_t)sizeof( /* (' */ "%')" ) - 1,
- /* (' */ "%')" );
-
- ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
-
- } else {
- backsql_strfcat( &bsi->bsi_flt_where, "cblbl",
- '(', /* ) */
- &at->bam_sel_expr,
- (ber_len_t)sizeof( " LIKE '%" ) - 1,
- " LIKE '%",
- &f->f_av_value,
- (ber_len_t)sizeof( /* (' */ "%')" ) - 1,
- /* (' */ "%')" );
- }
+ (void)backsql_process_filter_like( bsi, at, 1, &f->f_av_value );
break;
default:
switch ( bsi->bsi_scope ) {
case LDAP_SCOPE_BASE:
- if ( bi->upper_func.bv_val ) {
- backsql_strfcat( &bsi->bsi_join_where, "blbcb",
+ if ( BACKSQL_CANUPPERCASE( bi ) ) {
+ backsql_strfcat( &bsi->bsi_join_where, "bl",
&bi->upper_func,
- (ber_len_t)sizeof( "(ldap_entries.dn)=" ) - 1,
- "(ldap_entries.dn)=",
- &bi->upper_func_open,
- '?',
- &bi->upper_func_close );
+ (ber_len_t)sizeof( "(ldap_entries.dn)=?" ) - 1,
+ "(ldap_entries.dn)=?" );
} else {
backsql_strfcat( &bsi->bsi_join_where, "l",
(ber_len_t)sizeof( "ldap_entries.dn=?" ) - 1,
}
break;
+ case BACKSQL_SCOPE_BASE_LIKE:
+ if ( BACKSQL_CANUPPERCASE( bi ) ) {
+ backsql_strfcat( &bsi->bsi_join_where, "bl",
+ &bi->upper_func,
+ (ber_len_t)sizeof( "(ldap_entries.dn) LIKE ?" ) - 1,
+ "(ldap_entries.dn) LIKE ?" );
+ } else {
+ backsql_strfcat( &bsi->bsi_join_where, "l",
+ (ber_len_t)sizeof( "ldap_entries.dn LIKE ?" ) - 1,
+ "ldap_entries.dn LIKE ?" );
+ }
+ break;
+
case LDAP_SCOPE_ONELEVEL:
backsql_strfcat( &bsi->bsi_join_where, "l",
(ber_len_t)sizeof( "ldap_entries.parent=?" ) - 1,
break;
case LDAP_SCOPE_SUBTREE:
- if ( bi->upper_func.bv_val ) {
- backsql_strfcat( &bsi->bsi_join_where, "blbcb",
+ if ( BACKSQL_CANUPPERCASE( bi ) ) {
+ backsql_strfcat( &bsi->bsi_join_where, "bl",
&bi->upper_func,
- (ber_len_t)sizeof( "(ldap_entries.dn) LIKE " ) - 1,
- "(ldap_entries.dn) LIKE ",
- &bi->upper_func_open,
- '?',
- &bi->upper_func_close );
+ (ber_len_t)sizeof( "(ldap_entries.dn) LIKE ?" ) - 1,
+ "(ldap_entries.dn) LIKE ?" );
} else {
backsql_strfcat( &bsi->bsi_join_where, "l",
(ber_len_t)sizeof( "ldap_entries.dn LIKE ?" ) - 1,
struct berval query;
SQLHSTMT sth;
RETCODE rc;
- backsql_entryID base_id, *c_id;
+ backsql_entryID base_id = BACKSQL_ENTRYID_INIT;
int res;
BACKSQL_ROW_NTS row;
int i;
int j;
-
int n_candidates = bsi->bsi_n_candidates;
+ /*
+ * + 1 because we need room for '%'; this makes a subtree
+ * search for a DN BACKSQL_MAX_DN_LEN long legal
+ * if it returns that DN only
+ */
+ char temp_base_dn[ BACKSQL_MAX_DN_LEN + 1 + 1 ];
+
bsi->bsi_status = LDAP_SUCCESS;
- Debug( LDAP_DEBUG_TRACE, "==>backsql_oc_get_candidates(): oc='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_oc_get_candidates(): oc=\"%s\"\n",
BACKSQL_OC_NAME( oc ), 0, 0 );
if ( bsi->bsi_n_candidates == -1 ) {
res = backsql_srch_query( bsi, &query );
if ( res ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
- "error while constructing query for objectclass '%s'\n",
+ "error while constructing query for objectclass \"%s\"\n",
oc->bom_oc->soc_cname.bv_val, 0, 0 );
/*
* FIXME: need to separate errors from legally
if ( query.bv_val == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
- "could not construct query for objectclass '%s'\n",
+ "could not construct query for objectclass \"%s\"\n",
oc->bom_oc->soc_cname.bv_val, 0, 0 );
bsi->bsi_status = LDAP_SUCCESS;
return BACKSQL_CONTINUE;
switch ( bsi->bsi_scope ) {
case LDAP_SCOPE_BASE:
- Debug( LDAP_DEBUG_TRACE, "(base)dn: '%s'\n",
- bsi->bsi_base_dn->bv_val, 0, 0 );
+ case BACKSQL_SCOPE_BASE_LIKE:
+ /*
+ * We do not accept DNs longer than BACKSQL_MAX_DN_LEN;
+ * however this should be handled earlier
+ */
+ if ( bsi->bsi_base_dn->bv_len > BACKSQL_MAX_DN_LEN ) {
+ bsi->bsi_status = LDAP_OTHER;
+ return BACKSQL_CONTINUE;
+ }
- rc = backsql_BindParamStr( sth, 2, bsi->bsi_base_dn->bv_val,
+ AC_MEMCPY( temp_base_dn, bsi->bsi_base_dn->bv_val,
+ bsi->bsi_base_dn->bv_len + 1 );
+
+ /* uppercase DN only if the stored DN can be uppercased
+ * for comparison */
+ if ( BACKSQL_CANUPPERCASE( bi ) ) {
+ ldap_pvt_str2upper( temp_base_dn );
+ }
+
+ Debug( LDAP_DEBUG_TRACE, "(base)dn: \"%s\"\n",
+ temp_base_dn, 0, 0 );
+
+ rc = backsql_BindParamStr( sth, 2, temp_base_dn,
BACKSQL_MAX_DN_LEN );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
break;
case LDAP_SCOPE_SUBTREE: {
-
- /*
- * + 1 because we need room for '%'; this makes a subtree
- * search for a DN BACKSQL_MAX_DN_LEN long legal
- * if it returns that DN only
- */
- char temp_base_dn[ BACKSQL_MAX_DN_LEN + 1 + 1 ];
-
/*
* We do not accept DNs longer than BACKSQL_MAX_DN_LEN;
* however this should be handled earlier
*/
- assert( bsi->bsi_base_dn->bv_len <= BACKSQL_MAX_DN_LEN );
-
+ if ( bsi->bsi_base_dn->bv_len > BACKSQL_MAX_DN_LEN ) {
+ bsi->bsi_status = LDAP_OTHER;
+ return BACKSQL_CONTINUE;
+ }
+
/*
* Sets the parameters for the SQL built earlier
* NOTE that all the databases could actually use
AC_MEMCPY( &temp_base_dn[ 1 ], bsi->bsi_base_dn->bv_val,
bsi->bsi_base_dn->bv_len + 1 );
}
- ldap_pvt_str2upper( temp_base_dn );
- Debug( LDAP_DEBUG_TRACE, "(sub)dn: '%s'\n", temp_base_dn,
+ /* uppercase DN only if the stored DN can be uppercased
+ * for comparison */
+ if ( BACKSQL_CANUPPERCASE( bi ) ) {
+ ldap_pvt_str2upper( temp_base_dn );
+ }
+
+ Debug( LDAP_DEBUG_TRACE, "(sub)dn: \"%s\"\n", temp_base_dn,
0, 0 );
rc = backsql_BindParamStr( sth, 2, temp_base_dn,
bsi->bsi_status = res;
return BACKSQL_CONTINUE;
}
-
- Debug( LDAP_DEBUG_TRACE, "(one)id: '%lu'\n", base_id.id,
+
+#ifdef BACKSQL_ARBITRARY_KEY
+ Debug( LDAP_DEBUG_TRACE, "(one)id: \"%s\"\n",
+ base_id.eid_id.bv_val, 0, 0 );
+
+ rc = backsql_BindParamStr( sth, 2, base_id.eid_id.bv_val,
+ BACKSQL_MAX_KEY_LEN );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ Debug( LDAP_DEBUG_TRACE, "(one)id: '%lu'\n", base_id.eid_id,
0, 0 );
- rc = backsql_BindParamID( sth, 2, &base_id.id );
+ rc = backsql_BindParamID( sth, 2, &base_id.eid_id );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
backsql_free_entryID( &base_id, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
backsql_BindRowAsStrings( sth, &row );
rc = SQLFetch( sth );
for ( ; BACKSQL_SUCCESS( rc ); rc = SQLFetch( sth ) ) {
+ struct berval dn;
+ backsql_entryID *c_id = NULL;
+
+ ber_str2bv( row.cols[ 3 ], 0, 0, &dn );
+
+ if ( backsql_api_odbc2dn( bsi->bsi_op, bsi->bsi_rs, &dn ) ) {
+ continue;
+ }
+
c_id = (backsql_entryID *)ch_calloc( 1,
sizeof( backsql_entryID ) );
- c_id->id = strtol( row.cols[ 0 ], NULL, 0 );
- c_id->keyval = strtol( row.cols[ 1 ], NULL, 0 );
- c_id->oc_id = bsi->bsi_oc->bom_id;
- ber_str2bv( row.cols[ 3 ], 0, 1, &c_id->dn );
- c_id->next = bsi->bsi_id_list;
+#ifdef BACKSQL_ARBITRARY_KEY
+ ber_str2bv( row.cols[ 0 ], 0, 1, &c_id->eid_id );
+ ber_str2bv( row.cols[ 1 ], 0, 1, &c_id->eid_keyval );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ c_id->eid_id = strtol( row.cols[ 0 ], NULL, 0 );
+ c_id->eid_keyval = strtol( row.cols[ 1 ], NULL, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+ c_id->eid_oc_id = bsi->bsi_oc->bom_id;
+
+ if ( dn.bv_val == row.cols[ 3 ] ) {
+ ber_dupbv( &c_id->eid_dn, &dn );
+ } else {
+ c_id->eid_dn = dn;
+ }
+
+ c_id->eid_next = bsi->bsi_id_list;
bsi->bsi_id_list = c_id;
bsi->bsi_n_candidates--;
+#ifdef BACKSQL_ARBITRARY_KEY
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
- "added entry id=%ld, keyval=%ld dn='%s'\n",
- c_id->id, c_id->keyval, row.cols[ 3 ] );
+ "added entry id=%s, keyval=%s dn=\"%s\"\n",
+ c_id->eid_id.bv_val, c_id->eid_keyval.bv_val,
+ row.cols[ 3 ] );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
+ "added entry id=%ld, keyval=%ld dn=\"%s\"\n",
+ c_id->eid_id, c_id->eid_keyval, row.cols[ 3 ] );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
if ( bsi->bsi_n_candidates == -1 ) {
break;
time_t stoptime = 0;
backsql_srch_info srch_info;
backsql_entryID *eid = NULL;
+ struct berval base;
manageDSAit = get_manageDSAit( op );
Debug( LDAP_DEBUG_TRACE, "==>backsql_search(): "
- "base='%s', filter='%s', scope=%d,",
+ "base=\"%s\", filter=\"%s\", scope=%d,",
op->o_req_ndn.bv_val,
op->ors_filterstr.bv_val,
op->ors_scope );
/* compute it anyway; root does not use it */
stoptime = op->o_time + op->ors_tlimit;
- backsql_init_search( &srch_info, &op->o_req_dn,
+ base = op->o_req_dn;
+ if ( backsql_api_dn2odbc( op, rs, &base ) ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
+ "backsql_api_dn2odbc failed\n",
+ 0, 0, 0 );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "SQL-backend error";
+ send_ldap_result( op, rs );
+ return 1;
+ }
+
+ backsql_init_search( &srch_info, &base,
op->ors_scope,
op->ors_slimit, op->ors_tlimit,
stoptime, op->ors_filter,
- dbh, op, op->ors_attrs );
+ dbh, op, rs, op->ors_attrs );
/*
* for each objectclass we try to construct query which gets IDs
goto end_of_search;
}
+#ifdef BACKSQL_ARBITRARY_KEY
+ Debug(LDAP_DEBUG_TRACE, "backsql_search(): loading data "
+ "for entry id=%s, oc_id=%ld, keyval=%s\n",
+ eid->eid_id.bv_val, eid->eid_oc_id,
+ eid->eid_keyval.bv_val );
+#else /* ! BACKSQL_ARBITRARY_KEY */
Debug(LDAP_DEBUG_TRACE, "backsql_search(): loading data "
"for entry id=%ld, oc_id=%ld, keyval=%ld\n",
- eid->id, eid->oc_id, eid->keyval );
+ eid->eid_id, eid->eid_oc_id, eid->eid_keyval );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
entry = (Entry *)ch_calloc( sizeof( Entry ), 1 );
res = backsql_id2entry( &srch_info, entry, eid );
if ( !manageDSAit &&
op->ors_scope != LDAP_SCOPE_BASE &&
+ op->ors_scope != BACKSQL_SCOPE_BASE_LIKE &&
is_entry_referral( entry ) ) {
BerVarray refs;
struct berval matched_dn;
done:;
ch_free( srch_info.bsi_attrs );
+ if ( base.bv_val != op->o_req_ndn.bv_val ) {
+ ch_free( base.bv_val );
+ }
Debug( LDAP_DEBUG_TRACE, "<==backsql_search()\n", 0, 0, 0 );
return 0;
SQLGetInfo( dbh, SQL_DRIVER_NAME, drv_name, sizeof( drv_name ), &len );
#ifdef BACKSQL_TRACE
- Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): driver name='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): driver name=\"%s\"\n",
drv_name, 0, 0 );
#endif /* BACKSQL_TRACE */
SQL_NTS, si->dbpasswd, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: "
- "SQLConnect() to database '%s' as user '%s' "
+ "SQLConnect() to database \"%s\" as user \"%s\" "
"%s:\n", si->dbname, si->dbuser,
rc == SQL_SUCCESS_WITH_INFO ?
"succeeded with info" : "failed" );
va_end( strs );
#ifdef BACKSQL_TRACE
- Debug( LDAP_DEBUG_TRACE, "<==backsql_strcat() (dest='%s')\n",
+ Debug( LDAP_DEBUG_TRACE, "<==backsql_strcat() (dest=\"%s\")\n",
dest, 0, 0 );
#endif /* BACKSQL_TRACE */
va_end( strs );
#ifdef BACKSQL_TRACE
- Debug( LDAP_DEBUG_TRACE, "<==backsql_strfcat() (dest='%s')\n",
+ Debug( LDAP_DEBUG_TRACE, "<==backsql_strfcat() (dest=\"%s\")\n",
dest, 0, 0 );
#endif /* BACKSQL_TRACE */
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(): "
- "at_name='%s', at_val='%s'\n",
+ "at_name=\"%s\", at_val=\"%s\"\n",
at_name->bv_val, at_val->bv_val, 0 );
#endif /* BACKSQL_TRACE */
rc = slap_bv2ad( at_name, &ad, &text );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(): "
- "failed to find AttributeDescription for '%s'\n",
+ "failed to find AttributeDescription for \"%s\"\n",
at_name->bv_val, 0, 0 );
return 0;
}
if ( rc != 0 ) {
Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(): "
- "failed to merge value '%s' for attribute '%s'\n",
+ "failed to merge value \"%s\" for attribute \"%s\"\n",
at_val->bv_val, at_name->bv_val, 0 );
return 0;
}
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "==>backsql_merge_from_clause(): "
- "dest_from='%s',src_from='%s'\n",
+ "dest_from=\"%s\",src_from=\"%s\"\n",
dest_from ? dest_from->bb_val.bv_val : "<NULL>", src_from, 0 );
#endif /* BACKSQL_TRACE */
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "backsql_merge_from_clause(): "
- "p='%s' s='%s'\n", p, s, 0 );
+ "p=\"%s\" s=\"%s\"\n", p, s, 0 );
#endif /* BACKSQL_TRACE */
if ( res.bb_val.bv_val == NULL ) {
* imported into slapd without appropriate __declspec(dllimport) directives.
*/
-#if defined(SLAPD_BDB) && !defined(SLAPD_BDB_DYNAMIC)
+#if SLAPD_BDB == SLAPD_MOD_STATIC
#include "back-bdb/external.h"
#endif
-#if defined(SLAPD_DNSSRV) && !defined(SLAPD_DNSSRV_DYNAMIC)
+#if SLAPD_DNSSRV == SLAPD_MOD_STATIC
#include "back-dnssrv/external.h"
#endif
-#if defined(SLAPD_HDB) && !defined(SLAPD_HDB_DYNAMIC)
+#if SLAPD_HDB == SLAPD_MOD_STATIC
#include "back-hdb/external.h"
#endif
-#if defined(SLAPD_LDAP) && !defined(SLAPD_LDAP_DYNAMIC)
+#if SLAPD_LDAP == SLAPD_MOD_STATIC
#include "back-ldap/external.h"
#endif
-#if defined(SLAPD_LDBM) && !defined(SLAPD_LDBM_DYNAMIC)
+#if SLAPD_LDBM == SLAPD_MOD_STATIC
#include "back-ldbm/external.h"
#endif
-#if defined(SLAPD_META) && !defined(SLAPD_META_DYNAMIC)
+#if SLAPD_META == SLAPD_MOD_STATIC
#include "back-meta/external.h"
#endif
-#if defined(SLAPD_MONITOR) && !defined(SLAPD_MONITOR_DYNAMIC)
+#if SLAPD_MONITOR == SLAPD_MOD_STATIC
#include "back-monitor/external.h"
#endif
-#if defined(SLAPD_NULL) && !defined(SLAPD_NULL_DYNAMIC)
+#if SLAPD_NULL == SLAPD_MOD_STATIC
#include "back-null/external.h"
#endif
-#if defined(SLAPD_PASSWD) && !defined(SLAPD_PASSWD_DYNAMIC)
+#if SLAPD_PASSWD == SLAPD_MOD_STATIC
#include "back-passwd/external.h"
#endif
-#if defined(SLAPD_PERL) && !defined(SLAPD_PERL_DYNAMIC)
+#if SLAPD_PERL == SLAPD_MOD_STATIC
#include "back-perl/external.h"
#endif
-#if defined(SLAPD_RELAY) && !defined(SLAPD_RELAY_DYNAMIC)
+#if SLAPD_RELAY == SLAPD_MOD_STATIC
#include "back-relay/external.h"
#endif
-#if defined(SLAPD_SHELL) && !defined(SLAPD_SHELL_DYNAMIC)
+#if SLAPD_SHELL == SLAPD_MOD_STATIC
#include "back-shell/external.h"
#endif
-#if defined(SLAPD_TCL) && !defined(SLAPD_TCL_DYNAMIC)
+#if SLAPD_TCL == SLAPD_MOD_STATIC
#include "back-tcl/external.h"
#endif
-#if defined(SLAPD_SQL) && !defined(SLAPD_SQL_DYNAMIC)
+#if SLAPD_SQL == SLAPD_MOD_STATIC
#include "back-sql/external.h"
#endif
-#if defined(SLAPD_PRIVATE) && !defined(SLAPD_PRIVATE_DYNAMIC)
+#if SLAPD_PRIVATE == SLAPD_MOD_STATIC
#include "private/external.h"
#endif
static BackendInfo binfo[] = {
-#if defined(SLAPD_BDB) && !defined(SLAPD_BDB_DYNAMIC)
+#if SLAPD_BDB == SLAPD_MOD_STATIC
{"bdb", bdb_initialize},
#endif
-#if defined(SLAPD_DNSSRV) && !defined(SLAPD_DNSSRV_DYNAMIC)
+#if SLAPD_DNSSRV == SLAPD_MOD_STATIC
{"dnssrv", dnssrv_back_initialize},
#endif
-#if defined(SLAPD_HDB) && !defined(SLAPD_HDB_DYNAMIC)
+#if SLAPD_HDB == SLAPD_MOD_STATIC
{"hdb", hdb_initialize},
#endif
-#if defined(SLAPD_LDAP) && !defined(SLAPD_LDAP_DYNAMIC)
+#if SLAPD_LDAP == SLAPD_MOD_STATIC
{"ldap", ldap_back_initialize},
#endif
-#if defined(SLAPD_LDBM) && !defined(SLAPD_LDBM_DYNAMIC)
+#if SLAPD_LDBM == SLAPD_MOD_STATIC
{"ldbm", ldbm_back_initialize},
#endif
-#if defined(SLAPD_META) && !defined(SLAPD_META_DYNAMIC)
+#if SLAPD_META == SLAPD_MOD_STATIC
{"meta", meta_back_initialize},
#endif
-#if defined(SLAPD_MONITOR) && !defined(SLAPD_MONITOR_DYNAMIC)
+#if SLAPD_MONITOR == SLAPD_MOD_STATIC
{"monitor", monitor_back_initialize},
#endif
-#if defined(SLAPD_NULL) && !defined(SLAPD_NULL_DYNAMIC)
+#if SLAPD_NULL == SLAPD_MOD_STATIC
{"null", null_back_initialize},
#endif
-#if defined(SLAPD_PASSWD) && !defined(SLAPD_PASSWD_DYNAMIC)
+#if SLAPD_PASSWD == SLAPD_MOD_STATIC
{"passwd", passwd_back_initialize},
#endif
-#if defined(SLAPD_PERL) && !defined(SLAPD_PERL_DYNAMIC)
+#if SLAPD_PERL == SLAPD_MOD_STATIC
{"perl", perl_back_initialize},
#endif
-#if defined(SLAPD_RELAY) && !defined(SLAPD_RELAY_DYNAMIC)
+#if SLAPD_RELAY == SLAPD_MOD_STATIC
{"relay", relay_back_initialize},
#endif
-#if defined(SLAPD_SHELL) && !defined(SLAPD_SHELL_DYNAMIC)
+#if SLAPD_SHELL == SLAPD_MOD_STATIC
{"shell", shell_back_initialize},
#endif
-#if defined(SLAPD_TCL) && !defined(SLAPD_TCL_DYNAMIC)
+#if SLAPD_TCL == SLAPD_MOD_STATIC
{"tcl", tcl_back_initialize},
#endif
-#if defined(SLAPD_SQL) && !defined(SLAPD_SQL_DYNAMIC)
+#if SLAPD_SQL == SLAPD_MOD_STATIC
{"sql", sql_back_initialize},
#endif
/* for any private backend */
-#if defined(SLAPD_PRIVATE) && !defined(SLAPD_PRIVATE_DYNAMIC)
+#if SLAPD_PRIVATE == SLAPD_MOD_STATIC
{"private", private_back_initialize},
#endif
{NULL}
}
int
-be_isupdate( Operation *op )
+be_sync_update( Operation *op )
{
- return be_isupdate_dn( op->o_bd, &op->o_ndn );
+ return ( SLAP_SYNC_SHADOW( op->o_bd ) && syncrepl_isupdate( op ) );
+}
+
+int
+be_slurp_update( Operation *op )
+{
+ return ( SLAP_SLURP_SHADOW( op->o_bd ) && be_isupdate_dn( op->o_bd, &op->o_ndn ));
+}
+
+int
+be_shadow_update( Operation *op )
+{
+#if 0
+ return ( be_sync_update( op ) || be_slurp_update( op ) );
+#endif
+ /* NOTE: this is slightly more efficient */
+ return ( SLAP_SHADOW( op->o_bd ) && ( syncrepl_isupdate( op ) || be_isupdate_dn( op->o_bd, &op->o_ndn ) ) );
}
int
0,
-1, /* no limit on unchecked size */
0, /* page limit */
- 0 /* hide number of entries left */
+ 0, /* hide number of entries left */
+ 0 /* number of total entries returned by pagedResults equal to hard limit */
};
AccessControl *global_acl = NULL;
char **default_passwd_hash = NULL;
int cargc = 0, cargv_size = 0;
char **cargv;
-struct berval default_search_base = { 0, NULL };
-struct berval default_search_nbase = { 0, NULL };
+struct berval default_search_base = BER_BVNULL;
+struct berval default_search_nbase = BER_BVNULL;
unsigned num_subordinates = 0;
-struct berval global_schemadn = { 0, NULL };
-struct berval global_schemandn = { 0, NULL };
+struct berval global_schemadn = BER_BVNULL;
+struct berval global_schemandn = BER_BVNULL;
ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
return 1;
}
- SLAP_DBFLAGS(be) |= SLAP_DBFLAG_SHADOW;
+ SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW );
/* list of replicas of the data in this backend (master only) */
} else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
}
}
- SLAP_DBFLAGS(be) |= SLAP_DBFLAG_SHADOW;
+ SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW );
} else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
if ( cargc < 2 ) {
LDAPControl *ctrl )
{
int rc;
- struct berval dn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
if ( op->o_proxy_authz != SLAP_NO_CONTROL ) {
rs->sr_text = "proxy authorization control specified multiple times";
ber_tag_t tag;
ber_int_t size;
BerElement *ber;
- struct berval cookie = { 0, NULL };
+ struct berval cookie = BER_BVNULL;
if ( op->o_pagedresults != SLAP_NO_CONTROL ) {
rs->sr_text = "paged results control specified multiple times";
AC_MEMCPY( &reqcookie, cookie.bv_val, sizeof( reqcookie ));
- if( reqcookie > op->o_pagedresults_state.ps_cookie ) {
+ if ( reqcookie > op->o_pagedresults_state.ps_cookie ) {
/* bad cookie */
rs->sr_text = "paged results cookie is invalid";
return LDAP_PROTOCOL_ERROR;
- } else if( reqcookie < op->o_pagedresults_state.ps_cookie ) {
+ } else if ( reqcookie < op->o_pagedresults_state.ps_cookie ) {
rs->sr_text = "paged results cookie is invalid or old";
return LDAP_UNWILLING_TO_PERFORM;
}
+
} else {
/* Initial request. Initialize state. */
op->o_pagedresults_state.ps_cookie = 0;
op->o_pagedresults_state.ps_id = NOID;
+ op->o_pagedresults_state.ps_count = 0;
}
op->o_pagedresults_size = size;
LDAPControl *ctrl )
{
BerElement *ber;
- struct berval fstr = { 0, NULL };
+ struct berval fstr = BER_BVNULL;
const char *err_msg = "";
if ( op->o_assert != SLAP_NO_CONTROL ) {
LDAPControl *ctrl )
{
BerElement *ber;
- struct berval fstr = { 0, NULL };
+ struct berval fstr = BER_BVNULL;
const char *err_msg = "";
if ( op->o_valuesreturnfilter != SLAP_NO_CONTROL ) {
SlapReply *rs
)
{
- struct berval dn = { 0, NULL };
- struct berval pdn = { 0, NULL };
- struct berval org_req_dn = { 0, NULL };
- struct berval org_req_ndn = { 0, NULL };
- struct berval org_dn = { 0, NULL };
- struct berval org_ndn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
+ struct berval pdn = BER_BVNULL;
+ struct berval org_req_dn = BER_BVNULL;
+ struct berval org_req_ndn = BER_BVNULL;
+ struct berval org_dn = BER_BVNULL;
+ struct berval org_ndn = BER_BVNULL;
int org_managedsait;
int manageDSAit;
int repl_user = be_isupdate( op );
#ifndef SLAPD_MULTIMASTER
if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#else
- if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ))
#endif
{
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
} else if ( strcasecmp( pattern, "users" ) == 0 ) {
flags = SLAP_LIMITS_USERS;
- } else if ( strncasecmp( pattern, "dn", sizeof( "dn" ) - 1 ) == 0 ) {
- pattern += sizeof( "dn" ) - 1;
+ } else if ( strncasecmp( pattern, "dn", STRLENOF( "dn" ) ) == 0 ) {
+ pattern += STRLENOF( "dn" );
if ( pattern[0] == '.' ) {
pattern++;
- if ( strncasecmp( pattern, "exact", sizeof( "exact" ) - 1 ) == 0 ) {
+ if ( strncasecmp( pattern, "exact", STRLENOF( "exact" )) == 0 ) {
flags = SLAP_LIMITS_EXACT;
- pattern += sizeof( "exact" ) - 1;
+ pattern += STRLENOF( "exact" );
- } else if ( strncasecmp( pattern, "base", sizeof( "base" ) - 1 ) == 0 ) {
+ } else if ( strncasecmp( pattern, "base", STRLENOF( "base" ) ) == 0 ) {
flags = SLAP_LIMITS_BASE;
- pattern += sizeof( "base" ) - 1;
+ pattern += STRLENOF( "base" );
- } else if ( strncasecmp( pattern, "one", sizeof( "one" ) - 1 ) == 0 ) {
+ } else if ( strncasecmp( pattern, "one", STRLENOF( "one" ) ) == 0 ) {
flags = SLAP_LIMITS_ONE;
- pattern += sizeof( "one" ) - 1;
- if ( strncasecmp( pattern, "level", sizeof( "level" ) - 1 ) == 0 ) {
- pattern += sizeof( "level" ) - 1;
+ pattern += STRLENOF( "one" );
+ if ( strncasecmp( pattern, "level", STRLENOF( "level" ) ) == 0 ) {
+ pattern += STRLENOF( "level" );
} else {
#ifdef NEW_LOGGING
#endif
}
- } else if ( strncasecmp( pattern, "sub", sizeof( "sub" ) - 1 ) == 0 ) {
+ } else if ( strncasecmp( pattern, "sub", STRLENOF( "sub" ) ) == 0 ) {
flags = SLAP_LIMITS_SUBTREE;
- pattern += sizeof( "sub" ) - 1;
- if ( strncasecmp( pattern, "tree", sizeof( "tree" ) - 1 ) == 0 ) {
- pattern += sizeof( "tree" ) - 1;
+ pattern += STRLENOF( "sub" );
+ if ( strncasecmp( pattern, "tree", STRLENOF( "tree" ) ) == 0 ) {
+ pattern += STRLENOF( "tree" );
} else {
#ifdef NEW_LOGGING
#endif
}
- } else if ( strncasecmp( pattern, "children", sizeof( "children" ) - 1 ) == 0 ) {
+ } else if ( strncasecmp( pattern, "children", STRLENOF( "children" ) ) == 0 ) {
flags = SLAP_LIMITS_CHILDREN;
- pattern += sizeof( "children" ) - 1;
+ pattern += STRLENOF( "children" );
- } else if ( strncasecmp( pattern, "regex", sizeof( "regex" ) - 1 ) == 0 ) {
+ } else if ( strncasecmp( pattern, "regex", STRLENOF( "regex" ) ) == 0 ) {
flags = SLAP_LIMITS_REGEX;
- pattern += sizeof( "regex" ) - 1;
+ pattern += STRLENOF( "regex" );
/*
* this could be deprecated in favour
* of the pattern = "anonymous" form
*/
- } else if ( strncasecmp( pattern, "anonymous", sizeof( "anonymous" ) - 1 ) == 0 ) {
+ } else if ( strncasecmp( pattern, "anonymous", STRLENOF( "anonymous" ) ) == 0 ) {
flags = SLAP_LIMITS_ANONYMOUS;
pattern = NULL;
}
}
}
- } else if (strncasecmp( pattern, "group", sizeof( "group" ) - 1 ) == 0 ) {
- pattern += sizeof( "group" ) - 1;
+ } else if (strncasecmp( pattern, "group", STRLENOF( "group" ) ) == 0 ) {
+ pattern += STRLENOF( "group" );
if ( pattern[0] == '/' ) {
struct berval oc, ad;
|| limit.lms_s_soft == -1 ) ) {
limit.lms_s_hard = limit.lms_s_soft;
}
-
+
+ /*
+ * defaults ...
+ */
+ if ( limit.lms_t_hard == 0 ) {
+ limit.lms_t_hard = limit.lms_t_soft;
+ }
+
+ if ( limit.lms_s_hard == 0 ) {
+ limit.lms_s_hard = limit.lms_s_soft;
+ }
+
+ if ( limit.lms_s_pr_total == 0 ) {
+ limit.lms_s_pr_total = limit.lms_s_hard;
+ }
+
rc = limits_add( be, flags, pattern, group_oc, group_ad, &limit );
if ( rc ) {
assert( arg );
assert( limit );
- if ( strncasecmp( arg, "time", sizeof( "time" ) - 1 ) == 0 ) {
- arg += 4;
+ if ( strncasecmp( arg, "time", STRLENOF( "time" ) ) == 0 ) {
+ arg += STRLENOF( "time" );
if ( arg[0] == '.' ) {
arg++;
- if ( strncasecmp( arg, "soft", sizeof( "soft" ) - 1 ) == 0 ) {
- arg += 4;
- if ( arg[0] != '=' ) {
- return( 1 );
- }
- arg++;
+ if ( strncasecmp( arg, "soft=", STRLENOF( "soft=" ) ) == 0 ) {
+ arg += STRLENOF( "soft=" );
if ( strcasecmp( arg, "none" ) == 0 ) {
limit->lms_t_soft = -1;
+
} else {
char *next = NULL;
+ int soft = strtol( arg, &next, 10 );
- limit->lms_t_soft =
- strtol( arg, &next, 10 );
- if ( next == arg || limit->lms_t_soft < -1 ) {
+ if ( next == arg || next[ 0 ] != '\0' ) {
return( 1 );
}
+
+ if ( soft < -1 ) {
+ return( 1 );
+ }
+
+ if ( soft == -1 ) {
+ /* FIXME: use "none" instead */
+ }
+
+ limit->lms_t_soft = soft;
}
- } else if ( strncasecmp( arg, "hard", sizeof( "hard" ) - 1 ) == 0 ) {
- arg += 4;
- if ( arg[0] != '=' ) {
- return( 1 );
- }
- arg++;
+ } else if ( strncasecmp( arg, "hard=", STRLENOF( "hard=" ) ) == 0 ) {
+ arg += STRLENOF( "hard=" );
if ( strcasecmp( arg, "soft" ) == 0 ) {
limit->lms_t_hard = 0;
+
} else if ( strcasecmp( arg, "none" ) == 0 ) {
limit->lms_t_hard = -1;
+
} else {
char *next = NULL;
+ int hard = strtol( arg, &next, 10 );
- limit->lms_t_hard =
- strtol( arg, &next, 10 );
- if ( next == arg || limit->lms_t_hard < -1 ) {
+ if ( next == arg || next[ 0 ] != '\0' ) {
return( 1 );
}
+
+ if ( hard < -1 ) {
+ return( 1 );
+ }
+
+ if ( hard == -1 ) {
+ /* FIXME: use "none" instead */
+ }
+
+ if ( hard == 0 ) {
+ /* FIXME: use "soft" instead */
+ }
+
+ limit->lms_t_hard = hard;
}
} else {
return( 1 );
}
- } else if ( strncasecmp( arg, "size", sizeof( "size" ) - 1 ) == 0 ) {
- arg += 4;
+ } else if ( strncasecmp( arg, "size", STRLENOF( "size" ) ) == 0 ) {
+ arg += STRLENOF( "size" );
if ( arg[0] == '.' ) {
arg++;
- if ( strncasecmp( arg, "soft", sizeof( "soft" ) - 1 ) == 0 ) {
- arg += 4;
- if ( arg[0] != '=' ) {
- return( 1 );
- }
- arg++;
+ if ( strncasecmp( arg, "soft=", STRLENOF( "soft=" ) ) == 0 ) {
+ arg += STRLENOF( "soft=" );
if ( strcasecmp( arg, "none" ) == 0 ) {
limit->lms_s_soft = -1;
} else {
char *next = NULL;
+ int soft = strtol( arg, &next, 10 );
+
+ if ( next == arg || next[ 0 ] != '\0' ) {
+ return( 1 );
+ }
- limit->lms_s_soft =
- strtol( arg, &next, 10 );
- if ( next == arg || limit->lms_s_soft < -1 ) {
+ if ( soft < -1 ) {
return( 1 );
}
+
+ if ( soft == -1 ) {
+ /* FIXME: use "none" instead */
+ }
+
+ limit->lms_s_soft = soft;
}
- } else if ( strncasecmp( arg, "hard", sizeof( "hard" ) - 1 ) == 0 ) {
- arg += 4;
- if ( arg[0] != '=' ) {
- return( 1 );
- }
- arg++;
+ } else if ( strncasecmp( arg, "hard=", STRLENOF( "hard=" ) ) == 0 ) {
+ arg += STRLENOF( "hard=" );
if ( strcasecmp( arg, "soft" ) == 0 ) {
limit->lms_s_hard = 0;
+
} else if ( strcasecmp( arg, "none" ) == 0 ) {
limit->lms_s_hard = -1;
+
} else {
char *next = NULL;
+ int hard = strtol( arg, &next, 10 );
+
+ if ( next == arg || next[ 0 ] != '\0' ) {
+ return( 1 );
+ }
- limit->lms_s_hard =
- strtol( arg, &next, 10 );
- if ( next == arg || limit->lms_s_hard < -1 ) {
+ if ( hard < -1 ) {
return( 1 );
}
+
+ if ( hard == -1 ) {
+ /* FIXME: use "none" instead */
+ }
+
+ if ( hard == 0 ) {
+ /* FIXME: use "soft" instead */
+ }
+
+ limit->lms_s_hard = hard;
}
- } else if ( strncasecmp( arg, "unchecked", sizeof( "unchecked" ) - 1 ) == 0 ) {
- arg += 9;
- if ( arg[0] != '=' ) {
- return( 1 );
- }
- arg++;
+ } else if ( strncasecmp( arg, "unchecked=", STRLENOF( "unchecked=" ) ) == 0 ) {
+ arg += STRLENOF( "unchecked=" );
if ( strcasecmp( arg, "none" ) == 0 ) {
limit->lms_s_unchecked = -1;
+
+ } else if ( strcasecmp( arg, "disabled" ) == 0 ) {
+ limit->lms_s_unchecked = 0;
+
} else {
char *next = NULL;
+ int unchecked = strtol( arg, &next, 10 );
- limit->lms_s_unchecked =
- strtol( arg, &next, 10 );
- if ( next == arg || limit->lms_s_unchecked < -1 ) {
+ if ( next == arg || next[ 0 ] != '\0' ) {
return( 1 );
}
- }
- } else if ( strncasecmp( arg, "pr", sizeof( "pr" ) - 1 ) == 0 ) {
- arg += sizeof( "pr" ) - 1;
- if ( arg[0] != '=' ) {
- return( 1 );
+ if ( unchecked < -1 ) {
+ return( 1 );
+ }
+
+ if ( unchecked == -1 ) {
+ /* FIXME: use "none" instead */
+ }
+
+ limit->lms_s_unchecked = unchecked;
}
- arg++;
+
+ } else if ( strncasecmp( arg, "pr=", STRLENOF( "pr=" ) ) == 0 ) {
+ arg += STRLENOF( "pr=" );
if ( strcasecmp( arg, "noEstimate" ) == 0 ) {
limit->lms_s_pr_hide = 1;
+
+ } else if ( strcasecmp( arg, "none" ) == 0 ) {
+ limit->lms_s_pr = -1;
+
+ } else if ( strcasecmp( arg, "disabled" ) == 0 ) {
+ limit->lms_s_pr_total = -2;
+
} else {
char *next = NULL;
+ int pr = strtol( arg, &next, 10 );
- limit->lms_s_pr =
- strtol( arg, &next, 10 );
- if ( next == arg || limit->lms_s_pr < -1 ) {
+ if ( next == arg || next[ 0 ] != '\0' ) {
return( 1 );
}
+
+ if ( pr < -1 ) {
+ return( 1 );
+ }
+
+ if ( pr == -1 ) {
+ /* FIXME: use "none" instead */
+ }
+
+ limit->lms_s_pr = pr;
}
-
+
+ } else if ( strncasecmp( arg, "prtotal=", STRLENOF( "prtotal=" ) ) == 0 ) {
+ arg += STRLENOF( "prtotal=" );
+
+ if ( strcasecmp( arg, "none" ) == 0 ) {
+ limit->lms_s_pr_total = -1;
+
+ } else if ( strcasecmp( arg, "hard" ) == 0 ) {
+ limit->lms_s_pr_total = 0;
+
+ } else {
+ char *next = NULL;
+ int total;
+
+ total = strtol( arg, &next, 10 );
+ if ( next == arg || next[ 0 ] != '\0' ) {
+ return( 1 );
+ }
+
+ if ( total < -1 ) {
+ return( 1 );
+ }
+
+ if ( total == -1 ) {
+ /* FIXME: use "none" instead */
+ }
+
+ if ( total == 0 ) {
+ /* FIXME: use "pr=disable" instead */
+ }
+
+ limit->lms_s_pr_total = total;
+ }
+
} else {
return( 1 );
}
/* negative hard limit means no limit */
}
+
+ /* don't even get to backend if candidate check is disabled */
+ if ( op->ors_limit->lms_s_unchecked == 0 ) {
+ rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
+ send_ldap_result( op, rs );
+ rs->sr_err = LDAP_SUCCESS;
+ return -1;
+ }
+
+ /* if paged results is requested */
+ if ( get_pagedresults( op ) ) {
+ int slimit = -2;
+
+ /* paged results is not allowed */
+ if ( op->ors_limit->lms_s_pr_total == -2 ) {
+ rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
+ rs->sr_text = "pagedResults control not allowed";
+ send_ldap_result( op, rs );
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_text = NULL;
+ return -1;
- /* if no limit is required, use soft limit */
- if ( op->ors_slimit <= 0 ) {
- if ( get_pagedresults( op ) && op->ors_limit->lms_s_pr != 0 ) {
- op->ors_slimit = op->ors_limit->lms_s_pr;
} else {
- op->ors_slimit = op->ors_limit->lms_s_soft;
+ /* if no limit is required, use soft limit */
+ int total;
+ int slimit2 = -1;
+
+ /* first round of pagedResults: set count to any appropriate limit */
+
+ /* if the limit is set, check that it does not violate any limit */
+ if ( op->ors_slimit > 0 ) {
+ slimit2 = op->ors_slimit;
+ if ( op->ors_limit->lms_s_pr_total > 0 ) {
+ if ( op->ors_slimit > op->ors_limit->lms_s_pr_total ) {
+ slimit2 = -2;
+ }
+
+ } else if ( op->ors_limit->lms_s_hard > 0 ) {
+ if ( op->ors_slimit > op->ors_limit->lms_s_hard ) {
+ slimit2 = -2;
+ }
+
+ } else if ( op->ors_limit->lms_s_soft > 0 && op->ors_slimit > op->ors_limit->lms_s_soft ) {
+ if ( op->ors_slimit > op->ors_limit->lms_s_soft ) {
+ slimit2 = -2;
+ }
+ }
+
+ if ( slimit2 == -2 ) {
+ rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
+ send_ldap_result( op, rs );
+ rs->sr_err = LDAP_SUCCESS;
+ return -1;
+ }
+
+ } else {
+ if ( op->ors_limit->lms_s_pr_total > 0 ) {
+ slimit2 = op->ors_limit->lms_s_pr_total;
+
+ } else if ( op->ors_limit->lms_s_hard > 0 ) {
+ slimit2 = op->ors_limit->lms_s_hard;
+
+ } else if ( op->ors_limit->lms_s_soft > 0 ) {
+ slimit2 = op->ors_limit->lms_s_soft;
+ }
+ }
+
+ total = slimit2 - op->o_pagedresults_state.ps_count;
+
+ if ( total >= 0 && op->ors_limit->lms_s_pr > 0 ) {
+ /* use the smallest limit set by total/per page */
+ if ( total < op->ors_limit->lms_s_pr ) {
+ slimit = total;
+
+ } else {
+ /* use the perpage limit if any
+ * NOTE: + 1 because the given value must be legal */
+ slimit = op->ors_limit->lms_s_pr + 1;
+ }
+
+ } else if ( total >= 0 ) {
+ /* use the total limit if any */
+ slimit = total;
+
+ } else if ( op->ors_limit->lms_s_pr != 0 ) {
+ /* use the perpage limit if any
+ * NOTE: + 1 because the given value must be legal */
+ slimit = op->ors_limit->lms_s_pr + 1;
+
+ } else {
+ /* use the standard hard/soft limit if any */
+ slimit = op->ors_limit->lms_s_hard;
+ }
+ }
+
+ /* if got any limit, use it */
+ if ( slimit != -2 ) {
+ if ( op->ors_slimit <= 0 ) {
+ op->ors_slimit = slimit;
+
+ } else if ( op->ors_slimit - op->o_pagedresults_state.ps_count > slimit ) {
+ rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
+ send_ldap_result( op, rs );
+ rs->sr_err = LDAP_SUCCESS;
+ return -1;
+ } else {
+ op->ors_slimit = slimit;
+ }
+
+ } else {
+ /* use the standard hard/soft limit if any */
+ op->ors_slimit = op->ors_limit->lms_s_hard;
}
/* if requested limit higher than hard limit, abort */
}
/* negative hard limit means no limit */
+
+ } else if ( op->ors_slimit == 0 ) {
+ op->ors_slimit = op->ors_limit->lms_s_soft;
}
}
Operation *op,
SlapReply *rs )
{
- struct berval dn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
char *last;
ber_tag_t tag;
ber_len_t len;
Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
#endif
-
/* collect modifications & save for later */
-
for ( tag = ber_first_element( op->o_ber, &len, &last );
tag != LBER_DEFAULT;
tag = ber_next_element( op->o_ber, &len, last ) )
tmp.sml_nvalues = NULL;
if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
- &tmp.sml_type, &tmp.sml_values )
- == LBER_ERROR )
+ &tmp.sml_type, &tmp.sml_values ) == LBER_ERROR )
{
- send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding modlist error" );
+ send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR,
+ "decoding modlist error" );
rs->sr_err = SLAPD_DISCONNECT;
goto cleanup;
}
*/
#ifndef SLAPD_MULTIMASTER
if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#else
- if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ))
#endif
{
int update = op->o_bd->be_update_ndn.bv_len;
#if defined( LDAP_SLAPI )
} /* modlist != NULL */
- if ( pb != NULL && slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
+ if ( pb != NULL && slapi_int_call_plugins( op->o_bd,
+ SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 )
+ {
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
- "failed\n", 0, 0, 0 );
+ LDAP_LOG( OPERATION, INFO,
+ "do_modify: modify postoperation plugins failed\n", 0, 0, 0 );
#else
- Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
- "failed.\n", 0, 0, 0);
+ Debug(LDAP_DEBUG_TRACE,
+ "do_modify: modify postoperation plugins failed.\n", 0, 0, 0);
#endif
}
#endif /* defined( LDAP_SLAPI ) */
cleanup:
-
slap_graduate_commit_csn( op );
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
ml->sml_nvalues[nvals].bv_val = NULL;
ml->sml_nvalues[nvals].bv_len = 0;
}
+
+ if( nvals ) {
+ /* check for duplicates */
+ int i, j;
+ MatchingRule *mr = ad->ad_type->sat_equality;
+
+ /* check if the values we're adding already exist */
+ if( mr == NULL || !mr->smr_match ) {
+ for ( i = 1; ml->sml_values[i].bv_val != NULL; i++ ) {
+ /* test asserted values against themselves */
+ for( j = 0; j < i; j++ ) {
+ if ( bvmatch( &ml->sml_values[i],
+ &ml->sml_values[j] ) )
+ {
+ /* value exists already */
+ snprintf( textbuf, textlen,
+ "%s: value #%d provided more than once",
+ ml->sml_desc->ad_cname.bv_val, j );
+ *text = textbuf;
+ return LDAP_TYPE_OR_VALUE_EXISTS;
+ }
+ }
+ }
+
+ } else {
+ int rc = LDAP_SUCCESS;
+ int match;
+
+ for ( i = 1; ml->sml_values[i].bv_val != NULL; i++ ) {
+ /* test asserted values against themselves */
+ for( j = 0; j < i; j++ ) {
+ rc = value_match( &match, ml->sml_desc, mr,
+ SLAP_MR_EQUALITY
+ | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
+ | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
+ | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+ ml->sml_nvalues
+ ? &ml->sml_nvalues[i]
+ : &ml->sml_values[i],
+ ml->sml_nvalues
+ ? &ml->sml_nvalues[j]
+ : &ml->sml_values[j],
+ text );
+ if ( rc == LDAP_SUCCESS && match == 0 ) {
+ /* value exists already */
+ snprintf( textbuf, textlen,
+ "%s: value #%d provided more than once",
+ ml->sml_desc->ad_cname.bv_val, j );
+ *text = textbuf;
+ return LDAP_TYPE_OR_VALUE_EXISTS;
+ }
+ }
+ }
+
+ if ( rc != LDAP_SUCCESS ) return rc;
+ }
+ }
+
}
}
SlapReply *rs
)
{
- struct berval dn = { 0, NULL };
- struct berval newrdn = { 0, NULL };
- struct berval newSuperior = { 0, NULL };
+ struct berval dn = BER_BVNULL;
+ struct berval newrdn = BER_BVNULL;
+ struct berval newSuperior = BER_BVNULL;
ber_int_t deloldrdn;
- struct berval pnewSuperior = { 0, NULL };
+ struct berval pnewSuperior = BER_BVNULL;
- struct berval nnewSuperior = { 0, NULL };
+ struct berval nnewSuperior = BER_BVNULL;
Backend *newSuperior_be = NULL;
ber_len_t length;
int manageDSAit;
- struct berval pdn = { 0, NULL };
- struct berval org_req_dn = { 0, NULL };
- struct berval org_req_ndn = { 0, NULL };
- struct berval org_dn = { 0, NULL };
- struct berval org_ndn = { 0, NULL };
+ struct berval pdn = BER_BVNULL;
+ struct berval org_req_dn = BER_BVNULL;
+ struct berval org_req_ndn = BER_BVNULL;
+ struct berval org_dn = BER_BVNULL;
+ struct berval org_ndn = BER_BVNULL;
int org_managedsait;
#ifdef NEW_LOGGING
int repl_user = be_isupdate( op );
#ifndef SLAPD_MULTIMASTER
if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#else
- if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ))
#endif
{
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
#include "slap.h"
-int
-modify_check_duplicates(
- AttributeDescription *ad,
- MatchingRule *mr,
- BerVarray vals,
- BerVarray mods,
- int permissive,
- const char **text,
- char *textbuf, size_t textlen )
-{
- int i, j, numvals = 0, nummods,
- rc = LDAP_SUCCESS, matched;
- /* this function is no longer used */
- return rc;
-}
-
int
modify_add_values(
Entry *e,
const char **text,
char *textbuf, size_t textlen )
{
- int i, j;
- int matched;
- Attribute *a;
- MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
+ int rc;
const char *op;
+ Attribute *a;
+ Modification pmod = *mod;
switch( mod->sm_op ) {
case LDAP_MOD_ADD:
}
a = attr_find( e->e_attrs, mod->sm_desc );
+ if( a != NULL ) { /* check if values to add exist in attribute */
+ int rc, i, j, p;
+ MatchingRule *mr;
- /*
- * With permissive set, as long as the attribute being added
- * has the same value(s?) as the existing attribute, then the
- * modify will succeed.
- */
-
- /* check if the values we're adding already exist */
- if( mr == NULL || !mr->smr_match ) {
- if ( a != NULL ) {
+ mr = mod->sm_desc->ad_type->sat_equality;
+ if( mr == NULL || !mr->smr_match ) {
/* do not allow add of additional attribute
if no equality rule exists */
*text = textbuf;
return LDAP_INAPPROPRIATE_MATCHING;
}
- for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
- /* test asserted values against existing values */
- if( a ) {
- for( matched = 0, j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
- if ( bvmatch( &mod->sm_bvalues[i], &a->a_vals[j] ) ) {
- if ( permissive ) {
- matched++;
- continue;
- }
- /* value exists already */
- *text = textbuf;
- snprintf( textbuf, textlen,
- "modify/%s: %s: value #%i already exists",
- op, mod->sm_desc->ad_cname.bv_val, j );
- return LDAP_TYPE_OR_VALUE_EXISTS;
- }
- }
- if ( permissive && matched == j ) {
- /* values already exist; do nothing */
- return LDAP_SUCCESS;
- }
- }
-
- /* test asserted values against themselves */
- for( j = 0; j < i; j++ ) {
- if ( bvmatch( &mod->sm_bvalues[i], &mod->sm_bvalues[j] ) ) {
- /* value exists already */
- *text = textbuf;
- snprintf( textbuf, textlen,
- "modify/%s: %s: value #%i already exists",
- op, mod->sm_desc->ad_cname.bv_val, j );
- return LDAP_TYPE_OR_VALUE_EXISTS;
- }
+ if( permissive ) {
+ for ( i=0; mod->sm_values[i].bv_val; i++ ) /* count 'em */;
+ pmod.sm_values = (BerVarray) ch_malloc( i*sizeof( struct berval ));
+ if( pmod.sm_nvalues != NULL ) {
+ pmod.sm_nvalues = (BerVarray) ch_malloc(
+ i*sizeof( struct berval ));
}
}
- } else {
/* no normalization is done in this routine nor
* in the matching routines called by this routine.
* values are now normalized once on input to the
* server (whether from LDAP or from the underlying
* database).
- * This should outperform the old code. No numbers
- * are available yet.
*/
-
- int rc;
-
- if ( mod->sm_bvalues[1].bv_val == 0 ) {
- if ( a != NULL ) {
- int i;
-
- for ( matched = 0, i = 0; a->a_vals[ i ].bv_val; i++ ) {
- int match;
-
- if( mod->sm_nvalues ) {
- rc = value_match( &match, mod->sm_desc, mr,
- SLAP_MR_EQUALITY
- | SLAP_MR_VALUE_OF_ASSERTION_SYNTAX
- | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
- | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
- &a->a_nvals[i],
- &mod->sm_nvalues[0],
- text );
-
- } else {
- rc = value_match( &match, mod->sm_desc, mr,
- SLAP_MR_EQUALITY
- | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
- &a->a_vals[i],
- &mod->sm_values[0],
- text );
- }
-
-
- if( rc == LDAP_SUCCESS && match == 0 ) {
- if ( permissive ) {
- matched++;
- continue;
- }
- *text = textbuf;
- snprintf( textbuf, textlen,
- "modify/%s: %s: value #0 already exists",
- op, mod->sm_desc->ad_cname.bv_val );
- return LDAP_TYPE_OR_VALUE_EXISTS;
- }
+ for ( p=i=0; mod->sm_values[i].bv_val; i++ ) {
+ int match;
+ assert( a->a_vals[0].bv_val );
+ for ( j=0; a->a_vals[j].bv_val; j++ ) {
+ if( mod->sm_nvalues ) {
+ rc = value_match( &match, mod->sm_desc, mr,
+ SLAP_MR_EQUALITY | SLAP_MR_VALUE_OF_ASSERTION_SYNTAX
+ | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
+ | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+ &a->a_nvals[j], &mod->sm_nvalues[i], text );
+ } else {
+ rc = value_match( &match, mod->sm_desc, mr,
+ SLAP_MR_EQUALITY | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+ &a->a_vals[j], &mod->sm_values[i], text );
}
- if ( permissive && matched == i ) {
- /* values already exist; do nothing */
- return LDAP_SUCCESS;
- }
- }
- } else {
- rc = modify_check_duplicates( mod->sm_desc, mr,
- a ? a->a_vals : NULL, mod->sm_bvalues,
- permissive, text, textbuf, textlen );
+ if( rc == LDAP_SUCCESS && match == 0 ) {
+ if( permissive ) break;
- if ( permissive && rc == LDAP_TYPE_OR_VALUE_EXISTS ) {
- return LDAP_SUCCESS;
+ /* value already exists */
+ *text = textbuf;
+ snprintf( textbuf, textlen,
+ "modify/%s: %s: value #%d already exists",
+ op, mod->sm_desc->ad_cname.bv_val, i );
+ return LDAP_TYPE_OR_VALUE_EXISTS;
+ }
}
- if ( rc != LDAP_SUCCESS ) {
- return rc;
+ if( permissive && !match ) {
+ if( pmod.sm_nvalues ) {
+ pmod.sm_nvalues[p] = mod->sm_nvalues[i];
+ }
+ pmod.sm_values[p++] = mod->sm_values[i];
}
}
+
+ if( permissive && p == 0 ) {
+ /* all new values match exist */
+ ch_free( pmod.sm_values );
+ if( pmod.sm_nvalues ) ch_free( pmod.sm_nvalues );
+ return LDAP_SUCCESS;
+ }
}
/* no - add them */
- if( attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues ) != 0 ) {
+ rc = attr_merge( e, mod->sm_desc, pmod.sm_values, pmod.sm_nvalues );
+
+ if( a != NULL && permissive ) {
+ ch_free( pmod.sm_values );
+ if( pmod.sm_nvalues ) ch_free( pmod.sm_nvalues );
+ }
+
+ if( rc != 0 ) {
/* this should return result of attr_merge */
*text = textbuf;
snprintf( textbuf, textlen,
Modification *mod,
int permissive,
const char **text,
- char *textbuf, size_t textlen
-)
+ char *textbuf, size_t textlen )
{
int i, j, k, rc = LDAP_SUCCESS;
Attribute *a;
*/
/* delete the entire attribute */
- if ( mod->sm_bvalues == NULL ) {
+ if ( mod->sm_values == NULL ) {
rc = attr_delete( &e->e_attrs, mod->sm_desc );
if( permissive ) {
return LDAP_NO_SUCH_ATTRIBUTE;
}
-
for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) {
int found = 0;
for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
{
(void) attr_delete( &e->e_attrs, mod->sm_desc );
- if ( mod->sm_bvalues ) {
+ if ( mod->sm_values ) {
return modify_add_values( e, mod, permissive, text, textbuf, textlen );
}
return LDAP_NO_SUCH_ATTRIBUTE;
}
-
if ( !strcmp( a->a_desc->ad_type->sat_syntax_oid, SLAPD_INTEGER_SYNTAX )) {
int i;
char str[sizeof(long)*3 + 2]; /* overly long */
- long incr = atol( mod->sm_bvalues[0].bv_val );
+ long incr = atol( mod->sm_values[0].bv_val );
/* treat zero and errors as a no-op */
if( incr == 0 ) {
int scope_stored,
int scope_incoming )
{
- struct berval pdn_incoming = { 0, NULL };
+ struct berval pdn_incoming = BER_BVNULL;
if (scope_stored < scope_incoming)
return 0;
op->o_req_ndn = op->o_bd->be_nsuffix[0];
op->ors_scope = LDAP_SCOPE_SUBTREE;
op->ors_deref = LDAP_DEREF_NEVER;
- op->ors_slimit = 0;
- op->ors_tlimit = 0;
+ op->ors_slimit = -1;
+ op->ors_tlimit = -1;
op->ors_filter = &filter;
op->ors_filterstr.bv_val = filter_str;
op->ors_filterstr.bv_len = strlen(filter_str);
mod.sml_op = LDAP_MOD_DELETE;
mod.sml_desc = ad_queryid;
mod.sml_type = ad_queryid->ad_cname;
- mod.sml_bvalues = vals;
+ mod.sml_values = vals;
mod.sml_next = NULL;
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, DETAIL1,
LDAP_SLAPD_F (int) be_isroot LDAP_P(( Operation *op ));
LDAP_SLAPD_F (int) be_isroot_dn LDAP_P(( Backend *be, struct berval *ndn ));
LDAP_SLAPD_F (int) be_isroot_pw LDAP_P(( Operation *op ));
-LDAP_SLAPD_F (int) be_isupdate LDAP_P(( Operation *op ));
+LDAP_SLAPD_F (int) be_sync_update LDAP_P(( Operation *op ));
+LDAP_SLAPD_F (int) be_slurp_update LDAP_P(( Operation *op ));
+#define be_isupdate( op ) be_slurp_update( (op) )
+LDAP_SLAPD_F (int) be_shadow_update LDAP_P(( Operation *op ));
LDAP_SLAPD_F (int) be_isupdate_dn LDAP_P(( Backend *be, struct berval *ndn ));
LDAP_SLAPD_F (struct berval *) be_root_dn LDAP_P(( Backend *be ));
LDAP_SLAPD_F (int) be_entry_get_rw LDAP_P(( struct slap_op *o,
/*
* mods.c
*/
-LDAP_SLAPD_F( int ) modify_check_duplicates(
- AttributeDescription *ad, MatchingRule *mr,
- BerVarray vals, BerVarray mods, int permissive,
- const char **text, char *textbuf, size_t textlen );
LDAP_SLAPD_F( int ) modify_add_values( Entry *e,
Modification *mod,
int permissive,
struct berval *, struct berval * ));
LDAP_SLAPD_F (struct berval *) slap_uuidstr_from_normalized LDAP_P((
struct berval *, struct berval *, void * ));
+LDAP_SLAPD_F (int) syncrepl_isupdate LDAP_P(( Operation * ));
+LDAP_SLAPD_F (int) syncrepl_isupdate_dn LDAP_P(( Backend *, struct berval * ));
/* syntax.c */
LDAP_SLAPD_F (Syntax *) syn_find LDAP_P((
if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
Statslog( LDAP_DEBUG_STATS,
- "conn=%lu op=%lu DISCONNECT tag=%lu err=%d text=%s\n",
- op->o_connid, op->o_opid, rs->sr_tag, rs->sr_err, rs->sr_text ? rs->sr_text : "" );
+ "conn=%lu op=%lu DISCONNECT tag=%lu err=%d text=%s\n",
+ op->o_connid, op->o_opid, rs->sr_tag, rs->sr_err,
+ rs->sr_text ? rs->sr_text : "" );
}
}
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY,
- "send_ldap_result: conn %lu op=%lu p=%d\n",
+ "send_ldap_result: conn=%lu op=%lu p=%d\n",
op->o_connid, op->o_opid, op->o_protocol );
#else
Debug( LDAP_DEBUG_TRACE,
#if SASL_VERSION_MAJOR >= 2
static const char *slap_propnames[] = {
- "*slapConn", "*authcDN", "*authzDN", NULL };
+ "*slapConn", "*slapAuthcDN", "*slapAuthzDN", NULL };
static Filter generic_filter = { LDAP_FILTER_PRESENT };
static struct berval generic_filterstr = BER_BVC("(objectclass=*)");
#define PROP_CONN 0
#define PROP_AUTHC 1
#define PROP_AUTHZ 2
+#define PROP_COUNT 3 /* Number of properties we used */
typedef struct lookup_info {
- int last;
int flags;
const struct propval *list;
sasl_server_params_t *sparams;
if (rs->sr_type != REP_SEARCH) return 0;
- for( i = 0; i < sl->last; i++ ) {
+ for( i = 0; sl->list[i].name; i++ ) {
const char *name = sl->list[i].name;
if ( name[0] == '*' ) {
if ( sl->flags & SASL_AUXPROP_AUTHZID ) continue;
+ /* Skip our private properties */
+ if ( !strcmp( name, slap_propnames[0] )) {
+ i += PROP_COUNT-1;
+ continue;
+ }
name++;
} else if ( !(sl->flags & SASL_AUXPROP_AUTHZID ) )
continue;
sl.flags = flags;
/* Find our DN and conn first */
- for( i = 0, sl.last = 0; sl.list[i].name; i++ ) {
+ for( i = 0; sl.list[i].name; i++ ) {
if ( sl.list[i].name[0] == '*' ) {
if ( !strcmp( sl.list[i].name, slap_propnames[PROP_CONN] ) ) {
if ( sl.list[i].values && sl.list[i].values[0] )
AC_MEMCPY( &conn, sl.list[i].values[0], sizeof( conn ) );
- if ( !sl.last ) sl.last = i;
+ continue;
}
if ( (flags & SASL_AUXPROP_AUTHZID) &&
!strcmp( sl.list[i].name, slap_propnames[PROP_AUTHZ] ) ) {
if ( sl.list[i].values && sl.list[i].values[0] )
AC_MEMCPY( &op.o_req_ndn, sl.list[i].values[0], sizeof( struct berval ) );
- if ( !sl.last ) sl.last = i;
break;
}
if ( !strcmp( sl.list[i].name, slap_propnames[PROP_AUTHC] ) ) {
- if ( !sl.last ) sl.last = i;
if ( sl.list[i].values && sl.list[i].values[0] ) {
AC_MEMCPY( &op.o_req_ndn, sl.list[i].values[0], sizeof( struct berval ) );
if ( !(flags & SASL_AUXPROP_AUTHZID) )
}
/* Now see what else needs to be fetched */
- for( i = 0; i < sl.last; i++ ) {
+ for( i = 0; sl.list[i].name; i++ ) {
const char *name = sl.list[i].name;
if ( name[0] == '*' ) {
if ( flags & SASL_AUXPROP_AUTHZID ) continue;
+ /* Skip our private properties */
+ if ( !strcmp( name, slap_propnames[0] )) {
+ i += PROP_COUNT-1;
+ continue;
+ }
name++;
} else if ( !(flags & SASL_AUXPROP_AUTHZID ) )
continue;
if ( !(flags & SASL_AUXPROP_OVERRIDE) ) continue;
}
doit = 1;
+ break;
}
if (doit) {
int
slap_sasl_setpass( Operation *op, SlapReply *rs )
{
- struct berval id = { 0, NULL }; /* needs to come from connection */
- struct berval new = { 0, NULL };
- struct berval old = { 0, NULL };
+ struct berval id = BER_BVNULL; /* needs to come from connection */
+ struct berval new = BER_BVNULL;
+ struct berval old = BER_BVNULL;
assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, &op->ore_reqoid ) == 0 );
/* Username strings */
if( is_dn == SET_U ) {
char *p;
- struct berval realm = { 0, NULL }, c1 = *dn;
+ struct berval realm = BER_BVNULL, c1 = *dn;
len = dn->bv_len + sizeof("uid=")-1 + sizeof(",cn=auth")-1;
Connection c = *op->o_conn;
char buf[ SLAP_LDAPDN_MAXLEN ];
struct berval id,
- user = { 0, NULL },
- realm = { 0, NULL },
- mech = { 0, NULL };
+ user = BER_BVNULL,
+ realm = BER_BVNULL,
+ mech = BER_BVNULL;
if ( sizeof( buf ) <= uri->bv_len ) {
return LDAP_INVALID_SYNTAX;
op.o_conn = opx->o_conn;
op.o_connid = opx->o_connid;
op.o_req_dn = op.o_req_ndn;
+ op.oq_search.rs_slimit = 1;
+ op.oq_search.rs_tlimit = -1;
op.o_bd->be_search( &op, &rs );
slap_callback cb = { NULL, sasl_sc_sasl2dn, NULL, NULL };
Operation op = {0};
SlapReply rs = {REP_RESULT};
- struct berval regout = { 0, NULL };
+ struct berval regout = BER_BVNULL;
#ifdef NEW_LOGGING
LDAP_LOG( TRANSPORT, ENTRY,
#endif
op.oq_search.rs_deref = LDAP_DEREF_NEVER;
op.oq_search.rs_slimit = 1;
+ op.oq_search.rs_tlimit = -1;
op.oq_search.rs_attrsonly = 1;
op.o_req_dn = op.o_req_ndn;
AttributeDescription *sm_desc;
struct berval sm_type;
BerVarray sm_values;
-#define sm_bvalues sm_values
BerVarray sm_nvalues;
} Modification;
#define sml_op sml_mod.sm_op
#define sml_desc sml_mod.sm_desc
#define sml_type sml_mod.sm_type
-#define sml_bvalues sml_mod.sm_values
#define sml_values sml_mod.sm_values
#define sml_nvalues sml_mod.sm_nvalues
struct slap_mod_list *sml_next;
#define ml_op ml_mod.mod_op
#define ml_type ml_mod.mod_type
#define ml_values ml_mod.mod_values
-#define ml_bvalues ml_mod.mod_values
} LDAPModList;
/*
int lms_s_unchecked;
int lms_s_pr;
int lms_s_pr_hide;
+ int lms_s_pr_total;
};
struct slap_limits {
#define SLAP_DBFLAG_NOLASTMOD 0x0001U
#define SLAP_DBFLAG_NO_SCHEMA_CHECK 0x0002U
#define SLAP_DBFLAG_GLUE_INSTANCE 0x0010U /* a glue backend */
-#define SLAP_DBFLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */
+#define SLAP_DBFLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */
#define SLAP_DBFLAG_GLUE_LINKED 0x0040U /* child is connected to parent */
-#define SLAP_DBFLAG_SHADOW 0x8000U /* a shadow */
+#define SLAP_DBFLAG_SHADOW 0x8000U /* a shadow */
+#define SLAP_DBFLAG_SYNC_SHADOW 0x1000U /* a sync shadow */
+#define SLAP_DBFLAG_SLURP_SHADOW 0x2000U /* a slurp shadow */
slap_mask_t be_flags;
#define SLAP_DBFLAGS(be) ((be)->be_flags)
#define SLAP_NOLASTMOD(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_NOLASTMOD)
#define SLAP_GLUE_LINKED(be) \
(SLAP_DBFLAGS(be) & SLAP_DBFLAG_GLUE_LINKED)
#define SLAP_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SHADOW)
+#define SLAP_SYNC_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SYNC_SHADOW)
+#define SLAP_SLURP_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SLURP_SHADOW)
slap_mask_t be_restrictops; /* restriction operations */
#define SLAP_RESTRICT_OP_ADD 0x0001U
Backend *ps_be;
PagedResultsCookie ps_cookie;
ID ps_id;
+ int ps_count;
} PagedResultsState;
#define LDAP_PSEARCH_BY_ADD 0x01
char *ldn,
LDAPMod **mods )
{
- struct berval dn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
Entry *pEntry=NULL;
LDAPMod *pMod;
struct berval *bv;
* being passed in may not have been allocated on the
* heap.
*/
- rc = bvptr2obj_copy( pMod->mod_bvalues, &bv );
+ rc = bvptr2obj_copy( pMod->mod_values, &bv );
if ( rc != LDAP_SUCCESS ) goto cleanup;
tmp.sml_type.bv_val = pMod->mod_type;
tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
+ tmp.sml_values = bv;
tmp.sml_nvalues = NULL;
mod = (Modifications *) ch_malloc( sizeof(Modifications) );
mod->sml_next = NULL;
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
+ mod->sml_values = tmp.sml_values;
mod->sml_nvalues = tmp.sml_nvalues;
*modtail = mod;
if ( rc != LDAP_SUCCESS ) goto cleanup;
tmp.sml_type.bv_val = pMod->mod_type;
tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
+ tmp.sml_values = bv;
tmp.sml_nvalues = NULL;
mod = (Modifications *) ch_malloc( sizeof(Modifications) );
mod->sml_next = NULL;
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
+ mod->sml_values = tmp.sml_values;
mod->sml_nvalues = tmp.sml_nvalues;
*modtail = mod;
Slapi_PBlock *pPB = NULL;
Slapi_PBlock *pSavePB = NULL;
SlapReply rs = { REP_RESULT };
- struct berval dn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
int manageDsaIt = 0;
int isCritical;
int log_change )
{
#ifdef LDAP_SLAPI
- struct berval dn = { 0, NULL };
- struct berval newrdn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
+ struct berval newrdn = BER_BVNULL;
Connection *pConn = NULL;
Operation *op = NULL;
Slapi_PBlock *pPB = NULL;
Slapi_PBlock *pPB = NULL;
Slapi_PBlock *pSavePB = NULL;
- struct berval dn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
int manageDsaIt = 0;
int isCritical;
* convert an array of pointers to bervals
* to an array of bervals
*/
- rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv );
+ rs.sr_err = bvptr2obj_copy( pMod->mod_values, &bv );
if ( rs.sr_err != LDAP_SUCCESS )
goto cleanup;
tmp.sml_type.bv_val = pMod->mod_type;
tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
+ tmp.sml_values = bv;
tmp.sml_nvalues = NULL;
mod = (Modifications *)ch_malloc( sizeof(Modifications) );
mod->sml_next = NULL;
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
+ mod->sml_values = tmp.sml_values;
mod->sml_nvalues = tmp.sml_nvalues;
} else {
rs.sr_err = values2obj_copy( pMod->mod_values, &bv );
goto cleanup;
tmp.sml_type.bv_val = pMod->mod_type;
tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
+ tmp.sml_values = bv;
tmp.sml_nvalues = NULL;
mod = (Modifications *) ch_malloc( sizeof(Modifications) );
mod->sml_next = NULL;
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
+ mod->sml_values = tmp.sml_values;
mod->sml_nvalues = tmp.sml_nvalues;
}
*modtail = mod;
switch( pMod->mod_op & LDAP_MOD_OP ) {
case LDAP_MOD_ADD:
- if ( mod->sml_bvalues == NULL ) {
+ if ( mod->sml_values == NULL ) {
rs.sr_err = LDAP_PROTOCOL_ERROR;
goto cleanup;
}
Operation *op = NULL;
Slapi_PBlock *ptr = NULL;
Slapi_PBlock *pSavePB = NULL;
- struct berval dn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
Filter *filter=NULL;
- struct berval fstr = { 0, NULL };
+ struct berval fstr = BER_BVNULL;
AttributeName *an = NULL;
const char *text = NULL;
char *ldn )
{
#ifdef LDAP_SLAPI
- struct berval dn = { 0, NULL };
+ struct berval dn = BER_BVNULL;
dn.bv_val = ldn;
dn.bv_len = strlen( ldn );
if ( vals == NULL ) {
/* Apparently vals can be NULL
- * FIXME: sm_bvalues = NULL ? */
- mod.sm_bvalues = (BerVarray)ch_malloc( sizeof(struct berval) );
- mod.sm_bvalues->bv_val = NULL;
+ * FIXME: sm_values = NULL ? */
+ mod.sm_values = (BerVarray)ch_malloc( sizeof(struct berval) );
+ mod.sm_values->bv_val = NULL;
} else {
- rc = bvptr2obj( vals, &mod.sm_bvalues );
+ rc = bvptr2obj( vals, &mod.sm_values );
if ( rc != LDAP_SUCCESS ) {
return LDAP_CONSTRAINT_VIOLATION;
}
rc = modify_add_values( e, &mod, 0, &text, textbuf, sizeof(textbuf) );
- ch_free( mod.sm_bvalues );
+ ch_free( mod.sm_values );
return (rc == LDAP_SUCCESS) ? LDAP_SUCCESS : LDAP_CONSTRAINT_VIOLATION;
#else
return attr_delete( &e->e_attrs, mod.sm_desc ) ? LDAP_OTHER : LDAP_SUCCESS;
}
- rc = bvptr2obj( vals, &mod.sm_bvalues );
+ rc = bvptr2obj( vals, &mod.sm_values );
if ( rc != LDAP_SUCCESS ) {
return LDAP_CONSTRAINT_VIOLATION;
}
rc = modify_delete_values( e, &mod, 0, &text, textbuf, sizeof(textbuf) );
- ch_free( mod.sm_bvalues );
+ ch_free( mod.sm_values );
return rc;
#else
mp = ml->sml_next;
/* just free the containing array */
- slapi_ch_free( (void **)&ml->sml_bvalues );
+ slapi_ch_free( (void **)&ml->sml_values );
slapi_ch_free( (void **)&ml );
}
modp->mod_type = ml->sml_type.bv_val;
ml->sml_type.bv_val = NULL;
- if ( ml->sml_bvalues != NULL ) {
- for( j = 0; ml->sml_bvalues[j].bv_val != NULL; j++ )
+ if ( ml->sml_values != NULL ) {
+ for( j = 0; ml->sml_values[j].bv_val != NULL; j++ )
;
modp->mod_bvalues = (struct berval **)ch_malloc( (j + 1) *
sizeof(struct berval *) );
- for( j = 0; ml->sml_bvalues[j].bv_val != NULL; j++ ) {
+ for( j = 0; ml->sml_values[j].bv_val != NULL; j++ ) {
/* Take ownership of original values. */
modp->mod_bvalues[j] = (struct berval *)ch_malloc( sizeof(struct berval) );
- modp->mod_bvalues[j]->bv_len = ml->sml_bvalues[j].bv_len;
- modp->mod_bvalues[j]->bv_val = ml->sml_bvalues[j].bv_val;
- ml->sml_bvalues[j].bv_len = 0;
- ml->sml_bvalues[j].bv_val = NULL;
+ modp->mod_bvalues[j]->bv_len = ml->sml_values[j].bv_len;
+ modp->mod_bvalues[j]->bv_val = ml->sml_values[j].bv_val;
+ ml->sml_values[j].bv_len = 0;
+ ml->sml_values[j].bv_val = NULL;
}
modp->mod_bvalues[j] = NULL;
} else {
}
if ( i == 0 ) {
- mod->sml_bvalues = NULL;
+ mod->sml_values = NULL;
} else {
- mod->sml_bvalues = (BerVarray) ch_malloc( (i + 1) * sizeof(struct berval) );
+ mod->sml_values = (BerVarray) ch_malloc( (i + 1) * sizeof(struct berval) );
/* NB: This implicitly trusts a plugin to return valid modifications. */
if ( (*modp)->mod_op & LDAP_MOD_BVALUES ) {
for( i = 0, bvp = (*modp)->mod_bvalues; bvp != NULL && *bvp != NULL; bvp++, i++ ) {
- mod->sml_bvalues[i].bv_val = (*bvp)->bv_val;
- mod->sml_bvalues[i].bv_len = (*bvp)->bv_len;
+ mod->sml_values[i].bv_val = (*bvp)->bv_val;
+ mod->sml_values[i].bv_len = (*bvp)->bv_len;
}
} else {
for( i = 0, p = (*modp)->mod_values; p != NULL && *p != NULL; p++, i++ ) {
- mod->sml_bvalues[i].bv_val = *p;
- mod->sml_bvalues[i].bv_len = strlen( *p );
+ mod->sml_values[i].bv_val = *p;
+ mod->sml_values[i].bv_len = strlen( *p );
}
}
- mod->sml_bvalues[i].bv_val = NULL;
- mod->sml_bvalues[i].bv_len = 0;
+ mod->sml_values[i].bv_val = NULL;
+ mod->sml_values[i].bv_len = 0;
}
mod->sml_nvalues = NULL;
* Modification list. Do free the containing array.
*/
if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
- for ( j = 0; mods[i]->mod_bvalues != NULL && mods[i]->mod_bvalues[j] != NULL; j++ ) {
- ch_free( mods[i]->mod_bvalues[j] );
+ for ( j = 0; mods[i]->mod_values != NULL && mods[i]->mod_values[j] != NULL; j++ ) {
+ ch_free( mods[i]->mod_values[j] );
}
- ch_free( mods[i]->mod_bvalues );
+ ch_free( mods[i]->mod_values );
} else {
ch_free( mods[i]->mod_values );
}
sc = NULL;
} else {
/* stored cookie */
- struct berval newcookie = { 0, NULL };
+ struct berval newcookie = BER_BVNULL;
ber_dupbv( &cookie_bv, &cookie[0] );
ber_bvarray_add( &si->si_syncCookie.octet_str, &cookie_bv );
slap_parse_sync_cookie( &si->si_syncCookie );
Entry *entry = NULL;
int syncstate;
- struct berval syncUUID = { 0, NULL };
+ struct berval syncUUID = BER_BVNULL;
struct sync_cookie syncCookie = { NULL, -1, NULL };
struct sync_cookie syncCookie_req = { NULL, -1, NULL };
- struct berval cookie = { 0, NULL };
+ struct berval cookie = BER_BVNULL;
int rc, err, i;
ber_len_t len;
mod->sml_next = NULL;
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
+ mod->sml_values = tmp.sml_values;
mod->sml_nvalues = NULL;
*modtail = mod;
Backend *be = op->o_bd;
slap_callback cb = { NULL };
struct berval *syncuuid_bv = NULL;
- struct berval syncUUID_strrep = { 0, NULL };
- struct berval uuid_bv = { 0, NULL };
+ struct berval syncUUID_strrep = BER_BVNULL;
+ struct berval uuid_bv = BER_BVNULL;
SlapReply rs = {REP_RESULT};
Filter f = {0};
int ret = LDAP_SUCCESS;
const char *text;
- struct berval pdn = { 0, NULL };
- struct berval org_req_dn = { 0, NULL };
- struct berval org_req_ndn = { 0, NULL };
- struct berval org_dn = { 0, NULL };
- struct berval org_ndn = { 0, NULL };
+ struct berval pdn = BER_BVNULL;
+ struct berval org_req_dn = BER_BVNULL;
+ struct berval org_req_ndn = BER_BVNULL;
+ struct berval org_dn = BER_BVNULL;
+ struct berval org_ndn = BER_BVNULL;
int org_managedsait;
if (( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD ))
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_desc = slap_schema.si_ad_entryUUID;
mod->sml_type = mod->sml_desc->ad_cname;
- ber_bvarray_add( &mod->sml_bvalues, &uuid_bv );
+ ber_bvarray_add( &mod->sml_values, &uuid_bv );
modtail->sml_next = mod;
op->o_tag = LDAP_REQ_MODIFY;
Modifications **modtail = &modlist;
Attribute *attr;
- struct berval pdn = { 0, NULL };
- struct berval org_req_dn = { 0, NULL };
- struct berval org_req_ndn = { 0, NULL };
- struct berval org_dn = { 0, NULL };
- struct berval org_ndn = { 0, NULL };
+ struct berval pdn = BER_BVNULL;
+ struct berval org_req_dn = BER_BVNULL;
+ struct berval org_req_ndn = BER_BVNULL;
+ struct berval org_dn = BER_BVNULL;
+ struct berval org_ndn = BER_BVNULL;
int org_managedsait;
op->o_req_dn = si->si_base;
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_desc = slap_schema.si_ad_objectClass;
mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_bvalues = &gcbva[0];
+ mod->sml_values = &gcbva[0];
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_bvalues = &gcbva[1];
+ mod->sml_values = &gcbva[1];
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_desc = slap_schema.si_ad_objectClass;
mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_bvalues = ocbva;
+ mod->sml_values = ocbva;
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_desc = slap_schema.si_ad_cn;
mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_bvalues = cnbva;
+ mod->sml_values = cnbva;
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_desc = slap_schema.si_ad_syncreplCookie;
mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_bvalues = scbva;
+ mod->sml_values = scbva;
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_desc = slap_schema.si_ad_subtreeSpecification;
mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_bvalues = ssbva;
+ mod->sml_values = ssbva;
*modtail = mod;
modtail = &mod->sml_next;
return;
}
+int
+syncrepl_isupdate( Operation *op )
+{
+ return ( syncrepl_isupdate_dn( op->o_bd, &op->o_ndn ));
+}
+
+int
+syncrepl_isupdate_dn(
+ Backend* be,
+ struct berval* ndn
+)
+{
+ syncinfo_t* si;
+ int ret = 0;
+
+ if ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
+ LDAP_STAILQ_FOREACH( si, &be->be_syncinfo, si_next ) {
+ if ( ret = dn_match( &si->si_updatedn, ndn )) {
+ return ret;
+ }
+ }
+ }
+ return 0;
+}
+
static int
dn_callback(
Operation* op,
}
ch_free ( (char *) bv );
}
-