ldap/servers/plugins/automember/automember.c | 23 +-
ldap/servers/plugins/cos/cos.c | 2
ldap/servers/plugins/dna/dna.c | 18 +
ldap/servers/plugins/linkedattrs/linked_attrs.c | 34 ++-
ldap/servers/plugins/memberof/memberof.c | 16 -
ldap/servers/plugins/mep/mep.c | 41 ++--
ldap/servers/plugins/pam_passthru/pam_ptpreop.c | 12 -
ldap/servers/plugins/referint/referint.c | 52 ++---
ldap/servers/plugins/replication/repl5.h | 4
ldap/servers/plugins/replication/repl5_init.c | 11 -
ldap/servers/plugins/replication/repl5_plugins.c | 192 +++++---------------
ldap/servers/plugins/replication/urp.c | 41 ++--
ldap/servers/plugins/retrocl/retrocl_po.c | 12 -
ldap/servers/plugins/roles/roles_plugin.c | 2
ldap/servers/plugins/statechange/statechange.c | 22 +-
ldap/servers/plugins/usn/usn.c | 65 ++++---
ldap/servers/plugins/views/views.c | 35 +--
ldap/servers/slapd/add.c | 2
ldap/servers/slapd/back-ldbm/ldbm_add.c | 213 +++++++++++------------
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 51 +++--
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 2
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 2
ldap/servers/slapd/back-ldbm/ldbm_search.c | 2
ldap/servers/slapd/delete.c | 2
ldap/servers/slapd/dn.c | 67 ++++++-
ldap/servers/slapd/modify.c | 2
ldap/servers/slapd/modrdn.c | 2
ldap/servers/slapd/plugin.c | 20 +-
ldap/servers/slapd/rdn.c | 24 --
ldap/servers/slapd/slapi-plugin.h | 18 +
30 files changed, 507 insertions(+), 482 deletions(-)
New commits:
commit 6b87414c935903ed6d77905a3d8a716a4f3d26db
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jul 18 11:38:30 2013 -0700
Ticket #47367 - (phase 2) ldapdelete returns non-leaf entry error while trying to
remove a leaf entry
Fix description:
1) Make sure add/modify/modrdn/delete plug-in callbacks return
SLAPI_PLUGIN_SUCCESS (==0) on SUCCESS and SLAPI_PLUGIN_FAILURE
(==-1) on FAILURE. And set error code to SLAPI_RESULT_CODE in
pblock, if any.
2) replication: eliminated multimaster_betxnpreop_* which were
used for calling urp. Urp needs to be processed at bepreop
timing.
Reviewed by Rich (Thank you!!)
https://fedorahosted.org/389/ticket/47367
(cherry picked from commit 733059713a5dfb72c844de1e3b9bc153d4ae6ccb)
(cherry picked from commit ad0a2cabe349368e0cc72155994569564ca71290)
diff --git a/ldap/servers/plugins/automember/automember.c
b/ldap/servers/plugins/automember/automember.c
index 49f47f7..2ba3314 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -1686,7 +1686,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
LDAPMod **mods;
int free_entry = 0;
char *errstr = NULL;
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_pre_op\n");
@@ -1771,7 +1771,8 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
"automember_pre_op: operation failure [%d]\n", ret);
slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
slapi_ch_free((void **)&errstr);
- ret = -1;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
+ ret = SLAPI_PLUGIN_FAILURE;
}
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
@@ -1822,7 +1823,7 @@ automember_mod_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"<-- automember_mod_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static int
@@ -1838,7 +1839,7 @@ automember_add_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started || !automember_oktodo(pb))
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
/* Reload config if a config entry was added. */
if ((sdn = automember_get_sdn(pb))) {
@@ -1854,7 +1855,7 @@ automember_add_post_op(Slapi_PBlock *pb)
/* If replication, just bail. */
if (automember_isrepl(pb)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* Get the newly added entry. */
@@ -1868,7 +1869,7 @@ automember_add_post_op(Slapi_PBlock *pb)
tombstone);
slapi_value_free(&tombstone);
if (rc) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* Check if a config entry applies
@@ -1878,7 +1879,7 @@ automember_add_post_op(Slapi_PBlock *pb)
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
automember_config_unlock();
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (!PR_CLIST_IS_EMPTY(g_automember_config)) {
@@ -1907,7 +1908,7 @@ bail:
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"<-- automember_add_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/*
@@ -1925,7 +1926,7 @@ automember_del_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started || !automember_oktodo(pb)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* Reload config if a config entry was deleted. */
@@ -1941,7 +1942,7 @@ automember_del_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"<-- automember_del_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
typedef struct _task_data
@@ -2193,7 +2194,7 @@ void automember_rebuild_task_thread(void *arg){
/* Does the entry meet scope and filter requirements? */
if (slapi_dn_issuffix(slapi_sdn_get_dn(td->base_dn), config->scope)
&&
(slapi_filter_test_simple(entries[i], config->filter) == 0))
- {
+ {
automember_update_membership(config, entries[i], NULL);
}
list = PR_NEXT_LINK(list);
diff --git a/ldap/servers/plugins/cos/cos.c b/ldap/servers/plugins/cos/cos.c
index 0d76d99..55ff850 100644
--- a/ldap/servers/plugins/cos/cos.c
+++ b/ldap/servers/plugins/cos/cos.c
@@ -306,6 +306,6 @@ int cos_post_op( Slapi_PBlock *pb )
cos_cache_change_notify(pb);
LDAPDebug( LDAP_DEBUG_TRACE, "<-- cos_post_op\n",0,0,0);
- return 0; /* always succeed */
+ return SLAPI_PLUGIN_SUCCESS; /* always succeed */
}
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index a631208..a3c5468 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -70,8 +70,8 @@
#define DNA_DN "cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config"
/* temporary */
-#define DNA_SUCCESS 0
-#define DNA_FAILURE -1
+#define DNA_SUCCESS SLAPI_PLUGIN_SUCCESS
+#define DNA_FAILURE SLAPI_PLUGIN_FAILURE
/* Default range request timeout */
/* use the default replication timeout */
@@ -2798,7 +2798,7 @@ dna_create_valcheck_filter(struct configEntry *config_entry,
PRUint64 value, cha
static int
_dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
{
- int ret = 0;
+ int ret = DNA_SUCCESS;
PRCList *list = NULL;
struct configEntry *config_entry = NULL;
char *dn = NULL;
@@ -2977,7 +2977,7 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
slapi_ch_free((void **)&types_to_generate);
}
next:
- ret = 0;
+ ret = DNA_SUCCESS;
list = PR_NEXT_LINK(list);
}
}
@@ -2994,7 +2994,7 @@ bail:
static int
_dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods, char **errstr)
{
- int ret = 0;
+ int ret = DNA_SUCCESS;
PRCList *list = NULL;
struct configEntry *config_entry = NULL;
char *dn = NULL;
@@ -3376,6 +3376,7 @@ bail:
"dna_pre_op: operation failure [%d]\n", ret);
slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
slapi_ch_free((void **)&errstr);
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
ret = DNA_FAILURE;
}
@@ -3441,7 +3442,7 @@ static int dna_be_txn_pre_op(Slapi_PBlock *pb, int modtype)
char *dn = NULL;
char *type = NULL;
int numvals, e_numvals = 0;
- int i, len, ret = 0;
+ int i, len, ret = DNA_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_be_txn_pre_op\n");
@@ -3688,13 +3689,14 @@ bail:
"dna_be_txn_pre_op: operation failure [%d]\n", ret);
slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
slapi_ch_free((void **)&errstr);
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
ret = DNA_FAILURE;
}
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"<-- dna_be_txn_pre_op\n");
- return ret;
+ return ret;
}
static int dna_config_check_post_op(Slapi_PBlock * pb)
@@ -3715,7 +3717,7 @@ static int dna_config_check_post_op(Slapi_PBlock * pb)
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"<-- dna_config_check_post_op\n");
- return 0;
+ return DNA_SUCCESS;
}
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c
b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 7d8370d..30a8653 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1536,7 +1536,7 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
LDAPMod **mods = NULL;
int free_entry = 0;
char *errstr = NULL;
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_pre_op\n");
@@ -1603,7 +1603,8 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
"linked_attrs_pre_op: operation failure [%d]\n", ret);
slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
slapi_ch_free((void **)&errstr);
- ret = -1;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
+ ret = SLAPI_PLUGIN_FAILURE;
}
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
@@ -1640,7 +1641,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started)
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
/* We don't want to process internal modify
* operations that originate from this plugin.
@@ -1649,7 +1650,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
if (caller_id == linked_attrs_get_plugin_id()) {
/* Just return without processing */
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (linked_attrs_oktodo(pb) &&
@@ -1675,7 +1676,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
linked_attrs_unlock();
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
linked_attrs_find_config(dn, type, &config);
@@ -1729,7 +1730,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"<-- linked_attrs_mod_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static int
@@ -1743,7 +1744,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started || !linked_attrs_oktodo(pb))
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
/* Reload config if a config entry was added. */
if ((dn = linked_attrs_get_dn(pb))) {
@@ -1773,7 +1774,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
linked_attrs_unlock();
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
linked_attrs_find_config(dn, type, &config);
@@ -1808,7 +1809,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"<-- linked_attrs_add_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static int
@@ -1822,7 +1823,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started || !linked_attrs_oktodo(pb))
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
/* Reload config if a config entry was deleted. */
if ((dn = linked_attrs_get_dn(pb))) {
@@ -1852,7 +1853,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
linked_attrs_unlock();
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
linked_attrs_find_config(dn, type, &config);
@@ -1920,7 +1921,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"<-- linked_attrs_del_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static int
@@ -1932,7 +1933,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
Slapi_Attr *attr = NULL;
char *type = NULL;
struct configEntry *config = NULL;
- int rc = 0;
+ int rc = SLAPI_PLUGIN_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_modrdn_post_op\n");
@@ -1978,7 +1979,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
linked_attrs_unlock();
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
linked_attrs_find_config(old_dn, type, &config);
@@ -2069,7 +2070,10 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
done:
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"<-- linked_attrs_modrdn_post_op\n");
-
+ if (rc) {
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
+ }
return rc;
}
diff --git a/ldap/servers/plugins/memberof/memberof.c
b/ldap/servers/plugins/memberof/memberof.c
index 4baad88..991bd78 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -380,7 +380,7 @@ int memberof_postop_close(Slapi_PBlock *pb)
*/
int memberof_postop_del(Slapi_PBlock *pb)
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
MemberOfConfig configCopy = {0, 0, 0, 0};
Slapi_DN *sdn;
void *caller_id = NULL;
@@ -393,7 +393,7 @@ int memberof_postop_del(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &caller_id);
if (caller_id == memberof_get_plugin_id()) {
/* Just return without processing */
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb)))
@@ -626,7 +626,7 @@ int memberof_call_foreach_dn(Slapi_PBlock *pb, Slapi_DN *sdn,
*/
int memberof_postop_modrdn(Slapi_PBlock *pb)
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
void *caller_id = NULL;
slapi_log_error( SLAPI_LOG_TRACE, MEMBEROF_PLUGIN_SUBSYSTEM,
@@ -637,7 +637,7 @@ int memberof_postop_modrdn(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &caller_id);
if (caller_id == memberof_get_plugin_id()) {
/* Just return without processing */
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if(memberof_oktodo(pb))
@@ -801,7 +801,7 @@ int memberof_replace_dn_type_callback(Slapi_Entry *e, void
*callback_data)
*/
int memberof_postop_modify(Slapi_PBlock *pb)
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
Slapi_DN *sdn = NULL;
Slapi_Mods *smods = 0;
Slapi_Mod *smod = 0;
@@ -817,7 +817,7 @@ int memberof_postop_modify(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &caller_id);
if (caller_id == memberof_get_plugin_id()) {
/* Just return without processing */
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb)))
@@ -945,7 +945,7 @@ int memberof_postop_modify(Slapi_PBlock *pb)
*/
int memberof_postop_add(Slapi_PBlock *pb)
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
int interested = 0;
Slapi_DN *sdn = 0;
void *caller_id = NULL;
@@ -958,7 +958,7 @@ int memberof_postop_add(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &caller_id);
if (caller_id == memberof_get_plugin_id()) {
/* Just return without processing */
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb)))
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index f8e3c2b..58345e0 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -1984,7 +1984,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
char *errstr = NULL;
struct configEntry *config = NULL;
void *caller_id = NULL;
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_pre_op\n");
@@ -2259,7 +2259,8 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
"mep_pre_op: operation failure [%d]\n", ret);
slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
slapi_ch_free((void **)&errstr);
- ret = -1;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
+ ret = SLAPI_PLUGIN_FAILURE;
}
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
@@ -2313,7 +2314,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started)
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
if (mep_oktodo(pb) && (sdn = mep_get_sdn(pb))) {
/* First check if the config or a template is being modified. */
@@ -2430,7 +2431,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"<-- mep_mod_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static int
@@ -2445,7 +2446,7 @@ mep_add_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started || !mep_oktodo(pb))
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
/* Reload config if a config entry was added. */
if ((sdn = mep_get_sdn(pb))) {
@@ -2460,7 +2461,7 @@ mep_add_post_op(Slapi_PBlock *pb)
/* If replication, just bail. */
if (mep_isrepl(pb)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* Get the newly added entry. */
@@ -2469,7 +2470,7 @@ mep_add_post_op(Slapi_PBlock *pb)
if (e) {
/* If the entry is a tombstone, just bail. */
if (mep_has_tombstone_value(e)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* Check if a config entry applies
@@ -2479,7 +2480,7 @@ mep_add_post_op(Slapi_PBlock *pb)
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
mep_config_unlock();
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
mep_find_config(e, &config);
@@ -2497,7 +2498,7 @@ mep_add_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"<-- mep_add_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static int
@@ -2511,7 +2512,7 @@ mep_del_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started || !mep_oktodo(pb)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* Reload config if a config entry was deleted. */
@@ -2526,7 +2527,7 @@ mep_del_post_op(Slapi_PBlock *pb)
/* If replication, just bail. */
if (mep_isrepl(pb)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* Get deleted entry, then go through types to find config. */
@@ -2537,7 +2538,7 @@ mep_del_post_op(Slapi_PBlock *pb)
/* If the entry is a tombstone, just bail. */
if (mep_has_tombstone_value(e)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* See if we're an origin entry . */
@@ -2566,7 +2567,7 @@ mep_del_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"<-- mep_del_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static int
@@ -2584,7 +2585,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
/* Just bail if we aren't ready to service requests yet. */
if (!g_plugin_started || !mep_oktodo(pb))
- return 0;;
+ return SLAPI_PLUGIN_SUCCESS;;
/* Reload config if an existing config entry was renamed,
* or if the new dn brings an entry into the scope of the
@@ -2597,7 +2598,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
"mep_modrdn_post_op: Error "
"retrieving post-op entry\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if ((old_sdn = mep_get_sdn(pb))) {
@@ -2611,12 +2612,12 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
/* If replication, just bail. */
if (mep_isrepl(pb)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* If the entry is a tombstone, just bail. */
if (mep_has_tombstone_value(post_e)) {
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* See if we're an origin entry . */
@@ -2638,7 +2639,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
if (!g_plugin_started) {
mep_config_unlock();
slapi_pblock_destroy(mep_pb);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
mep_find_config(post_e, &config);
@@ -2809,7 +2810,7 @@ bailmod:
/* Bail out if the plug-in close function was just called. */
if (!g_plugin_started) {
mep_config_unlock();
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
mep_find_config(post_e, &config);
@@ -2823,7 +2824,7 @@ bailmod:
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"<-- mep_modrdn_post_op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static int
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
b/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
index 7d9ff8b..abf93e3 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
@@ -229,7 +229,7 @@ pam_passthruauth_init( Slapi_PBlock *pb )
slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"<= pam_passthruauth_init\n" );
- bail:
+bail:
return status;
}
@@ -574,7 +574,7 @@ pam_passthru_preop(Slapi_PBlock *pb, int modtype)
Slapi_Entry *e = NULL;
LDAPMod **mods;
char returntext[SLAPI_DSE_RETURNTEXT_SIZE];
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"=> pam_passthru_preop\n");
@@ -640,11 +640,11 @@ pam_passthru_preop(Slapi_PBlock *pb, int modtype)
}
- bail:
+bail:
/* If we are refusing the operation, return the result to the client. */
if (ret) {
slapi_send_ldap_result(pb, ret, NULL, returntext, 0, NULL);
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
}
slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
@@ -683,7 +683,7 @@ pam_passthru_modrdn_preop(Slapi_PBlock *pb)
static int
pam_passthru_postop(Slapi_PBlock *pb)
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
Slapi_DN *sdn = NULL;
Slapi_DN *new_sdn = NULL;
Slapi_Entry *e = NULL;
@@ -737,7 +737,7 @@ pam_passthru_postop(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"<= pam_passthru_postop\n");
- bail:
+bail:
return ret;
}
diff --git a/ldap/servers/plugins/referint/referint.c
b/ldap/servers/plugins/referint/referint.c
index 234c322..d31f53c 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -194,7 +194,7 @@ referint_postop_del( Slapi_PBlock *pb )
if (0 == refint_started) {
/* not initialized yet */
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
@@ -203,33 +203,33 @@ referint_postop_del( Slapi_PBlock *pb )
{
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop_del: could not get parameters\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
/*
* This plugin should only execute if the delete was successful
* and this is not a replicated op(unless its allowed)
*/
if(oprc != 0 || (isrepop && !allow_repl)){
- return( 0 );
+ return SLAPI_PLUGIN_SUCCESS;
}
/* get the args */
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop failed to get argc\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop failed to get argv\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
-
+
if(argv == NULL){
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop_del, args are NULL\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
-
+
if (argc >= 3) {
/* argv[0] will be the delay */
delay = atoi(argv[0]);
@@ -239,19 +239,19 @@ referint_postop_del( Slapi_PBlock *pb )
if(delay == -1){
/* integrity updating is off */
- rc = 0;
+ rc = SLAPI_PLUGIN_SUCCESS;
} else if(delay == 0){ /* no delay */
/* call function to update references to entry */
rc = update_integrity(argv, sdn, NULL, NULL, logChanges);
} else {
/* write the entry to integrity log */
writeintegritylog(pb, argv[1], sdn, NULL, NULL, NULL /*
slapi_get_requestor_sdn(pb) */);
- rc = 0;
+ rc = SLAPI_PLUGIN_SUCCESS;
}
} else {
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop insufficient arguments supplied\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
return( rc );
@@ -279,30 +279,30 @@ referint_postop_modrdn( Slapi_PBlock *pb )
{
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop_modrdn: could not get parameters\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
/*
* This plugin should only execute if the delete was successful
* and this is not a replicated op (unless its allowed)
*/
if(oprc != 0 || (isrepop && !allow_repl)){
- return( 0 );
+ return SLAPI_PLUGIN_SUCCESS;
}
/* get the args */
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop failed to get argv\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop failed to get argv\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
if(argv == NULL){
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop_modrdn, args are NULL\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
if (argc >= 3) {
@@ -314,19 +314,19 @@ referint_postop_modrdn( Slapi_PBlock *pb )
} else {
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop_modrdn insufficient arguments supplied\n" );
- return( -1 );
+ return SLAPI_PLUGIN_FAILURE;
}
if(delay == -1){
/* integrity updating is off */
- rc = 0;
+ rc = SLAPI_PLUGIN_SUCCESS;
} else if(delay == 0){ /* no delay */
/* call function to update references to entry */
rc = update_integrity(argv, sdn, newrdn, newsuperior, logChanges);
} else {
/* write the entry to integrity log */
writeintegritylog(pb, argv[1], sdn, newrdn, newsuperior, NULL /*
slapi_get_requestor_sdn(pb) */);
- rc = 0;
+ rc = SLAPI_PLUGIN_SUCCESS;
}
return( rc );
@@ -720,12 +720,12 @@ update_integrity(char **argv, Slapi_DN *origSDN,
int search_result;
int nval = 0;
int i, j;
- int rc;
+ int rc = SLAPI_PLUGIN_SUCCESS;
if ( argv == NULL ){
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"referint_postop required config file arguments missing\n" );
- rc = -1;
+ rc = SLAPI_PLUGIN_FAILURE;
goto free_and_return;
}
/*
@@ -818,7 +818,7 @@ update_integrity(char **argv, Slapi_DN *origSDN,
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
"update_integrity search (base=%s filter=%s) returned
"
"error %d\n", search_base, filter, search_result);
- rc = -1;
+ rc = SLAPI_PLUGIN_FAILURE;
goto free_and_return;
}
}
@@ -828,7 +828,7 @@ update_integrity(char **argv, Slapi_DN *origSDN,
}
}
/* if got here, then everything good rc = 0 */
- rc = 0;
+ rc = SLAPI_PLUGIN_SUCCESS;
free_and_return:
/* free filter and search_results_pb */
@@ -878,7 +878,7 @@ int referint_postop_start( Slapi_PBlock *pb)
keeprunning_mutex = PR_NewLock();
keeprunning_cv = PR_NewCondVar(keeprunning_mutex);
keeprunning =1;
-
+
referint_tid = PR_CreateThread (PR_USER_THREAD,
referint_thread_func,
(void *)argv,
@@ -1075,7 +1075,7 @@ int my_fgetc(PRFileDesc *stream)
}
return retval;
-}
+}
int
GetNextLine(char *dest, int size_dest, PRFileDesc *stream) {
@@ -1083,7 +1083,7 @@ GetNextLine(char *dest, int size_dest, PRFileDesc *stream) {
char nextchar ='\0';
int done = 0;
int i = 0;
-
+
while(!done){
if( ( nextchar = my_fgetc(stream) ) != 0){
if( i < (size_dest - 1) ){
diff --git a/ldap/servers/plugins/replication/repl5.h
b/ldap/servers/plugins/replication/repl5.h
index b15f268..5d2a421 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -210,10 +210,6 @@ int multimaster_bepreop_add (Slapi_PBlock *pb);
int multimaster_bepreop_delete (Slapi_PBlock *pb);
int multimaster_bepreop_modify (Slapi_PBlock *pb);
int multimaster_bepreop_modrdn (Slapi_PBlock *pb);
-int multimaster_betxnpreop_add (Slapi_PBlock *pb);
-int multimaster_betxnpreop_delete (Slapi_PBlock *pb);
-int multimaster_betxnpreop_modify (Slapi_PBlock *pb);
-int multimaster_betxnpreop_modrdn (Slapi_PBlock *pb);
int replica_ruv_smods_for_op (Slapi_PBlock *pb, char **uniqueid,
Slapi_Mods **smods);
int multimaster_bepostop_modrdn (Slapi_PBlock *pb);
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c
b/ldap/servers/plugins/replication/repl5_plugins.c
index 590af7e..7bd24d7 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -190,13 +190,13 @@ multimaster_preop_add (Slapi_PBlock *pb)
copy_operation_parameters(pb);
slapi_operation_set_csngen_handler(op,
(void*)replica_generate_next_csn);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (!is_mmr_replica (pb))
{
copy_operation_parameters(pb);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
@@ -241,7 +241,7 @@ multimaster_preop_add (Slapi_PBlock *pb)
slapi_ch_free ((void**)&target_uuid);
slapi_ch_free ((void**)&superior_uuid);
- return -1;
+ return SLAPI_PLUGIN_FAILURE;
}
operation_set_csn(op, csn);
@@ -296,7 +296,7 @@ multimaster_preop_add (Slapi_PBlock *pb)
copy_operation_parameters(pb);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
int
@@ -320,13 +320,13 @@ multimaster_preop_delete (Slapi_PBlock *pb)
slapi_operation_set_replica_attr_handler ( op, (void*)replica_get_attr );
slapi_operation_set_csngen_handler(op,
(void*)replica_generate_next_csn);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (!is_mmr_replica (pb))
{
copy_operation_parameters(pb);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
@@ -366,7 +366,7 @@ multimaster_preop_delete (Slapi_PBlock *pb)
csn_free (&csn);
slapi_ch_free ((void**)&target_uuid);
- return -1;
+ return SLAPI_PLUGIN_FAILURE;
}
/*
@@ -396,7 +396,7 @@ multimaster_preop_delete (Slapi_PBlock *pb)
copy_operation_parameters(pb);
slapi_operation_set_replica_attr_handler ( op, (void*)replica_get_attr );
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
int
@@ -419,13 +419,13 @@ multimaster_preop_modify (Slapi_PBlock *pb)
copy_operation_parameters(pb);
slapi_operation_set_csngen_handler(op,
(void*)replica_generate_next_csn);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (!is_mmr_replica (pb))
{
copy_operation_parameters(pb);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
@@ -465,7 +465,7 @@ multimaster_preop_modify (Slapi_PBlock *pb)
csn_free (&csn);
slapi_ch_free ((void**)&target_uuid);
- return -1;
+ return SLAPI_PLUGIN_FAILURE;
}
/*
@@ -498,7 +498,7 @@ multimaster_preop_modify (Slapi_PBlock *pb)
}
copy_operation_parameters(pb);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
int
@@ -521,13 +521,13 @@ multimaster_preop_modrdn (Slapi_PBlock *pb)
copy_operation_parameters(pb);
slapi_operation_set_csngen_handler(op,
(void*)replica_generate_next_csn);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (!is_mmr_replica (pb))
{
copy_operation_parameters(pb);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
@@ -577,7 +577,7 @@ multimaster_preop_modrdn (Slapi_PBlock *pb)
slapi_ch_free ((void**)&newsuperior_uuid);
ldap_mods_free (modrdn_mods, 1);
- return -1;
+ return SLAPI_PLUGIN_FAILURE;
}
operation_set_csn(op, csn);
@@ -625,19 +625,19 @@ multimaster_preop_modrdn (Slapi_PBlock *pb)
copy_operation_parameters(pb);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
int
multimaster_preop_search (Slapi_PBlock *pb)
{
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
int
multimaster_preop_compare (Slapi_PBlock *pb)
{
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
static void
@@ -704,7 +704,7 @@ purge_entry_state_information (Slapi_PBlock *pb)
int
multimaster_bepreop_add (Slapi_PBlock *pb)
{
- int rc= 0;
+ int rc= SLAPI_PLUGIN_SUCCESS;
Slapi_Operation *op;
int is_replicated_operation;
int is_fixup_operation;
@@ -729,7 +729,7 @@ multimaster_bepreop_add (Slapi_PBlock *pb)
int
multimaster_bepreop_delete (Slapi_PBlock *pb)
{
- int rc= 0;
+ int rc= SLAPI_PLUGIN_SUCCESS;
Slapi_Operation *op;
int is_replicated_operation;
int is_fixup_operation;
@@ -754,7 +754,7 @@ multimaster_bepreop_delete (Slapi_PBlock *pb)
int
multimaster_bepreop_modify (Slapi_PBlock *pb)
{
- int rc= 0;
+ int rc= SLAPI_PLUGIN_SUCCESS;
Slapi_Operation *op;
int is_replicated_operation;
int is_fixup_operation;
@@ -782,7 +782,7 @@ multimaster_bepreop_modify (Slapi_PBlock *pb)
int
multimaster_bepreop_modrdn (Slapi_PBlock *pb)
{
- int rc= 0;
+ int rc= SLAPI_PLUGIN_SUCCESS;
Slapi_Operation *op;
int is_replicated_operation;
int is_fixup_operation;
@@ -807,99 +807,6 @@ multimaster_bepreop_modrdn (Slapi_PBlock *pb)
return rc;
}
-/* betxn preop's */
-int
-multimaster_betxnpreop_add (Slapi_PBlock *pb)
-{
- int rc= 0;
- Slapi_Operation *op;
- int is_replicated_operation;
- int is_fixup_operation;
-
- slapi_pblock_get(pb, SLAPI_OPERATION, &op);
- is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
- is_fixup_operation= operation_is_flag_set(op,OP_FLAG_REPL_FIXUP);
-
- /* For replicated operations, apply URP algorithm */
- if (!is_fixup_operation)
- {
- if (is_replicated_operation) {
- rc = urp_add_operation(pb);
- }
- }
-
- return rc;
-}
-
-int
-multimaster_betxnpreop_delete (Slapi_PBlock *pb)
-{
- int rc= 0;
- Slapi_Operation *op;
- int is_replicated_operation;
- int is_fixup_operation;
-
- slapi_pblock_get(pb, SLAPI_OPERATION, &op);
- is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
- is_fixup_operation= operation_is_flag_set(op,OP_FLAG_REPL_FIXUP);
-
- /* For replicated operations, apply URP algorithm */
- if(!is_fixup_operation)
- {
- if (is_replicated_operation) {
- rc = urp_delete_operation(pb);
- }
- }
-
- return rc;
-}
-
-int
-multimaster_betxnpreop_modify (Slapi_PBlock *pb)
-{
- int rc= 0;
- Slapi_Operation *op;
- int is_replicated_operation;
- int is_fixup_operation;
-
- slapi_pblock_get(pb, SLAPI_OPERATION, &op);
- is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
- is_fixup_operation= operation_is_flag_set(op,OP_FLAG_REPL_FIXUP);
-
- /* For replicated operations, apply URP algorithm */
- if(!is_fixup_operation)
- {
- if (is_replicated_operation) {
- rc = urp_modify_operation(pb);
- }
- }
-
- return rc;
-}
-
-int
-multimaster_betxnpreop_modrdn (Slapi_PBlock *pb)
-{
- int rc= 0;
- Slapi_Operation *op;
- int is_replicated_operation;
- int is_fixup_operation;
-
- slapi_pblock_get(pb, SLAPI_OPERATION, &op);
- is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
- is_fixup_operation= operation_is_flag_set(op,OP_FLAG_REPL_FIXUP);
-
- /* For replicated operations, apply URP algorithm */
- if(!is_fixup_operation)
- {
- if (is_replicated_operation) {
- rc = urp_modrdn_operation(pb);
- }
- }
-
- return rc;
-}
-
int
multimaster_bepostop_modrdn (Slapi_PBlock *pb)
{
@@ -910,7 +817,7 @@ multimaster_bepostop_modrdn (Slapi_PBlock *pb)
{
urp_post_modrdn_operation (pb);
}
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
int
@@ -923,14 +830,14 @@ multimaster_bepostop_delete (Slapi_PBlock *pb)
{
urp_post_delete_operation (pb);
}
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* postop - write to changelog */
int
multimaster_postop_bind (Slapi_PBlock *pb)
{
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
int
@@ -985,7 +892,7 @@ multimaster_betxnpostop_modify (Slapi_PBlock *pb)
int
multimaster_be_betxnpostop_delete (Slapi_PBlock *pb)
{
- int rc = 0;
+ int rc = SLAPI_PLUGIN_SUCCESS;
/* original betxnpost */
rc = write_changelog_and_ruv(pb);
/* original bepost */
@@ -1119,7 +1026,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
int rc;
slapi_operation_parameters *op_params = NULL;
Object *repl_obj;
- int return_value = 0;
+ int return_value = SLAPI_PLUGIN_SUCCESS;
Replica *r;
Slapi_Backend *be;
int is_replicated_operation = 0;
@@ -1129,7 +1036,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
if ((operation_is_flag_set(op, OP_FLAG_REPL_FIXUP)) ||
(operation_is_flag_set(op, OP_FLAG_TOMBSTONE_ENTRY)))
{
- return 0;
+ return return_value;
}
/* ignore operations intended for chaining backends - they will be
@@ -1141,18 +1048,18 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
if (!is_replicated_operation &&
slapi_be_is_flag_set(be,SLAPI_BE_FLAG_REMOTE_DATA))
{
- return 0;
+ return return_value;
}
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (rc) { /* op failed - just return */
- return 0;
+ return return_value;
}
/* we only log changes for operations applied to a replica */
repl_obj = replica_get_replica_for_op (pb);
if (repl_obj == NULL)
- return 0;
+ return return_value;
r = (Replica*)object_get_data (repl_obj);
PR_ASSERT (r);
@@ -1214,7 +1121,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
if( op_params->csn &&
is_cleaned_rid(csn_get_replicaid(op_params->csn))){
/* this RID has been cleaned */
object_release (repl_obj);
- return 0;
+ return return_value;
}
/* we might have stripped all the mods - in that case we do not
@@ -1227,7 +1134,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"write_changelog_and_ruv: Skipped due to DISKFULL\n");
- return 0;
+ return return_value;
}
slapi_pblock_get(pb, SLAPI_TXN, &txn);
rc = cl5WriteOperationTxn(repl_name, repl_gen, op_params,
@@ -1243,7 +1150,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
op_params->target_address.uniqueid,
op_params->operation_type,
csn_as_string(op_params->csn, PR_FALSE, csn_str));
- return_value = 1;
+ return_value = SLAPI_PLUGIN_FAILURE;
}
}
@@ -1313,7 +1220,7 @@ process_postop (Slapi_PBlock *pb)
if ((operation_is_flag_set(op, OP_FLAG_REPL_FIXUP)) ||
(operation_is_flag_set(op, OP_FLAG_TOMBSTONE_ENTRY)))
{
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/* ignore operations intended for chaining backends - they will be
@@ -1325,24 +1232,27 @@ process_postop (Slapi_PBlock *pb)
if (!is_replicated_operation &&
slapi_be_is_flag_set(be,SLAPI_BE_FLAG_REMOTE_DATA))
{
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
get_repl_session_id (pb, sessionid, &opcsn);
- slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (rc == LDAP_SUCCESS)
{
- agmtlist_notify_all(pb);
+ agmtlist_notify_all(pb);
+ rc = SLAPI_PLUGIN_SUCCESS;
}
- else if (opcsn)
+ else if (opcsn)
{
- rc = cancel_opcsn (pb);
+ rc = cancel_opcsn (pb);
/* Don't try to get session id since conn is always null */
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
"%s process postop: canceling operation csn\n", sessionid);
- }
+ } else {
+ rc = SLAPI_PLUGIN_FAILURE;
+ }
/* the target unique id is set in the modify_preop above, so
we need to free it */
@@ -1436,7 +1346,7 @@ cancel_opcsn (Slapi_PBlock *pb)
object_release (repl_obj);
}
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
diff --git a/ldap/servers/plugins/retrocl/retrocl_po.c
b/ldap/servers/plugins/retrocl/retrocl_po.c
index c3d1c41..382c98a 100644
--- a/ldap/servers/plugins/retrocl/retrocl_po.c
+++ b/ldap/servers/plugins/retrocl/retrocl_po.c
@@ -581,24 +581,24 @@ int retrocl_postob (Slapi_PBlock *pb,int optype)
if (slapi_be_logchanges(be) == 0) {
LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if not
logging\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (retrocl_be_changelog == NULL || be == retrocl_be_changelog) {
LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if no/cl be\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (rc != LDAP_SUCCESS) {
LDAPDebug1Arg(LDAP_DEBUG_TRACE,"not applying change if op failed
%d\n",rc);
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (slapi_op_abandoned(pb)) {
LDAPDebug0Args(LDAP_DEBUG_PLUGIN,"not applying change if op
abandoned\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
curtime = current_time();
@@ -613,12 +613,12 @@ int retrocl_postob (Slapi_PBlock *pb,int optype)
if (op == NULL) {
LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if no op\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
if (operation_is_flag_set(op, OP_FLAG_TOMBSTONE_ENTRY)){
LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change for nsTombstone
entries\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
switch ( optype ) {
diff --git a/ldap/servers/plugins/roles/roles_plugin.c
b/ldap/servers/plugins/roles/roles_plugin.c
index 9db76ca..b00e9a7 100644
--- a/ldap/servers/plugins/roles/roles_plugin.c
+++ b/ldap/servers/plugins/roles/roles_plugin.c
@@ -355,7 +355,7 @@ static int roles_post_op( Slapi_PBlock *pb )
roles_cache_change_notify(pb);
slapi_log_error( SLAPI_LOG_PLUGIN, ROLES_PLUGIN_SUBSYSTEM, "<--
roles_post_op\n");
- return 0; /* always succeed */
+ return SLAPI_PLUGIN_SUCCESS; /* always succeed */
}
static void roles_set_plugin_identity(void * identity)
diff --git a/ldap/servers/plugins/statechange/statechange.c
b/ldap/servers/plugins/statechange/statechange.c
index 0b2b737..307ea75 100644
--- a/ldap/servers/plugins/statechange/statechange.c
+++ b/ldap/servers/plugins/statechange/statechange.c
@@ -110,7 +110,7 @@ void plugin_init_debug_level(int *level_ptr)
*/
int statechange_init( Slapi_PBlock *pb )
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
Slapi_Entry *plugin_entry = NULL;
char *plugin_type = NULL;
int postadd = SLAPI_PLUGIN_POST_ADD_FN;
@@ -148,7 +148,7 @@ int statechange_init( Slapi_PBlock *pb )
{
slapi_log_error( SLAPI_LOG_FATAL, SCN_PLUGIN_SUBSYSTEM,
"statechange_init: failed to register plugin\n" );
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
}
slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "<--
statechange_init\n");
@@ -163,7 +163,7 @@ int statechange_init( Slapi_PBlock *pb )
*/
static int statechange_start( Slapi_PBlock *pb )
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "-->
statechange_start\n");
@@ -177,14 +177,14 @@ static int statechange_start( Slapi_PBlock *pb )
{
/* badness */
slapi_log_error( SLAPI_LOG_FATAL, SCN_PLUGIN_SUBSYSTEM, "statechange: failed to
create lock\n");
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
}
else
{
if( slapi_apib_register(StateChange_v1_0_GUID, api) )
{
slapi_log_error( SLAPI_LOG_FATAL, SCN_PLUGIN_SUBSYSTEM, "statechange: failed to
publish state change interface\n");
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
}
}
@@ -207,7 +207,7 @@ static int statechange_close( Slapi_PBlock *pb )
slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "<--
statechange_close\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
@@ -251,7 +251,7 @@ static int statechange_post_op( Slapi_PBlock *pb, int modtype )
struct slapi_entry *e_after = NULL;
if(head == 0)
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "-->
statechange_post_op\n");
@@ -317,13 +317,13 @@ bail:
slapi_unlock_mutex(buffer_lock);
slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "<--
statechange_post_op\n");
- return 0; /* always succeed */
+ return SLAPI_PLUGIN_SUCCESS; /* always succeed */
}
static int _statechange_register(char *caller_id, char *dn, char *filter, void
*caller_data, notify_callback func)
{
- int ret = -1;
+ int ret = SLAPI_PLUGIN_FAILURE;
SCNotify *item;
/* simple - we don't check for duplicates */
@@ -352,7 +352,7 @@ static int _statechange_register(char *caller_id, char *dn, char
*filter, void *
slapi_ch_free_string(&item->filter);
slapi_ch_free_string(&writable_filter);
slapi_ch_free((void **)&item);
- return -1;
+ return ret;
} else if (!writable_filter) {
item->realfilter = NULL;
}
@@ -375,7 +375,7 @@ static int _statechange_register(char *caller_id, char *dn, char
*filter, void *
slapi_unlock_mutex(buffer_lock);
slapi_ch_free_string(&writable_filter);
- ret = 0;
+ ret = SLAPI_PLUGIN_SUCCESS;
}
return ret;
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 4473618..338517f 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -148,13 +148,13 @@ bail:
static int
usn_preop_init(Slapi_PBlock *pb)
{
- int rc = 0;
+ int rc = SLAPI_PLUGIN_SUCCESS;
int predel = SLAPI_PLUGIN_PRE_DELETE_FN;
if (slapi_pblock_set(pb, predel, (void *)usn_preop_delete) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
"usn_preop_init: failed to register preop plugin\n");
- rc = -1;
+ rc = SLAPI_PLUGIN_FAILURE;
}
return rc;
@@ -163,7 +163,7 @@ usn_preop_init(Slapi_PBlock *pb)
static int
usn_bepreop_init(Slapi_PBlock *pb)
{
- int rc = 0;
+ int rc = SLAPI_PLUGIN_SUCCESS;
int premod = SLAPI_PLUGIN_BE_PRE_MODIFY_FN;
int premdn = SLAPI_PLUGIN_BE_PRE_MODRDN_FN;
@@ -175,7 +175,7 @@ usn_bepreop_init(Slapi_PBlock *pb)
(slapi_pblock_set(pb, premdn, (void *)usn_bepreop_modify) != 0)) {
slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
"usn_bepreop_init: failed to register bepreop
plugin\n");
- rc = -1;
+ rc = SLAPI_PLUGIN_FAILURE;
}
return rc;
@@ -184,7 +184,7 @@ usn_bepreop_init(Slapi_PBlock *pb)
static int
usn_betxnpreop_init(Slapi_PBlock *pb)
{
- int rc = 0;
+ int rc = SLAPI_PLUGIN_SUCCESS;
int preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
int predel = SLAPI_PLUGIN_BE_TXN_PRE_DELETE_TOMBSTONE_FN;
@@ -192,7 +192,7 @@ usn_betxnpreop_init(Slapi_PBlock *pb)
(slapi_pblock_set(pb, predel, (void *)usn_betxnpreop_delete) != 0)) {
slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
"usn_betxnpreop_init: failed to register betxnpreop
plugin\n");
- rc = -1;
+ rc = SLAPI_PLUGIN_FAILURE;
}
return rc;
@@ -201,7 +201,7 @@ usn_betxnpreop_init(Slapi_PBlock *pb)
static int
usn_bepostop_init(Slapi_PBlock *pb)
{
- int rc = 0;
+ int rc = SLAPI_PLUGIN_SUCCESS;
Slapi_Entry *plugin_entry = NULL;
char *plugin_type = NULL;
int postadd = SLAPI_PLUGIN_BE_POST_ADD_FN;
@@ -227,7 +227,7 @@ usn_bepostop_init(Slapi_PBlock *pb)
(slapi_pblock_set(pb, postmdn, (void *)usn_bepostop) != 0)) {
slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
"usn_bepostop_init: failed to register bepostop
plugin\n");
- rc = -1;
+ rc = SLAPI_PLUGIN_FAILURE;
}
return rc;
@@ -236,12 +236,12 @@ usn_bepostop_init(Slapi_PBlock *pb)
static int
usn_rootdse_init()
{
- int rc = -1;
+ int rc = SLAPI_PLUGIN_FAILURE;
if (slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP,
"", LDAP_SCOPE_BASE,
"(objectclass=*)",
usn_rootdse_search, NULL)) {
- rc = 0;
+ rc = SLAPI_PLUGIN_SUCCESS;
}
return rc;
@@ -254,7 +254,7 @@ usn_rootdse_init()
static int
usn_start(Slapi_PBlock *pb)
{
- int rc = 0;
+ int rc = SLAPI_PLUGIN_SUCCESS;
Slapi_Value *value;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "-->
usn_start\n");
@@ -262,6 +262,7 @@ usn_start(Slapi_PBlock *pb)
rc = usn_rootdse_init();
rc |= usn_cleanup_start(pb);
if (rc) {
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
if (0) { /* Not executed; test code for slapi_get_plugin_default_config */
@@ -284,7 +285,9 @@ usn_start(Slapi_PBlock *pb)
/* add nsds5ReplicatedAttributeList: (objectclass=*) $ EXCLUDE entryusn
* to cn=plugin default config,cn=config */
value = slapi_value_new_string("(objectclass=*) $ EXCLUDE entryusn");
- rc = slapi_set_plugin_default_config("nsds5ReplicatedAttributeList",
value);
+ if (slapi_set_plugin_default_config("nsds5ReplicatedAttributeList", value))
{
+ rc = SLAPI_PLUGIN_FAILURE;
+ }
slapi_value_free(&value);
g_plugin_started = 1;
bail:
@@ -302,7 +305,7 @@ usn_close(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "<--
usn_close\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
/*
@@ -311,7 +314,6 @@ usn_close(Slapi_PBlock *pb)
static int
usn_preop_delete(Slapi_PBlock *pb)
{
- int rc = 0;
Slapi_Operation *op = NULL;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
@@ -323,7 +325,7 @@ usn_preop_delete(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"<-- usn_preop_delete\n");
- return rc;
+ return SLAPI_PLUGIN_SUCCESS;
}
static void
@@ -407,7 +409,7 @@ usn_betxnpreop_add(Slapi_PBlock *pb)
{
Slapi_Entry *e = NULL;
Slapi_Backend *be = NULL;
- int rc = LDAP_SUCCESS;
+ int rc = SLAPI_PLUGIN_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"--> usn_betxnpreop_add\n");
@@ -416,11 +418,15 @@ usn_betxnpreop_add(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
if (NULL == e) {
rc = LDAP_NO_SUCH_OBJECT;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
if (NULL == be) {
rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
_usn_add_next_usn(e, be);
@@ -439,7 +445,7 @@ usn_betxnpreop_delete(Slapi_PBlock *pb)
{
Slapi_Entry *e = NULL;
Slapi_Backend *be = NULL;
- int rc = LDAP_SUCCESS;
+ int rc = SLAPI_PLUGIN_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"--> usn_betxnpreop_delete\n");
@@ -448,11 +454,15 @@ usn_betxnpreop_delete(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_DELETE_BEPREOP_ENTRY, &e);
if (NULL == e) {
rc = LDAP_NO_SUCH_OBJECT;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
if (NULL == be) {
rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
_usn_add_next_usn(e, be);
@@ -472,7 +482,7 @@ usn_bepreop_modify (Slapi_PBlock *pb)
{
LDAPMod **mods = NULL;
Slapi_Backend *be = NULL;
- int rc = LDAP_SUCCESS;
+ int rc = SLAPI_PLUGIN_SUCCESS;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
"--> usn_bepreop_modify\n");
@@ -483,6 +493,9 @@ usn_bepreop_modify (Slapi_PBlock *pb)
if (NULL == be) {
slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
"usn_bepreop_modify: no backend.\n");
+ rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
if (LDAP_SUCCESS == _usn_mod_next_usn(&mods, be)) {
@@ -498,7 +511,7 @@ bail:
static int
usn_bepostop (Slapi_PBlock *pb)
{
- int rc = -1;
+ int rc = SLAPI_PLUGIN_FAILURE;
Slapi_Backend *be = NULL;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
@@ -507,12 +520,16 @@ usn_bepostop (Slapi_PBlock *pb)
/* if op is not successful, don't increment the counter */
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (LDAP_SUCCESS != rc) {
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
if (NULL == be) {
rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
@@ -529,7 +546,7 @@ bail:
static int
usn_bepostop_modify (Slapi_PBlock *pb)
{
- int rc = -1;
+ int rc = SLAPI_PLUGIN_FAILURE;
Slapi_Backend *be = NULL;
LDAPMod **mods = NULL;
int i;
@@ -540,6 +557,7 @@ usn_bepostop_modify (Slapi_PBlock *pb)
/* if op is not successful, don't increment the counter */
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (LDAP_SUCCESS != rc) {
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
@@ -560,6 +578,8 @@ usn_bepostop_modify (Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
if (NULL == be) {
rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
@@ -577,7 +597,7 @@ bail:
static int
usn_bepostop_delete (Slapi_PBlock *pb)
{
- int rc = -1;
+ int rc = SLAPI_PLUGIN_FAILURE;
Slapi_Backend *be = NULL;
slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
@@ -586,12 +606,15 @@ usn_bepostop_delete (Slapi_PBlock *pb)
/* if op is not successful, don't increment the counter */
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
if (LDAP_SUCCESS != rc) {
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
if (NULL == be) {
rc = LDAP_PARAM_ERROR;
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+ rc = SLAPI_PLUGIN_FAILURE;
goto bail;
}
diff --git a/ldap/servers/plugins/views/views.c b/ldap/servers/plugins/views/views.c
index 0892b0d..c6fd628 100644
--- a/ldap/servers/plugins/views/views.c
+++ b/ldap/servers/plugins/views/views.c
@@ -185,7 +185,7 @@ void * view_get_plugin_identity()
*/
int views_init( Slapi_PBlock *pb )
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
void * plugin_identity=NULL;
slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "-->
views_init\n");
@@ -209,7 +209,7 @@ int views_init( Slapi_PBlock *pb )
{
slapi_log_error( SLAPI_LOG_FATAL, VIEWS_PLUGIN_SUBSYSTEM,
"views_init: failed to register plugin\n" );
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
}
slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "<--
views_init\n");
@@ -238,7 +238,7 @@ void views_unlock()
*/
static int views_start( Slapi_PBlock *pb )
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
void **statechange_api;
slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "-->
views_start\n");
@@ -270,7 +270,7 @@ static int views_start( Slapi_PBlock *pb )
if( slapi_apib_register(Views_v1_0_GUID, api) )
{
slapi_log_error( SLAPI_LOG_FATAL, VIEWS_PLUGIN_SUBSYSTEM, "views: failed to
publish views interface\n");
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
}
slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "<--
views_start\n");
@@ -296,7 +296,7 @@ static int _internal_api_views_entry_dn_exists(char *view_dn, char
*e_dn)
static int _internal_api_views_entry_exists_general(char *view_dn, Slapi_Entry *e, char
*e_dn)
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
viewEntry *view;
char *dn;
@@ -326,7 +326,7 @@ static int _internal_api_views_entry_exists_general(char *view_dn,
Slapi_Entry *
if(slapi_dn_issuffix(dn, view_dn))
{
/* this entry is physically contained in the view hiearchy */
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
goto bail;
}
@@ -346,7 +346,7 @@ static int _internal_api_views_entry_exists_general(char *view_dn,
Slapi_Entry *
if(0==slapi_filter_test_simple(e,view->includeAncestorFiltersFilter))
{
/* this entry would appear in the view */
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
}
}
@@ -408,7 +408,7 @@ static int views_close( Slapi_PBlock *pb )
slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "<--
views_close\n");
- return 0;
+ return SLAPI_PLUGIN_SUCCESS;
}
@@ -419,7 +419,7 @@ static int views_close( Slapi_PBlock *pb )
*/
static int views_cache_create()
{
- int ret = -1;
+ int ret = SLAPI_PLUGIN_FAILURE;
slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "-->
views_cache_create\n");
@@ -474,7 +474,7 @@ static int views_cache_create()
{
/* its ok to not have views to cache */
theCache.cache_built = 0;
- ret = 0;
+ ret = SLAPI_PLUGIN_SUCCESS;
}
theCache.currentUpdaterThread = 0;
@@ -530,7 +530,7 @@ int views_cache_dn_compare(const void *e1, const void *e2)
*/
static int views_cache_index()
{
- int ret = -1;
+ int ret = SLAPI_PLUGIN_FAILURE;
int i;
viewEntry *theView = theCache.pCacheViews;
viewEntry *current = 0;
@@ -558,7 +558,7 @@ static int views_cache_index()
/* sort the views */
qsort(theCache.ppViewIndex, theCache.view_count, sizeof(viewEntry*),
views_cache_view_compare);
- ret = 0;
+ ret = SLAPI_PLUGIN_SUCCESS;
}
return ret;
@@ -569,7 +569,7 @@ static int views_cache_index()
views_cache_view_index_bsearch - RECURSIVE
----------------------------------------
performs a binary search on the cache view index
- return -1 if key is not found
+ return SLAPI_PLUGIN_FAILURE if key is not found
*/
viewEntry *views_cache_view_index_bsearch( const char *key, int lower, int upper )
{
@@ -617,7 +617,7 @@ viewEntry *views_cache_view_index_bsearch( const char *key, int lower,
int upper
*/
static viewEntry *views_cache_find_view(char *view)
{
- viewEntry *ret = 0; /* assume failure */
+ viewEntry *ret = SLAPI_PLUGIN_SUCCESS; /* assume failure */
if(theCache.view_count != 1)
ret = views_cache_view_index_bsearch(view, 0, theCache.view_count-1);
@@ -1119,7 +1119,7 @@ static void views_cache_create_inclusion_filter(viewEntry *pView)
*/
static int views_cache_build_view_list(viewEntry **pViews)
{
- int ret = 0;
+ int ret = SLAPI_PLUGIN_SUCCESS;
Slapi_PBlock *pSuffixSearch = 0;
Slapi_Entry **pSuffixList = 0;
Slapi_Attr *suffixAttr;
@@ -1192,7 +1192,7 @@ static int views_cache_build_view_list(viewEntry **pViews)
else
{
slapi_log_error(SLAPI_LOG_PLUGIN, VIEWS_PLUGIN_SUBSYSTEM,
"views_cache_build_view_list: failed to find suffixes\n");
- ret = -1;
+ ret = SLAPI_PLUGIN_FAILURE;
}
/* clean up */
@@ -1215,7 +1215,8 @@ struct dn_views_info {
/* does same funcationality as views_add_dn_views except it is invoked via a callback */
-static int views_dn_views_cb (Slapi_Entry* e, void *callback_data) {
+static int views_dn_views_cb (Slapi_Entry* e, void *callback_data)
+{
struct dn_views_info *info;
char *pDn = 0;
struct berval **dnVals;
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 2a70f64..2e326cf 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -713,7 +713,7 @@ static void op_shared_add (Slapi_PBlock *pb)
sdn = slapi_sdn_dup(slapi_entry_get_sdn_const(e));
slapi_pblock_set(pb, SLAPI_ADD_TARGET_SDN, (void *)sdn);
if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN :
- SLAPI_PLUGIN_PRE_ADD_FN) == 0)
+ SLAPI_PLUGIN_PRE_ADD_FN) == SLAPI_PLUGIN_SUCCESS)
{
int rc;
Slapi_Entry *ec;
diff --git a/ldap/servers/slapd/delete.c b/ldap/servers/slapd/delete.c
index ced6351..68409c7 100644
--- a/ldap/servers/slapd/delete.c
+++ b/ldap/servers/slapd/delete.c
@@ -353,7 +353,7 @@ static void op_shared_delete (Slapi_PBlock *pb)
* post-delete plugins.
*/
if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN :
- SLAPI_PLUGIN_PRE_DELETE_FN) == 0)
+ SLAPI_PLUGIN_PRE_DELETE_FN) == SLAPI_PLUGIN_SUCCESS)
{
int rc;
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index 867e391..be8b9b8 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -1040,7 +1040,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char
*old_pw)
*/
slapi_pblock_set (pb, SLAPI_MODIFY_MODS, (void*)slapi_mods_get_ldapmods_passout
(&smods));
if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN :
- SLAPI_PLUGIN_PRE_MODIFY_FN) == 0)
+ SLAPI_PLUGIN_PRE_MODIFY_FN) == SLAPI_PLUGIN_SUCCESS)
{
int rc;
diff --git a/ldap/servers/slapd/modrdn.c b/ldap/servers/slapd/modrdn.c
index 62c7f6a..bbdd9dd 100644
--- a/ldap/servers/slapd/modrdn.c
+++ b/ldap/servers/slapd/modrdn.c
@@ -654,7 +654,7 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
* post-modrdn plugins.
*/
if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN :
- SLAPI_PLUGIN_PRE_MODRDN_FN) == 0)
+ SLAPI_PLUGIN_PRE_MODRDN_FN) == SLAPI_PLUGIN_SUCCESS)
{
int rc= LDAP_OPERATIONS_ERROR;
slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database);
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index d19faa5..5f66ab2 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1453,9 +1453,8 @@ plugin_call_func (struct slapdplugin *list, int operation,
Slapi_PBlock *pb, int
if (( rc = func (pb)) != 0 )
{
if (SLAPI_PLUGIN_PREOPERATION == list->plg_type ||
- SLAPI_PLUGIN_INTERNAL_PREOPERATION == list->plg_type ||
- SLAPI_PLUGIN_BETXNPREOPERATION == list->plg_type ||
- SLAPI_PLUGIN_START_FN == operation )
+ SLAPI_PLUGIN_INTERNAL_PREOPERATION == list->plg_type ||
+ SLAPI_PLUGIN_START_FN == operation )
{
/*
* We bail out of plugin processing for preop plugins
@@ -1465,13 +1464,18 @@ plugin_call_func (struct slapdplugin *list, int operation,
Slapi_PBlock *pb, int
*/
return_value = rc;
break;
- } else if (SLAPI_PLUGIN_BEPREOPERATION == list->plg_type ||
- SLAPI_PLUGIN_BEPOSTOPERATION == list->plg_type)
+ }
+ else if (SLAPI_PLUGIN_BEPREOPERATION == list->plg_type ||
+ SLAPI_PLUGIN_BETXNPREOPERATION == list->plg_type ||
+ SLAPI_PLUGIN_BEPOSTOPERATION == list->plg_type)
{
- /* respect fatal error (-1); should not OR it */
- if (-1 == rc) {
+ /*
+ * respect fatal error SLAPI_PLUGIN_FAILURE (-1);
+ * should not OR it.
+ */
+ if (SLAPI_PLUGIN_FAILURE == rc) {
return_value = rc;
- } else if (-1 != return_value) {
+ } else if (SLAPI_PLUGIN_FAILURE != return_value) {
/* OR the result into the return value
* for be pre/postops */
return_value |= rc;
commit 28b313cac943d9d50866f9d73e6486167f2dbc8a
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jul 18 14:27:28 2013 -0700
Ticket #47367 - (phase 1) ldapdelete returns non-leaf entry error while trying to
remove a leaf entry
Bug description: Replication conflict confuses the numsubordinate count,
which leaves an entry that cannot be deleted even its subordinate entries
are all removed.
Fix description:
[urp.c] 1) get_dn_plus_uniqueid: a logic to create a conflict DN had a bug.
It used to call slapi_sdn_get_rdn to get the rdn. The function slapi_sdn_
get_rdn blindly returned the "dn" field without checking whether the
field
is NULL or not. Instead, this patch changes the interface of the helper
function get_dn_plus_uniqueid and use the original Slapi_DN with slapi_sdn_
get_dn, then generates the conflict DN "nsuniqueid=...+
<RDN>,<PARENT>".
2) The urp calling timing was moved from SLAPI_PLUGIN_BE_TXN_PRE_* to
SLAPI_PLUGIN_BE_PRE_*. (Note: SLAPI_PLUGIN_BE_PRE_* is also in the
backend transaction.) This is necessary since urp needs to be done
prior to parent checking.
[ldbm_add.c] Moved SLAPI_PLUGIN_BE_PRE_ADD_FN inside of the transaction.
Other operations are already calling SLAPI_PLUGIN_BE_PRE function at the
timing.
[ldbm_delete.c] There is a case a parent of a delete-candidate entry runs
into a conflict and multiple parent entries exist. Once it occurs, a
parent entry found by the parent dn string may not be the entry which
manages the numsubordinate count the delete-candidate entry belonging to.
It confuses the numsubordinate counts and leaves an entry which cannot be
deleted due to the numsubordinate count mismatch. This patch retrieves
parent entry by parent id if it is available.
[ldbm_entryrdn.c] When traversing the DIT, a special treatment is needed
for a tombstone entry. I.e, 2 RDNs (nsuniqueid=..., <RDN>) is treated as
one RDN. It should decrement the index (rdnidx) one more to point to the
right position of the RDN array in Slapi_RDN.
[ldbm_search.c] When checking the scope of an entry in ldbm_back_next_
search_entry_ext, a tombstone entry was not properly examined. This patch
introduces a new slapi api slapi_sdn_scope_test_ext.
[dn.c] In slapi_sdn_get_rdn, use slapi_sdn_get_dn to get the dn value of
Slapi_DN. It was one cause of the problem in get_dn_plus_uniqueid (urp.c).
This patch adds slapi_sdn_scope_test_ext, which takes flags to indicates
the first argument dn is a tombstone sdn. Also, this patch replaces
"malloc + strcpy + strcat" with slapi_ch_smprintf to improve the
readability of the code.
[rdn.c] This patch replaces "malloc + strcpy + strcat" with slapi_create_
dn_string to normalize the newly added rdn and improve the readability of
the code.
Reviewed by Rich (Thanks!!)
https://fedorahosted.org/389/ticket/47367
(cherry picked from commit 2f4f74b3d38eeb38f0794dfb2e880a95e7e9bd49)
(cherry picked from commit 690d58ba5870e7f0dd3ad6593c92a86771fc54d5)
diff --git a/ldap/servers/plugins/replication/repl5_init.c
b/ldap/servers/plugins/replication/repl5_init.c
index cc73f5d..b32a3b8 100644
--- a/ldap/servers/plugins/replication/repl5_init.c
+++ b/ldap/servers/plugins/replication/repl5_init.c
@@ -359,17 +359,6 @@ multimaster_betxnpreop_init( Slapi_PBlock *pb )
{
int rc= 0; /* OK */
- if( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 ||
- slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterbepreopdesc
) != 0 ||
- slapi_pblock_set( pb, SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN, (void *)
multimaster_betxnpreop_add ) != 0 ||
- slapi_pblock_set( pb, SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN, (void *)
multimaster_betxnpreop_delete ) != 0 ||
- slapi_pblock_set( pb, SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN, (void *)
multimaster_betxnpreop_modify ) != 0 ||
- slapi_pblock_set( pb, SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN, (void *)
multimaster_betxnpreop_modrdn ) != 0 )
- {
- slapi_log_error( SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_betxnpreop_init
failed\n" );
- rc= -1;
- }
-
return rc;
}
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c
b/ldap/servers/plugins/replication/repl5_plugins.c
index 01ac03c..590af7e 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -718,8 +718,7 @@ multimaster_bepreop_add (Slapi_PBlock *pb)
{
slapi_pblock_set(pb, SLAPI_TXN_RUV_MODS_FN,
(void *)replica_ruv_smods_for_op);
- if (!repl5_is_betxn && is_replicated_operation) {
- /* if is_betxn is on, urp is called at betxn preop */
+ if (is_replicated_operation) {
rc = urp_add_operation(pb);
}
}
@@ -744,8 +743,7 @@ multimaster_bepreop_delete (Slapi_PBlock *pb)
{
slapi_pblock_set(pb, SLAPI_TXN_RUV_MODS_FN,
(void *)replica_ruv_smods_for_op);
- if (!repl5_is_betxn && is_replicated_operation) {
- /* if is_betxn is on, urp is called at betxn preop */
+ if (is_replicated_operation) {
rc = urp_delete_operation(pb);
}
}
@@ -770,8 +768,7 @@ multimaster_bepreop_modify (Slapi_PBlock *pb)
{
slapi_pblock_set(pb, SLAPI_TXN_RUV_MODS_FN,
(void *)replica_ruv_smods_for_op);
- if (!repl5_is_betxn && is_replicated_operation) {
- /* if is_betxn is on, urp is called at betxn preop */
+ if (is_replicated_operation) {
rc = urp_modify_operation(pb);
}
}
@@ -799,8 +796,7 @@ multimaster_bepreop_modrdn (Slapi_PBlock *pb)
{
slapi_pblock_set(pb, SLAPI_TXN_RUV_MODS_FN,
(void *)replica_ruv_smods_for_op);
- if (!repl5_is_betxn && is_replicated_operation) {
- /* if is_betxn is on, urp is called at betxn preop */
+ if (is_replicated_operation) {
rc = urp_modrdn_operation(pb);
}
}
diff --git a/ldap/servers/plugins/replication/urp.c
b/ldap/servers/plugins/replication/urp.c
index 3d0ea82..471bf8d 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -55,9 +55,9 @@ extern int slapi_log_urp;
static int urp_add_resolve_parententry (Slapi_PBlock *pb, char *sessionid, Slapi_Entry
*entry, Slapi_Entry *parententry, CSN *opcsn);
static int urp_annotate_dn (char *sessionid, const Slapi_Entry *entry, CSN *opcsn, const
char *optype);
static int urp_naming_conflict_removal (Slapi_PBlock *pb, char *sessionid, CSN *opcsn,
const char *optype);
-static int mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn, const
Slapi_DN *conflictsdn, CSN *opcsn);
+static int mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn, const
Slapi_DN *conflictsdn, CSN *opcsn, const char *optype);
static int del_replconflict_attr (const Slapi_Entry *entry, CSN *opcsn, int opflags);
-static char *get_dn_plus_uniqueid(char *sessionid,const char *olddn,const char
*uniqueid);
+static char *get_dn_plus_uniqueid(char *sessionid,const Slapi_DN *oldsdn,const char
*uniqueid);
static char *get_rdn_plus_uniqueid(char *sessionid,const char *olddn,const char
*uniqueid);
static int is_suffix_entry (Slapi_PBlock *pb, Slapi_Entry *entry, Slapi_DN **parenddn);
@@ -184,7 +184,7 @@ urp_add_operation( Slapi_PBlock *pb )
if (r<0)
{
/* Entry to be added is a loser */
- char *newdn= get_dn_plus_uniqueid (sessionid, basedn, adduniqueid);
+ char *newdn= get_dn_plus_uniqueid (sessionid, (const Slapi_DN *)addentry,
adduniqueid);
if(newdn==NULL)
{
op_result= LDAP_OPERATIONS_ERROR;
@@ -203,7 +203,11 @@ urp_add_operation( Slapi_PBlock *pb )
Slapi_RDN *rdn;
char buf[BUFSIZ];
+#ifdef DEBUG
+ PR_snprintf(buf, BUFSIZ, "%s (add) %s", REASON_ANNOTATE_DN, basedn);
+#else
PR_snprintf(buf, BUFSIZ, "%s %s", REASON_ANNOTATE_DN, basedn);
+#endif
if (slapi_entry_attr_find (addentry, ATTR_NSDS5_REPLCONFLICT, &attr) == 0)
{
/* ATTR_NSDS5_REPLCONFLICT exists */
@@ -466,7 +470,7 @@ urp_modrdn_operation( Slapi_PBlock *pb )
Unique ID already in RDN - Change to Lost and Found entry */
goto bailout;
}
- mod_namingconflict_attr (op_uniqueid, target_sdn, existing_sdn, opcsn);
+ mod_namingconflict_attr (op_uniqueid, target_sdn, existing_sdn, opcsn,
"MODRDN");
slapi_pblock_set(pb, SLAPI_MODRDN_NEWRDN, newrdn_with_uniqueid);
slapi_log_error(slapi_log_urp, sessionid,
"urp_modrdn: Naming conflict MODRDN. Rename target entry to %s\n",
@@ -1033,7 +1037,7 @@ urp_annotate_dn (char *sessionid, const Slapi_Entry *entry, CSN
*opcsn, const ch
newrdn = get_rdn_plus_uniqueid ( sessionid, basedn, uniqueid );
if(newrdn!=NULL)
{
- mod_namingconflict_attr (uniqueid, basesdn, basesdn, opcsn);
+ mod_namingconflict_attr (uniqueid, basesdn, basesdn, opcsn, optype);
op_result = urp_fixup_rename_entry ( entry, newrdn, 0 );
switch(op_result)
{
@@ -1245,16 +1249,15 @@ bailout:
/* The returned value is either null or
"uniqueid=<uniqueid>+<basedn>" */
static char *
-get_dn_plus_uniqueid(char *sessionid, const char *olddn, const char *uniqueid)
+get_dn_plus_uniqueid(char *sessionid, const Slapi_DN *oldsdn, const char *uniqueid)
{
- Slapi_DN *sdn= slapi_sdn_new_dn_byval(olddn);
Slapi_RDN *rdn= slapi_rdn_new();
char *newdn;
PR_ASSERT(uniqueid!=NULL);
/* Check if the RDN already contains the Unique ID */
- slapi_sdn_get_rdn(sdn,rdn);
+ slapi_rdn_set_dn(rdn, slapi_sdn_get_dn(oldsdn));
if(slapi_rdn_contains(rdn,SLAPI_ATTR_UNIQUEID,uniqueid,strlen(uniqueid)))
{
/* The Unique ID is already in the RDN.
@@ -1264,16 +1267,20 @@ get_dn_plus_uniqueid(char *sessionid, const char *olddn, const
char *uniqueid)
* require admin intercession
*/
slapi_log_error(SLAPI_LOG_FATAL, sessionid,
- "Annotated DN %s has naming conflict\n", olddn );
+ "Annotated DN %s has naming conflict\n", slapi_sdn_get_dn(oldsdn) );
newdn= NULL;
}
else
{
- slapi_rdn_add(rdn,SLAPI_ATTR_UNIQUEID,uniqueid);
- slapi_sdn_set_rdn(sdn, rdn);
- newdn= slapi_ch_strdup(slapi_sdn_get_dn(sdn));
+ char *parentdn = slapi_dn_parent(slapi_sdn_get_dn(oldsdn));
+ slapi_rdn_add(rdn, SLAPI_ATTR_UNIQUEID, uniqueid);
+ /*
+ * using slapi_ch_smprintf is okay since ...
+ * uniqueid in rdn is normalized and
+ * parentdn is normalized by slapi_sdn_get_dn.
+ */
+ newdn = slapi_ch_smprintf("%s,%s", slapi_rdn_get_rdn(rdn), parentdn);
}
- slapi_sdn_free(&sdn);
slapi_rdn_free(&rdn);
return newdn;
}
@@ -1340,14 +1347,20 @@ is_suffix_dn ( Slapi_PBlock *pb, const Slapi_DN *dn, Slapi_DN
**parentdn )
static int
mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn,
- const Slapi_DN *conflictsdn, CSN *opcsn)
+ const Slapi_DN *conflictsdn, CSN *opcsn,
+ const char *optype)
{
Slapi_Mods smods;
char buf[BUFSIZ];
int op_result;
+#ifdef DEBUG
+ PR_snprintf (buf, sizeof(buf), "%s (%s) %s",
+ REASON_ANNOTATE_DN, optype, slapi_sdn_get_dn(conflictsdn));
+#else
PR_snprintf (buf, sizeof(buf), "%s %s",
REASON_ANNOTATE_DN, slapi_sdn_get_dn(conflictsdn));
+#endif
slapi_mods_init (&smods, 2);
if ( strncmp (slapi_sdn_get_dn(entrysdn), SLAPI_ATTR_UNIQUEID,
strlen(SLAPI_ATTR_UNIQUEID)) != 0 )
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c
b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 708ccfa..fa1e9bc 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -194,112 +194,6 @@ ldbm_back_add( Slapi_PBlock *pb )
}
- if (!is_tombstone_operation) {
- rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_DN_ENTRY);
- }
- rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_UNIQUEID_ENTRY);
- rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY);
- while(rc!=0)
- {
- /* JCM - copying entries can be expensive... should optimize */
- /*
- * Some present state information is passed through the PBlock to the
- * backend pre-op plugin. To ensure a consistent snapshot of this state
- * we wrap the reading of the entry with the dblock.
- */
- if(slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_UNIQUEID_ENTRY))
- {
- /* Check if an entry with the intended uniqueid already exists. */
- done_with_pblock_entry(pb,SLAPI_ADD_EXISTING_UNIQUEID_ENTRY); /* Could be through this
multiple times */
- addr.udn = NULL;
- addr.sdn = NULL;
- addr.uniqueid = (char*)slapi_entry_get_uniqueid(e); /* jcm - cast away const */
- ldap_result_code= get_copy_of_entry(pb, &addr, &txn,
SLAPI_ADD_EXISTING_UNIQUEID_ENTRY, !is_replicated_operation);
- }
- if(slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_DN_ENTRY))
- {
- slapi_pblock_get( pb, SLAPI_ADD_TARGET_SDN, &sdn );
- if (NULL == sdn)
- {
- LDAPDebug0Args(LDAP_DEBUG_ANY,
- "ldbm_back_add: Null target dn\n");
- goto error_return;
- }
-
- /* not need to check the dn syntax as this is a replicated op */
- if(!is_replicated_operation){
- dn = slapi_sdn_get_dn(sdn);
- ldap_result_code = slapi_dn_syntax_check(pb, dn, 1);
- if (ldap_result_code)
- {
- ldap_result_code = LDAP_INVALID_DN_SYNTAX;
- slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
- goto error_return;
- }
- }
-
- slapi_sdn_get_backend_parent(sdn, &parentsdn, pb->pb_backend);
- /* Check if an entry with the intended DN already exists. */
- done_with_pblock_entry(pb,SLAPI_ADD_EXISTING_DN_ENTRY); /* Could be through this
multiple times */
- addr.sdn = sdn;
- addr.udn = NULL;
- addr.uniqueid = NULL;
- ldap_result_code= get_copy_of_entry(pb, &addr, &txn,
SLAPI_ADD_EXISTING_DN_ENTRY, !is_replicated_operation);
- if(ldap_result_code==LDAP_OPERATIONS_ERROR ||
- ldap_result_code==LDAP_INVALID_DN_SYNTAX)
- {
- goto error_return;
- }
- }
- /* if we can find the parent by dn or uniqueid, and the operation has requested the
parent
- then get it */
- if(have_parent_address(&parentsdn, operation->o_params.p.p_add.parentuniqueid)
&&
- slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY))
- {
- done_with_pblock_entry(pb,SLAPI_ADD_PARENT_ENTRY); /* Could be through this multiple
times */
- addr.sdn = &parentsdn;
- addr.udn = NULL;
- addr.uniqueid = operation->o_params.p.p_add.parentuniqueid;
- ldap_result_code= get_copy_of_entry(pb, &addr, &txn, SLAPI_ADD_PARENT_ENTRY,
!is_replicated_operation);
- /* need to set parentsdn or parentuniqueid if either is not set? */
- }
-
- /* Call the Backend Pre Add plugins */
- slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- rc= plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN);
- if (rc) {
- int opreturn = 0;
- if (SLAPI_PLUGIN_NOOP == rc) {
- not_an_error = 1;
- rc = LDAP_SUCCESS;
- }
- /*
- * Plugin indicated some kind of failure,
- * or that this Operation became a No-Op.
- */
- if (!ldap_result_code) {
- slapi_pblock_get(pb, SLAPI_RESULT_CODE, &ldap_result_code);
- }
- if (!ldap_result_code) {
- LDAPDebug0Args(LDAP_DEBUG_ANY,
- "ldbm_back_add: SLAPI_PLUGIN_BE_PRE_ADD_FN returned error but did not
set SLAPI_RESULT_CODE\n");
- ldap_result_code = LDAP_OPERATIONS_ERROR;
- }
- slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &opreturn);
- if (!opreturn) {
- /* make sure opreturn is set for the postop plugins */
- slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, ldap_result_code ? &ldap_result_code
: &rc);
- }
-
- goto error_return;
- }
- /*
- * (rc!=-1 && rc!= 0) means that the plugin changed things, so we go around
- * the loop once again to get the new present state.
- */
- /* JCMREPL - Warning: A Plugin could cause an infinite loop by always returning a
result code that requires some action. */
- }
-
/*
* Originally (in the U-M LDAP 3.3 code), there was a comment near this
* code about a race condition. The race was that a 2nd entry could be
@@ -365,6 +259,113 @@ ldbm_back_add( Slapi_PBlock *pb )
if (0 == retry_count) {
/* First time, hold SERIAL LOCK */
retval = dblayer_txn_begin(be, parent_txn, &txn);
+
+ if (!is_tombstone_operation) {
+ rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_DN_ENTRY);
+ }
+
+ rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_UNIQUEID_ENTRY);
+ rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY);
+ while(rc!=0)
+ {
+ /* JCM - copying entries can be expensive... should optimize */
+ /*
+ * Some present state information is passed through the PBlock to the
+ * backend pre-op plugin. To ensure a consistent snapshot of this state
+ * we wrap the reading of the entry with the dblock.
+ */
+ if(slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_UNIQUEID_ENTRY))
+ {
+ /* Check if an entry with the intended uniqueid already exists. */
+ done_with_pblock_entry(pb,SLAPI_ADD_EXISTING_UNIQUEID_ENTRY); /* Could be through
this multiple times */
+ addr.udn = NULL;
+ addr.sdn = NULL;
+ addr.uniqueid = (char*)slapi_entry_get_uniqueid(e); /* jcm - cast away const */
+ ldap_result_code= get_copy_of_entry(pb, &addr, &txn,
SLAPI_ADD_EXISTING_UNIQUEID_ENTRY, !is_replicated_operation);
+ }
+ if(slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_EXISTING_DN_ENTRY))
+ {
+ slapi_pblock_get( pb, SLAPI_ADD_TARGET_SDN, &sdn );
+ if (NULL == sdn)
+ {
+ LDAPDebug0Args(LDAP_DEBUG_ANY,
+ "ldbm_back_add: Null target dn\n");
+ goto error_return;
+ }
+
+ /* not need to check the dn syntax as this is a replicated op */
+ if(!is_replicated_operation){
+ dn = slapi_sdn_get_dn(sdn);
+ ldap_result_code = slapi_dn_syntax_check(pb, dn, 1);
+ if (ldap_result_code)
+ {
+ ldap_result_code = LDAP_INVALID_DN_SYNTAX;
+ slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
+ goto error_return;
+ }
+ }
+
+ slapi_sdn_get_backend_parent(sdn, &parentsdn, pb->pb_backend);
+ /* Check if an entry with the intended DN already exists. */
+ done_with_pblock_entry(pb,SLAPI_ADD_EXISTING_DN_ENTRY); /* Could be through this
multiple times */
+ addr.sdn = sdn;
+ addr.udn = NULL;
+ addr.uniqueid = NULL;
+ ldap_result_code= get_copy_of_entry(pb, &addr, &txn,
SLAPI_ADD_EXISTING_DN_ENTRY, !is_replicated_operation);
+ if(ldap_result_code==LDAP_OPERATIONS_ERROR ||
+ ldap_result_code==LDAP_INVALID_DN_SYNTAX)
+ {
+ goto error_return;
+ }
+ }
+ /* if we can find the parent by dn or uniqueid, and the operation has requested the
parent
+ then get it */
+ if(have_parent_address(&parentsdn, operation->o_params.p.p_add.parentuniqueid)
&&
+ slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY))
+ {
+ done_with_pblock_entry(pb,SLAPI_ADD_PARENT_ENTRY); /* Could be through this multiple
times */
+ addr.sdn = &parentsdn;
+ addr.udn = NULL;
+ addr.uniqueid = operation->o_params.p.p_add.parentuniqueid;
+ ldap_result_code= get_copy_of_entry(pb, &addr, &txn, SLAPI_ADD_PARENT_ENTRY,
!is_replicated_operation);
+ /* need to set parentsdn or parentuniqueid if either is not set? */
+ }
+
+ /* Call the Backend Pre Add plugins */
+ slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
+ rc= plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN);
+ if (rc < 0) {
+ int opreturn = 0;
+ if (SLAPI_PLUGIN_NOOP == rc) {
+ not_an_error = 1;
+ rc = LDAP_SUCCESS;
+ }
+ /*
+ * Plugin indicated some kind of failure,
+ * or that this Operation became a No-Op.
+ */
+ if (!ldap_result_code) {
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &ldap_result_code);
+ }
+ if (!ldap_result_code) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY,
+ "ldbm_back_add: SLAPI_PLUGIN_BE_PRE_ADD_FN returned error but did not
set SLAPI_RESULT_CODE\n");
+ ldap_result_code = LDAP_OPERATIONS_ERROR;
+ }
+ slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &opreturn);
+ if (!opreturn) {
+ /* make sure opreturn is set for the postop plugins */
+ slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, ldap_result_code ?
&ldap_result_code : &rc);
+ }
+
+ goto error_return;
+ }
+ /*
+ * (rc!=-1 && rc!= 0) means that the plugin changed things, so we go around
+ * the loop once again to get the new present state.
+ */
+ /* JCMREPL - Warning: A Plugin could cause an infinite loop by always returning a
result code that requires some action. */
+ }
} else {
/* Otherwise, no SERIAL LOCK */
retval = dblayer_txn_begin_ext(li, parent_txn, &txn, PR_FALSE);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index be73e04..011c2d5 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -288,7 +288,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
/* Don't call pre-op for Tombstone entries */
if (!delete_tombstone_entry)
{
- int rc = 0;
/*
* Some present state information is passed through the PBlock to the
* backend pre-op plugin. To ensure a consistent snapshot of this state
@@ -305,12 +304,13 @@ ldbm_back_delete( Slapi_PBlock *pb )
goto error_return;
}
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
-
- rc = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_DELETE_FN);
- if (rc)
+
+ retval = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_DELETE_FN);
+ if (retval)
{
- if (SLAPI_PLUGIN_NOOP == rc) {
+ if (SLAPI_PLUGIN_NOOP == retval) {
not_an_error = 1;
+ rc = LDAP_SUCCESS;
}
/*
* Plugin indicated some kind of failure,
@@ -324,12 +324,11 @@ ldbm_back_delete( Slapi_PBlock *pb )
if (!opreturn) {
slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, ldap_result_code ?
&ldap_result_code : &rc );
}
- retval = -1;
goto error_return;
}
/* the flag could be set in a preop plugin (e.g., USN) */
delete_tombstone_entry = operation_is_flag_set(operation,
- OP_FLAG_TOMBSTONE_ENTRY);
+ OP_FLAG_TOMBSTONE_ENTRY);
}
/* call the transaction pre delete plugins just after the
@@ -363,16 +362,14 @@ ldbm_back_delete( Slapi_PBlock *pb )
*/
is_tombstone_entry = slapi_entry_flag_is_set(e->ep_entry,
SLAPI_ENTRY_FLAG_TOMBSTONE);
if (delete_tombstone_entry) {
- PR_ASSERT(is_tombstone_entry);
if (!is_tombstone_entry) {
slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
"Attempt to delete a non-tombstone entry %s\n", dn);
delete_tombstone_entry = 0;
}
} else {
- PR_ASSERT(!is_tombstone_entry);
if (is_tombstone_entry) {
- slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
+ slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
"Attempt to Tombstone again a tombstone entry %s\n", dn);
delete_tombstone_entry = 1;
}
@@ -428,7 +425,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
/* Save away a copy of the entry, before modifications */
slapi_pblock_set( pb, SLAPI_ENTRY_PRE_OP, slapi_entry_dup( e->ep_entry ));
- /* JCMACL - Shouldn't the access check be before the has children check...
+ /* JCMACL - Shouldn't the access check be before the has children check...
* otherwise we're revealing the fact that an entry exists and has children */
ldap_result_code = plugin_call_acl_plugin (pb, e->ep_entry, NULL, NULL,
SLAPI_ACL_DELETE,
ACLPLUGIN_ACCESS_DEFAULT, &errbuf );
@@ -449,12 +446,31 @@ ldbm_back_delete( Slapi_PBlock *pb )
if ( !slapi_sdn_isempty(&parentsdn) )
{
struct backentry *parent = NULL;
- entry_address parent_addr;
+ char *pid_str = slapi_entry_attr_get_charptr(e->ep_entry, LDBM_PARENTID_STR);
+ if (pid_str) {
+ /* First, try to get the direct parent. */
+ /*
+ * Although a rare case, multiple parents from repl conflict could exist.
+ * In such case, if a parent entry is found just by parentsdn
+ * (find_entry2modify_only_ext), a wrong parent could be found,
+ * and numsubordinate count could get confused.
+ */
+ ID pid = (ID)strtol(pid_str, (char **)NULL, 10);
+ parent = id2entry(be, pid ,NULL, &retval);
+ if (parent && cache_lock_entry(&inst->inst_cache, parent)) {
+ /* Failed to obtain parent entry's entry lock */
+ CACHE_RETURN(&(inst->inst_cache), &parent);
+ goto error_return;
+ }
+ }
+ if (NULL == parent) {
+ entry_address parent_addr;
- parent_addr.sdn = &parentsdn;
- parent_addr.uniqueid = NULL;
- parent = find_entry2modify_only_ext(pb, be, &parent_addr,
- TOMBSTONE_INCLUDED, &txn);
+ parent_addr.sdn = &parentsdn;
+ parent_addr.uniqueid = NULL;
+ parent = find_entry2modify_only_ext(pb, be, &parent_addr,
+ TOMBSTONE_INCLUDED, &txn);
+ }
if (NULL != parent) {
int isglue;
size_t haschildren = 0;
@@ -549,7 +565,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
slapi_value_free(&tomb_value);
/* XXXggood above used to be: slapi_entry_add_string(tombstone->ep_entry,
SLAPI_ATTR_OBJECTCLASS, SLAPI_ATTR_VALUE_TOMBSTONE); */
/* JCMREPL - Add a description of what's going on? */
-
+
if ( (original_tombstone = backentry_dup( tombstone )) == NULL ) {
ldap_result_code= LDAP_OPERATIONS_ERROR;
retval = -1;
@@ -568,6 +584,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
if (retval) {
if (SLAPI_PLUGIN_NOOP == retval) {
not_an_error = 1;
+ rc = LDAP_SUCCESS;
}
LDAPDebug1Arg( LDAP_DEBUG_TRACE,
"SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN plugin "
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index 1b74fa0..e24b43b 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -3152,6 +3152,7 @@ _entryrdn_index_read(backend *be,
/* Node might be a tombstone. */
rc = _entryrdn_get_tombstone_elem(cursor, tmpsrdn,
&key, nrdn, elem);
+ rdnidx--; /* consider nsuniqueid=..,<RDN> one RDN */
}
if (rc || NULL == *elem) {
slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
@@ -3258,6 +3259,7 @@ _entryrdn_index_read(backend *be,
}
goto bail;
}
+ rdnidx--; /* consider nsuniqueid=..,<RDN> one RDN */
} else {
slapi_ch_free((void **)&tmpelem);
if (DB_NOTFOUND != rc) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index 3682485..ed75202 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -447,7 +447,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
/* Call the Backend Pre ModRDN plugins */
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
rc= plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_MODRDN_FN);
- if (rc) {
+ if (rc < 0) {
if (SLAPI_PLUGIN_NOOP == rc) {
not_an_error = 1;
rc = LDAP_SUCCESS;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c
b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index c4d3797..76b41d5 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1608,7 +1608,7 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension
)
* just forget about it, since we don't want to return anything at all.
*/
{
if ( slapi_uniqueIDCompareString(target_uniqueid,
e->ep_entry->e_uniqueid) ||
- slapi_sdn_scope_test( backentry_get_sdn(e), basesdn, scope ))
+ slapi_sdn_scope_test_ext( backentry_get_sdn(e), basesdn, scope,
e->ep_entry->e_flags ))
{
/* check size limit */
if ( slimit >= 0 )
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index bb5973a..074f0a3 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2148,6 +2148,10 @@ slapi_sdn_set_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn)
{
/* NewDN= NewRDN + OldParent */
char *parentdn = slapi_dn_parent(slapi_sdn_get_dn(sdn));
+ /*
+ * using slapi_ch_smprintf is okay since
+ * newdn is set to sdn as a pre-normalized dn.
+ */
char *newdn = slapi_ch_smprintf("%s,%s", rawrdn, parentdn);
slapi_ch_free((void**)&parentdn);
slapi_sdn_set_dn_passin(sdn,newdn);
@@ -2170,10 +2174,11 @@ slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn)
{
/* NewDN= NewRDN + DN */
const char *dn= slapi_sdn_get_dn(sdn);
- char *newdn= slapi_ch_malloc(strlen(rawrdn)+1+strlen(dn)+1);
- strcpy( newdn, rawrdn );
- strcat( newdn, "," );
- strcat( newdn, dn );
+ /*
+ * using slapi_ch_smprintf is okay since
+ * newdn is set to sdn as a pre-normalized dn.
+ */
+ char *newdn = slapi_ch_smprintf("%s,%s", rawrdn, dn);
slapi_sdn_set_dn_passin(sdn,newdn);
}
return sdn;
@@ -2401,7 +2406,7 @@ slapi_sdn_get_backend_parent(const Slapi_DN *sdn,Slapi_DN
*sdn_parent,const Slap
void
slapi_sdn_get_rdn(const Slapi_DN *sdn,Slapi_RDN *rdn)
{
- slapi_rdn_set_dn(rdn,sdn->dn);
+ slapi_rdn_set_dn(rdn, slapi_sdn_get_dn(sdn));
}
Slapi_DN *
@@ -2572,6 +2577,47 @@ slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int
scope )
return rc;
}
+/*
+ * Return non-zero if "dn" matches the scoping criteria
+ * given by "base" and "scope".
+ * If SLAPI_ENTRY_FLAG_TOMBSTONE is set to flags,
+ * DN without "nsuniqueid=...," is examined.
+ */
+int
+slapi_sdn_scope_test_ext( const Slapi_DN *dn, const Slapi_DN *base, int scope, int flags
)
+{
+ int rc = 0;
+
+ switch ( scope ) {
+ case LDAP_SCOPE_BASE:
+ if (flags & SLAPI_ENTRY_FLAG_TOMBSTONE) {
+ Slapi_DN parent;
+ slapi_sdn_init(&parent);
+ slapi_sdn_get_parent(dn, &parent);
+ rc = ( slapi_sdn_compare( dn, &parent ) == 0 );
+ slapi_sdn_done(&parent);
+ } else {
+ rc = ( slapi_sdn_compare( dn, base ) == 0 );
+ }
+ break;
+ case LDAP_SCOPE_ONELEVEL:
+ if (flags & SLAPI_ENTRY_FLAG_TOMBSTONE) {
+ Slapi_DN parent;
+ slapi_sdn_init(&parent);
+ slapi_sdn_get_parent(dn, &parent);
+ rc = ( slapi_sdn_isparent( base, &parent ) != 0 );
+ slapi_sdn_done(&parent);
+ } else {
+ rc = ( slapi_sdn_isparent( base, dn ) != 0 );
+ }
+ break;
+ case LDAP_SCOPE_SUBTREE:
+ rc = ( slapi_sdn_issuffix( dn, base ) != 0 );
+ break;
+ }
+ return rc;
+}
+
/*
* build the new dn of an entry for moddn operations
*/
@@ -2619,8 +2665,17 @@ size_t
slapi_sdn_get_size(const Slapi_DN *sdn)
{
size_t sz = sizeof(Slapi_DN);
+ /* slapi_sdn_get_ndn_len returns the normalized dn length
+ * if dn or ndn exists. If both does not exist, it
+ * normalizes udn and set it to dn and returns the length.
+ */
sz += slapi_sdn_get_ndn_len(sdn);
- sz += strlen(sdn->dn) + 1;
+ if (sdn->dn && sdn->ndn) {
+ sz += slapi_sdn_get_ndn_len(sdn);
+ }
+ if (sdn->udn) {
+ sz += strlen(sdn->udn) + 1;
+ }
return sz;
}
diff --git a/ldap/servers/slapd/rdn.c b/ldap/servers/slapd/rdn.c
index d408f0e..fe2fae0 100644
--- a/ldap/servers/slapd/rdn.c
+++ b/ldap/servers/slapd/rdn.c
@@ -479,25 +479,17 @@ slapi_rdn_add(Slapi_RDN *rdn, const char *type, const char *value)
PR_ASSERT(NULL != value);
if(rdn->rdn==NULL)
{
- /* type=value '\0' */
- rdn->rdn= slapi_ch_malloc(strlen(type)+1+strlen(value)+1);
- strcpy( rdn->rdn, type );
- strcat( rdn->rdn, "=" );
- strcat( rdn->rdn, value );
+ /* type=value '\0' */
+ rdn->rdn = slapi_create_dn_string("%s=%s", type, value);
}
else
{
- /* type=value+rdn '\0' */
- char *newrdn= slapi_ch_malloc(strlen(type)+1+strlen(value)+1+strlen(rdn->rdn)+1);
- strcpy( newrdn, type );
- strcat( newrdn, "=" );
- strcat( newrdn, value );
- strcat( newrdn, "+" );
- strcat( newrdn, rdn->rdn );
- slapi_ch_free((void**)&rdn->rdn);
- rdn->rdn= newrdn;
- }
- slapi_unsetbit_uchar(rdn->flag,FLAG_RDNS);
+ /* type=value+rdn '\0' */
+ char *newrdn = slapi_create_dn_string("%s=%s+%s", type, value, rdn->rdn);
+ slapi_ch_free_string(&rdn->rdn);
+ rdn->rdn = newrdn;
+ }
+ slapi_unsetbit_uchar(rdn->flag,FLAG_RDNS);
return 1;
}
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index b216363..957e4ff 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -2722,6 +2722,24 @@ int slapi_sdn_get_ndn_len(const Slapi_DN *sdn);
int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope );
/**
+ * Checks if a DN is within a specified scope under a specified base DN.
+ * This api adjusts tombstoned DN when comparing with the base dn.
+ *
+ * \param dn A pointer to the \c Slapi_DN structure to test.
+ * \param base The base DN against which \c dn is going to be tested.
+ * \param scope The scope tested. Valid scopes are:
+ * \arg \c LDAP_SCOPE_BASE
+ * \arg \c LDAP_SCOPE_ONELEVEL
+ * \arg \c LDAP_SCOPE_SUBTREE
+ * \param flags 0 or SLAPI_ENTRY_FLAG_TOMBSTONE
+ * \return non-zero if \c dn matches the scoping criteria given by \c base and \c scope.
+ * \see slapi_sdn_compare()
+ * \see slapi_sdn_isparent()
+ * \see slapi_sdn_issuffix()
+ */
+int slapi_sdn_scope_test_ext( const Slapi_DN *dn, const Slapi_DN *base, int scope, int
flags );
+
+/**
* Retreives the RDN from a given DN.
*
* This function takes the DN stored in the \c Slapi_DN structure pointed to