From: Howard Chu Date: Sat, 9 Apr 2005 10:01:13 +0000 (+0000) Subject: ITS#3616 use fake context entry if suffix is empty. X-Git-Tag: OPENLDAP_AC_BP~949 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=90d97910474361a87571712e4dca235f90aa05c5;p=openldap ITS#3616 use fake context entry if suffix is empty. --- diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index dd7a661577..1f2f7a3b5a 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -316,6 +316,11 @@ bdb_cache_find_ndn( if ( !ei2 ) { int len = ei.bei_nrdn.bv_len; + if ( BER_BVISEMPTY( ndn )) { + *res = eip; + return LDAP_SUCCESS; + } + ei.bei_nrdn.bv_len = ndn->bv_len - (ei.bei_nrdn.bv_val - ndn->bv_val); bdb_cache_entryinfo_unlock( eip ); diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 14f587f0fe..c16b8faf71 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -418,6 +418,9 @@ int hdb_fix_dn( char *ptr, *nptr; int max = 0; + if ( !e->e_id ) + return 0; + /* count length of all DN components */ for ( ei = BEI(e); ei && ei->bei_id; ei=ei->bei_parent ) { rlen += ei->bei_rdn.bv_len + 1; diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 530b0f3dee..c82ba73178 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -142,6 +142,9 @@ ID bdb_tool_dn2id_get( Opheader ohdr = {0}; EntryInfo ei = {0}; + if ( BER_BVISEMPTY(dn) ) + return 0; + op.o_hdr = &ohdr; op.o_bd = be; op.o_tmpmemctx = NULL; @@ -154,13 +157,31 @@ ID bdb_tool_dn2id_get( return ei.bei_id; } +static struct berval ocbva[] = { + BER_BVC("locality"), + BER_BVC("syncProviderSubentry"), + BER_BVNULL +}; + int bdb_tool_id2entry_get( Backend *be, ID id, Entry **e ) { - return bdb_id2entry( be, NULL, id, e ); + int rc = bdb_id2entry( be, NULL, id, e ); + + if ( rc == DB_NOTFOUND && id == 0 ) { + Entry *dummy = ch_calloc( 1, sizeof(Entry) ); + dummy->e_name.bv_val = ch_strdup( "" ); + dummy->e_nname.bv_val = ch_strdup( "" ); + attr_merge( dummy, slap_schema.si_ad_objectClass, ocbva, NULL ); + attr_merge_one( dummy, slap_schema.si_ad_structuralObjectClass, + &ocbva[0], NULL ); + *e = dummy; + rc = LDAP_SUCCESS; + } + return rc; } Entry* bdb_tool_entry_get( BackendDB *be, ID id ) @@ -510,7 +531,6 @@ ID bdb_tool_entry_modify( assert( text->bv_val[0] == '\0' ); /* overconservative? */ assert ( e->e_id != NOID ); - assert ( e->e_id != 0 ); Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_tool_entry_modify) "( %ld, \"%s\" )\n", @@ -547,6 +567,10 @@ ID bdb_tool_entry_modify( goto done; } +#if 0 + /* FIXME: this is bogus, we don't have the old values to delete + * from the index because the given entry has already been modified. + */ rc = bdb_index_entry_del( &op, tid, e ); if( rc != 0 ) { snprintf( text->bv_val, text->bv_len, @@ -557,6 +581,7 @@ ID bdb_tool_entry_modify( text->bv_val, 0, 0 ); goto done; } +#endif rc = bdb_index_entry_add( &op, tid, e ); if( rc != 0 ) {