From cc27e754a9c77ff58c7bc01386091ad51a79e9c1 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 21 Dec 2005 00:00:11 +0000 Subject: [PATCH] Changes from HEAD suggested by Howard (1st round, less tests) --- doc/guide/admin/slapdconf2.sdf | 10 +++++++--- doc/guide/admin/slapdconfig.sdf | 10 +++++++--- doc/man/man5/slapd.conf.5 | 18 ++++++++++-------- servers/slapd/alock.c | 3 +++ servers/slapd/back-bdb/cache.c | 13 +++++++------ servers/slapd/back-bdb/dn2id.c | 2 +- servers/slapd/back-bdb/idl.c | 19 ++++++++++++++++++- servers/slapd/backglue.c | 5 +++++ servers/slapd/overlays/syncprov.c | 26 +++++++++++++++++--------- servers/slapd/overlays/unique.c | 28 +++++++++++++++++++++------- 10 files changed, 96 insertions(+), 38 deletions(-) diff --git a/doc/guide/admin/slapdconf2.sdf b/doc/guide/admin/slapdconf2.sdf index 4db17e6d77..18e143138b 100644 --- a/doc/guide/admin/slapdconf2.sdf +++ b/doc/guide/admin/slapdconf2.sdf @@ -664,9 +664,13 @@ send search requests to the provider slapd according to the search specification. The search specification includes {{EX:searchbase}}, {{EX:scope}}, {{EX:filter}}, {{EX:attrs}}, {{EX:attrsonly}}, {{EX:sizelimit}}, and {{EX:timelimit}} parameters as in the normal -search specification. The syncrepl search specification has -the same value syntax and the same default values as in the -{{ldapsearch}}(1) client search tool. +search specification. The {{EX:searchbase}} parameter has no +default value and must always be specified. The {{EX:scope}} defaults +to {{EX:sub}}, the {{EX:filter}} defaults to {{EX:(objectclass=*)}}, +{{EX:attrs}} defaults to {{EX:"*,+"}} to replicate all user and operational +attributes, and {{EX:attrsonly}} is unset by default. Both {{EX:sizelimit}} +and {{EX:timelimit}} default to "unlimited", and only positive integers +or "unlimited" may be specified. The LDAP Content Synchronization protocol has two operation types: {{EX:refreshOnly}} and {{EX:refreshAndPersist}}. diff --git a/doc/guide/admin/slapdconfig.sdf b/doc/guide/admin/slapdconfig.sdf index e13bbd1507..cee2e38699 100644 --- a/doc/guide/admin/slapdconfig.sdf +++ b/doc/guide/admin/slapdconfig.sdf @@ -468,9 +468,13 @@ send search requests to the provider slapd according to the search specification. The search specification includes {{EX:searchbase}}, {{EX:scope}}, {{EX:filter}}, {{EX:attrs}}, {{EX:attrsonly}}, {{EX:sizelimit}}, and {{EX:timelimit}} parameters as in the normal -search specification. The syncrepl search specification has -the same value syntax and the same default values as in the -{{ldapsearch}}(1) client search tool. +search specification. The {{EX:searchbase}} parameter has no +default value and must always be specified. The {{EX:scope}} defaults +to {{EX:sub}}, the {{EX:filter}} defaults to {{EX:(objectclass=*)}}, +{{EX:attrs}} defaults to {{EX:"*,+"}} to replicate all user and operational +attributes, and {{EX:attrsonly}} is unset by default. Both {{EX:sizelimit}} +and {{EX:timelimit}} default to "unlimited", and only integers +or "unlimited" may be specified. The LDAP Content Synchronization protocol has two operation types: {{EX:refreshOnly}} and {{EX:refreshAndPersist}}. diff --git a/doc/man/man5/slapd.conf.5 b/doc/man/man5/slapd.conf.5 index a552f4db8c..bb8a363c11 100644 --- a/doc/man/man5/slapd.conf.5 +++ b/doc/man/man5/slapd.conf.5 @@ -411,10 +411,10 @@ disables acceptance of anonymous bind requests. .B bind_simple disables simple (bind) authentication. .B tls_2_anon -disables Start TLS from forcing session to anonymous status (see also -.BR tls_authc ). +disables forcing session to anonymous status (see also +.BR tls_authc ) upon StartTLS operation receipt. .B tls_authc -disables StartTLS if authenticated (see also +dissallow the StartTLS operation if authenticated (see also .BR tls_2_anon ). .HP .hy 0 @@ -1546,11 +1546,13 @@ according to the search specification. The search specification includes .B searchbase, scope, filter, attrs, attrsonly, sizelimit, and .B timelimit -parameters as in the normal search specification. -The search specification for the LDAP Content Synchronization operation -has the same value syntax and the same default values as in the -.BR ldapsearch (1) -client search tool. +parameters as in the normal search specification. +The \fBscope\fP defaults to \fBsub\fP, the \fBfilter\fP defaults to +\fB(objectclass=*)\fP, and there is no default \fBsearchbase\fP. The +\fBattrs\fP list defaults to \fB"*,+"\fP to return all user and operational +attributes, and \fBattrsonly\fP is unset by default. +The \fBsizelimit\fP and \fBtimelimit\fP only +accept "unlimited" and positive integers, and both default to "unlimited". The LDAP Content Synchronization protocol has two operation types. In the .B refreshOnly diff --git a/servers/slapd/alock.c b/servers/slapd/alock.c index fc9e5290cb..ff6742144e 100644 --- a/servers/slapd/alock.c +++ b/servers/slapd/alock.c @@ -504,6 +504,9 @@ alock_close ( alock_info_t * info ) alock_slot_t slot_data; int res; + if ( !info->al_slot ) + return ALOCK_CLEAN; + (void) memset ((void *) &slot_data, 0, sizeof(alock_slot_t)); res = alock_grab_lock (info->al_fd, 0); diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 8e39d952df..92711b243b 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -438,12 +438,6 @@ hdb_cache_find_parent( addlru = 0; } - if ( addlru ) { - ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex ); - LRU_ADD( &bdb->bi_cache, ein ); - ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.lru_mutex ); - } - addlru = 1; /* If this is the first time, save this node * to be returned later. @@ -465,6 +459,13 @@ hdb_cache_find_parent( bdb->bi_cache.c_leaves++; ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); + if ( addlru ) { + ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex ); + LRU_ADD( &bdb->bi_cache, ein ); + ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.lru_mutex ); + } + addlru = 1; + /* Got the parent, link in and we're done. */ if ( ei2 ) { bdb_cache_entryinfo_lock( ei2 ); diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 185c73491b..05e482e1e3 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -178,7 +178,7 @@ bdb_dn2id_delete( #endif { buf[0] = DN_SUBTREE_PREFIX; - rc = db->del( db, txn, &key, 0 ); + rc = bdb_idl_delete_key( op->o_bd, db, txn, &key, e->e_id ); if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n", diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index e034fb2ff8..321e02e232 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -226,7 +226,7 @@ int bdb_idl_insert( ID *ids, ID id ) static int bdb_idl_delete( ID *ids, ID id ) { - unsigned x = bdb_idl_search( ids, id ); + unsigned x; #if IDL_DEBUG > 1 Debug( LDAP_DEBUG_ANY, "delete: %04lx at %d\n", (long) id, x, 0 ); @@ -235,6 +235,23 @@ static int bdb_idl_delete( ID *ids, ID id ) idl_check( ids ); #endif + if (BDB_IDL_IS_RANGE( ids )) { + /* If deleting a range boundary, adjust */ + if ( ids[1] == id ) + ids[1]++; + else if ( ids[2] == id ) + ids[2]--; + /* deleting from inside a range is a no-op */ + + /* If the range has collapsed, re-adjust */ + if ( ids[1] > ids[2] ) + ids[0] = 0; + else if ( ids[1] == ids[2] ) + ids[1] = 1; + return 0; + } + + x = bdb_idl_search( ids, id ); assert( x > 0 ); if( x <= 0 ) { diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index ec2f78ac17..1031e7e232 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -321,6 +321,9 @@ glue_op_search ( Operation *op, SlapReply *rs ) op->o_req_dn = op->o_bd->be_suffix[0]; op->o_req_ndn = op->o_bd->be_nsuffix[0]; rs->sr_err = op->o_bd->be_search(op, rs); + if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) { + gs.err = LDAP_SUCCESS; + } } else if (scope0 == LDAP_SCOPE_SUBTREE && dn_match(&op->o_bd->be_nsuffix[0], &ndn)) @@ -336,6 +339,8 @@ glue_op_search ( Operation *op, SlapReply *rs ) if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) { gs.err = LDAP_SUCCESS; } + op->o_req_dn = dn; + op->o_req_ndn = ndn; } else if (dnIsSuffix(&ndn, &op->o_bd->be_nsuffix[0])) { rs->sr_err = op->o_bd->be_search( op, rs ); diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index a62d0a0d0d..e15305542c 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -1800,6 +1800,9 @@ syncprov_search_response( Operation *op, SlapReply *rs ) return SLAP_CB_CONTINUE; } a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryCSN ); + if ( a == NULL && rs->sr_operational_attrs != NULL ) { + a = attr_find( rs->sr_operational_attrs, slap_schema.si_ad_entryCSN ); + } if ( a ) { /* Make sure entry is less than the snaphot'd contextCSN */ if ( ber_bvcmp( &a->a_nvals[0], &ss->ss_ctxcsn ) > 0 ) @@ -2276,8 +2279,8 @@ syncprov_db_open( slap_overinst *on = (slap_overinst *) be->bd_info; syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; - Connection conn; - OperationBuffer opbuf; + Connection conn = { 0 }; + OperationBuffer opbuf = { 0 }; char ctxcsnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; Operation *op = (Operation *) &opbuf; Entry *e; @@ -2320,12 +2323,14 @@ syncprov_db_open( strcpy( ctxcsnbuf, si->si_ctxcsnbuf ); } be_entry_release_rw( op, e, 0 ); - op->o_bd->bd_info = (BackendInfo *)on; - op->o_req_dn = be->be_suffix[0]; - op->o_req_ndn = be->be_nsuffix[0]; - op->ors_scope = LDAP_SCOPE_SUBTREE; - ldap_pvt_thread_create( &tid, 0, syncprov_db_otask, op ); - ldap_pvt_thread_join( tid, NULL ); + if ( !BER_BVISEMPTY( &si->si_ctxcsn ) ) { + op->o_bd->bd_info = (BackendInfo *)on; + op->o_req_dn = be->be_suffix[0]; + op->o_req_ndn = be->be_nsuffix[0]; + op->ors_scope = LDAP_SCOPE_SUBTREE; + ldap_pvt_thread_create( &tid, 0, syncprov_db_otask, op ); + ldap_pvt_thread_join( tid, NULL ); + } } else if ( SLAP_SYNC_SHADOW( op->o_bd )) { /* If we're also a consumer, and we didn't find the context entry, * then don't generate anything, wait for our provider to send it @@ -2419,6 +2424,9 @@ syncprov_db_destroy( syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; if ( si ) { + if ( si->si_logs ) { + ch_free( si->si_logs ); + } ldap_pvt_thread_mutex_destroy( &si->si_mods_mutex ); ldap_pvt_thread_mutex_destroy( &si->si_ops_mutex ); ldap_pvt_thread_mutex_destroy( &si->si_csn_mutex ); @@ -2542,7 +2550,7 @@ syncprov_initialize() int rc; rc = register_supported_control( LDAP_CONTROL_SYNC, - SLAP_CTRL_HIDE|SLAP_CTRL_SEARCH, NULL, + SLAP_CTRL_SEARCH, NULL, syncprov_parseCtrl, &slap_cids.sc_LDAPsync ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, diff --git a/servers/slapd/overlays/unique.c b/servers/slapd/overlays/unique.c index 5802b4a9d1..c675473750 100644 --- a/servers/slapd/overlays/unique.c +++ b/servers/slapd/overlays/unique.c @@ -384,7 +384,7 @@ static int unique_search( nop->o_bd = on->on_info->oi_origdb; rc = nop->o_bd->be_search(nop, &nrs); filter_free_x(nop, nop->ors_filter); - ch_free( key ); + op->o_tmpfree( key, op->o_tmpmemctx ); if(rc != LDAP_SUCCESS && rc != LDAP_NO_SUCH_OBJECT) { op->o_bd->bd_info = (BackendInfo *) on->on_info; @@ -404,6 +404,8 @@ static int unique_search( return(SLAP_CB_CONTINUE); } +#define ALLOC_EXTRA 16 /* extra slop */ + static int unique_add( Operation *op, SlapReply *rs @@ -415,7 +417,7 @@ static int unique_add( Attribute *a; char *key, *kp; - int ks = 16; + int ks = 0; Debug(LDAP_DEBUG_TRACE, "==> unique_add <%s>\n", op->o_req_dn.bv_val, 0, 0); @@ -438,7 +440,11 @@ static int unique_add( ks = count_filter_len(ud, a->a_desc, a->a_vals, ks); } - key = ch_malloc(ks); + if ( !ks ) + return SLAP_CB_CONTINUE; + + ks += ALLOC_EXTRA; + key = op->o_tmpalloc(ks, op->o_tmpmemctx); kp = key + sprintf(key, "(|"); @@ -465,7 +471,7 @@ static int unique_modify( Modifications *m; char *key, *kp; - int ks = 16; /* a handful of extra bytes */ + int ks = 0; Debug(LDAP_DEBUG_TRACE, "==> unique_modify <%s>\n", op->o_req_dn.bv_val, 0, 0); @@ -489,7 +495,11 @@ static int unique_modify( ks = count_filter_len(ud, m->sml_desc, m->sml_values, ks); } - key = ch_malloc(ks); + if ( !ks ) + return SLAP_CB_CONTINUE; + + ks += ALLOC_EXTRA; + key = op->o_tmpalloc(ks, op->o_tmpmemctx); kp = key + sprintf(key, "(|"); @@ -516,7 +526,7 @@ static int unique_modrdn( Operation nop = *op; char *key, *kp; - int i, ks = 16; /* a handful of extra bytes */ + int i, ks = 0; LDAPRDN newrdn; struct berval bv[2]; @@ -553,7 +563,11 @@ static int unique_modrdn( ks = count_filter_len(ud, newrdn[i]->la_private, bv, ks); } - key = ch_malloc(ks); + if ( !ks ) + return SLAP_CB_CONTINUE; + + ks += ALLOC_EXTRA; + key = op->o_tmpalloc(ks, op->o_tmpmemctx); kp = key + sprintf(key, "(|"); for(i = 0; newrdn[i]; i++) { -- 2.39.5