From b9e3f66c7c79f224587f4ad5561f29ba739050a1 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 12 Jun 2004 04:31:17 +0000 Subject: [PATCH] Add glue for root DB (ITS#3063) --- servers/slapd/back-bdb/add.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 476043febe..1b074f5745 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -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 ) { -- 2.39.5