]> git.sur5r.net Git - openldap/commitdiff
Add glue for root DB (ITS#3063)
authorHoward Chu <hyc@openldap.org>
Sat, 12 Jun 2004 04:31:17 +0000 (04:31 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 12 Jun 2004 04:31:17 +0000 (04:31 +0000)
servers/slapd/back-bdb/add.c

index 476043febe5cdc61f20072f005d60cef05e7b810..1b074f57451c7b1311ac41ef0a9f676f4b64e6b8 100644 (file)
@@ -380,6 +380,38 @@ retry:     /* transaction retry */
                goto return_results;
        }
 
+       /* This is the first add to a root DB, need to make the suffix glue */
+       if ( pdn.bv_len == 0 && ei->bei_id == 0 ) {
+               Entry e_root = {0};
+               e_root.e_name.bv_val = "";
+               e_root.e_nname.bv_val = "";
+               e_root.e_id = 1;
+               rs->sr_err = bdb_dn2id_add( op, lt2, ei, &e_root );
+
+               /* Just give up on any failure. */
+               if ( rs->sr_err ) {
+                       rs->sr_err = LDAP_OTHER;
+                       goto return_results;
+               }
+
+               /* Get a new ID for the actual entry */
+               if ( op->oq_add.rs_e->e_id == 1 ) {
+                       rs->sr_err = bdb_next_id( op->o_bd, NULL, &op->oq_add.rs_e->e_id );
+                       if (rs->sr_err) {
+                               rs->sr_err = LDAP_OTHER;
+                               goto return_results;
+                       }
+               }
+
+               /* Get new EntryInfo */
+               rs->sr_err = bdb_dn2entry( op, ltid, &op->ora_e->e_nname, &ei,
+               1, locker, &lock );
+               if (rs->sr_err != DB_NOTFOUND) {
+                       rs->sr_err = LDAP_OTHER;
+                       goto return_results;
+               }
+       }
+
        /* dn2id index */
        rs->sr_err = bdb_dn2id_add( op, lt2, ei, op->oq_add.rs_e );
        if ( rs->sr_err != 0 ) {