]> git.sur5r.net Git - openldap/commitdiff
ITS#3616 use fake context entry if suffix is empty.
authorHoward Chu <hyc@openldap.org>
Sat, 9 Apr 2005 10:01:13 +0000 (10:01 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 9 Apr 2005 10:01:13 +0000 (10:01 +0000)
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/tools.c

index dd7a661577e65c0abba64cc6c1327f817792f387..1f2f7a3b5ab3caf6bd5e06fc05859273f89e5dcc 100644 (file)
@@ -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 );
index 14f587f0fe1cbf25c1b2aae116816134639c7e4f..c16b8faf7109e8e1193b6b045ef7d27f554c5324 100644 (file)
@@ -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;
index 530b0f3dee32771cd8e0fd15736a40b299ab81e0..c82ba7317836722f8d2ea4fcf1906246fc421836 100644 (file)
@@ -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 ) {