|
|
dc8c34 |
From 3088c7e0776754c2d750d2871c77338eb9590fb7 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
dc8c34 |
Date: Thu, 26 Sep 2013 09:18:11 -0700
|
|
|
dc8c34 |
Subject: [PATCH 103/104] Ticket #47523 - Set up replcation/agreement before
|
|
|
dc8c34 |
initializing the sub suffix, the sub suffix is not found by ldapsearch
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Bug description: If a replication is configured against a backend
|
|
|
dc8c34 |
before initializing the backend with a suffix entry, an RUV entry
|
|
|
dc8c34 |
is inserted first with the entryid 1. The RUV entry's entryrdn is
|
|
|
dc8c34 |
added to the entryrdn index with a suffix entry which is a parent
|
|
|
dc8c34 |
entry of the RUV entry having a temporary entryid 0, which was to
|
|
|
dc8c34 |
be replaced with the real entryid when the real suffix entry is
|
|
|
dc8c34 |
added. But the replacement code was not executed.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Fix description: When a real suffix is added to the entryrdn index,
|
|
|
dc8c34 |
it returns DB_KEYEXIST, which used to be ignored by resetting 0
|
|
|
dc8c34 |
(== SUCCESS). This patch returns DB_KEYEXIST to the caller and let
|
|
|
dc8c34 |
_entryrdn_insert_key use the info to replace the temporary entryid
|
|
|
dc8c34 |
with the real one. The error code is ignored by the other callers.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/47523
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by nkinder (Thanks!).
|
|
|
dc8c34 |
(cherry picked from commit e6eab21920a0374eb356da3d1f041312c6857ecd)
|
|
|
dc8c34 |
(cherry picked from commit 6b35dc7b04da023cc14045cc6dd1f5e304cf265f)
|
|
|
dc8c34 |
(cherry picked from commit df1f0ed301db6404a8df479a051416da6c8b2738)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 39 +++++++++++++++-------------
|
|
|
dc8c34 |
1 file changed, 21 insertions(+), 18 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
|
|
|
dc8c34 |
index 156461b..887f74b 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
|
|
|
dc8c34 |
@@ -747,7 +747,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
dc8c34 |
renamedata.data = (void *)newelem;
|
|
|
dc8c34 |
renamedata.flags = DB_DBT_USERMEM;
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_SELF, db_txn);
|
|
|
dc8c34 |
- if (rc) {
|
|
|
dc8c34 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
dc8c34 |
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
|
|
|
dc8c34 |
"entryrdn_rename_subtree: Adding %s failed; "
|
|
|
dc8c34 |
"%s(%d)\n", keybuf, dblayer_strerror(rc), rc);
|
|
|
dc8c34 |
@@ -768,7 +768,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
dc8c34 |
renamedata.flags = DB_DBT_USERMEM;
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, &key,
|
|
|
dc8c34 |
&renamedata, RDN_INDEX_CHILD, db_txn);
|
|
|
dc8c34 |
- if (rc) {
|
|
|
dc8c34 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -813,7 +813,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
dc8c34 |
renamedata.data = (void *)newsupelem;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_PARENT, db_txn);
|
|
|
dc8c34 |
- if (rc) {
|
|
|
dc8c34 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
dc8c34 |
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
|
|
|
dc8c34 |
"entryrdn_rename_subtree: Adding "
|
|
|
dc8c34 |
"%s failed; %s(%d)\n",
|
|
|
dc8c34 |
@@ -848,7 +848,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
dc8c34 |
renamedata.data = (void *)newelem;
|
|
|
dc8c34 |
renamedata.flags = DB_DBT_USERMEM;
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_SELF, db_txn);
|
|
|
dc8c34 |
- if (rc) {
|
|
|
dc8c34 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
dc8c34 |
slapi_log_error(ENTRYRDN_LOGLEVEL(rc), ENTRYRDN_TAG,
|
|
|
dc8c34 |
"entryrdn_rename_subtree: Adding %s failed; "
|
|
|
dc8c34 |
"%s(%d)\n", keybuf, dblayer_strerror(rc), rc);
|
|
|
dc8c34 |
@@ -901,7 +901,7 @@ entryrdn_rename_subtree(backend *be,
|
|
|
dc8c34 |
renamedata.flags = DB_DBT_USERMEM;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_CHILD, db_txn);
|
|
|
dc8c34 |
- if (rc) {
|
|
|
dc8c34 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -1948,12 +1948,11 @@ _entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type, DB_TXN *db_txn)
|
|
|
dc8c34 |
rc = cursor->c_put(cursor, key, data, DB_NODUPDATA);
|
|
|
dc8c34 |
if (rc) {
|
|
|
dc8c34 |
if (DB_KEYEXIST == rc) {
|
|
|
dc8c34 |
- /* this is okay */
|
|
|
dc8c34 |
+ /* this is okay, but need to return DB_KEYEXIST to caller */
|
|
|
dc8c34 |
slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
|
|
|
dc8c34 |
"_entryrdn_put_data: The same key (%s) and the "
|
|
|
dc8c34 |
"data exists in index\n",
|
|
|
dc8c34 |
(char *)key->data);
|
|
|
dc8c34 |
- rc = 0;
|
|
|
dc8c34 |
break;
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
char *keyword = NULL;
|
|
|
dc8c34 |
@@ -2102,7 +2101,7 @@ _entryrdn_insert_key_elems(backend *be,
|
|
|
dc8c34 |
/* adding RDN to the child key */
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_CHILD, db_txn);
|
|
|
dc8c34 |
keybuf = key->data;
|
|
|
dc8c34 |
- if (rc) { /* failed */
|
|
|
dc8c34 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
@@ -2118,7 +2117,7 @@ _entryrdn_insert_key_elems(backend *be,
|
|
|
dc8c34 |
key->flags = DB_DBT_USERMEM;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_SELF, db_txn);
|
|
|
dc8c34 |
- if (rc) { /* failed */
|
|
|
dc8c34 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
@@ -2138,6 +2137,9 @@ _entryrdn_insert_key_elems(backend *be,
|
|
|
dc8c34 |
adddata.flags = DB_DBT_USERMEM;
|
|
|
dc8c34 |
/* adding RDN to the self key */
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, key, &adddata, RDN_INDEX_PARENT, db_txn);
|
|
|
dc8c34 |
+ if (DB_KEYEXIST == rc) { /* failed && ignore already exists */
|
|
|
dc8c34 |
+ rc = 0;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
/* Succeeded or failed, it's done. */
|
|
|
dc8c34 |
bail:
|
|
|
dc8c34 |
slapi_ch_free_string(&keybuf);
|
|
|
dc8c34 |
@@ -2261,7 +2263,7 @@ _entryrdn_replace_suffix_id(DBC *cursor, DBT *key, DBT *adddata,
|
|
|
dc8c34 |
/* Add it back */
|
|
|
dc8c34 |
rc = _entryrdn_put_data(cursor, &realkey, &moddata,
|
|
|
dc8c34 |
RDN_INDEX_CHILD, db_txn);
|
|
|
dc8c34 |
- if (rc) {
|
|
|
dc8c34 |
+ if (rc && (DB_KEYEXIST != rc)) { /* failed && ignore already exists */
|
|
|
dc8c34 |
goto bail0;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
if (curr_childnum + 1 == childnum) {
|
|
|
dc8c34 |
@@ -2524,7 +2526,7 @@ _entryrdn_insert_key(backend *be,
|
|
|
dc8c34 |
slapi_ch_free_string(&dn;;
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- elem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
dc8c34 |
+ elem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
dc8c34 |
if (NULL == elem) {
|
|
|
dc8c34 |
char *dn = NULL;
|
|
|
dc8c34 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
dc8c34 |
@@ -2544,12 +2546,13 @@ _entryrdn_insert_key(backend *be,
|
|
|
dc8c34 |
rc = _entryrdn_get_elem(cursor, &key, &data, nrdn, &elem);
|
|
|
dc8c34 |
if (rc) {
|
|
|
dc8c34 |
const char *myrdn = slapi_rdn_get_nrdn(srdn);
|
|
|
dc8c34 |
- const char *ep = NULL;
|
|
|
dc8c34 |
+ const char **ep = NULL;
|
|
|
dc8c34 |
int isexception = 0;
|
|
|
dc8c34 |
/* Check the RDN is in the exception list */
|
|
|
dc8c34 |
- for (ep = *rdn_exceptions; ep && *ep; ep++) {
|
|
|
dc8c34 |
- if (!strcmp(ep, myrdn)) {
|
|
|
dc8c34 |
+ for (ep = rdn_exceptions; ep && *ep; ep++) {
|
|
|
dc8c34 |
+ if (!strcmp(*ep, myrdn)) {
|
|
|
dc8c34 |
isexception = 1;
|
|
|
dc8c34 |
+ break;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
@@ -2629,7 +2632,7 @@ _entryrdn_insert_key(backend *be,
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- elem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
dc8c34 |
+ elem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
dc8c34 |
if (NULL == elem) {
|
|
|
dc8c34 |
char *dn = NULL;
|
|
|
dc8c34 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
dc8c34 |
@@ -2884,7 +2887,7 @@ _entryrdn_delete_key(backend *be,
|
|
|
dc8c34 |
slapi_ch_free_string(&dn;;
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- elem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
dc8c34 |
+ elem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
dc8c34 |
if (NULL == elem) {
|
|
|
dc8c34 |
char *dn = NULL;
|
|
|
dc8c34 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
dc8c34 |
@@ -3127,7 +3130,7 @@ _entryrdn_index_read(backend *be,
|
|
|
dc8c34 |
slapi_ch_free_string(&dn;;
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- *elem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
dc8c34 |
+ *elem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
dc8c34 |
if (NULL == *elem) {
|
|
|
dc8c34 |
char *dn = NULL;
|
|
|
dc8c34 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
dc8c34 |
@@ -3205,7 +3208,7 @@ _entryrdn_index_read(backend *be,
|
|
|
dc8c34 |
goto bail;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- tmpelem = _entryrdn_new_rdn_elem(be, 0 /*fake id*/, tmpsrdn, &len;;
|
|
|
dc8c34 |
+ tmpelem = _entryrdn_new_rdn_elem(be, TMPID, tmpsrdn, &len;;
|
|
|
dc8c34 |
if (NULL == tmpelem) {
|
|
|
dc8c34 |
char *dn = NULL;
|
|
|
dc8c34 |
slapi_rdn_get_dn(tmpsrdn, &dn;;
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.8.1.4
|
|
|
dc8c34 |
|