VERSION.sh | 2
ldap/servers/plugins/acctpolicy/acct_plugin.c | 19 +-
ldap/servers/plugins/acctpolicy/acct_util.c | 6
ldap/servers/plugins/acctpolicy/acctpolicy.h | 2
ldap/servers/plugins/automember/automember.c | 130 ++++++++++++-----
ldap/servers/plugins/deref/deref.c | 4
ldap/servers/plugins/dna/dna.c | 170 ++++++++++++++--------
ldap/servers/plugins/linkedattrs/fixup_task.c | 44 ++++-
ldap/servers/plugins/linkedattrs/linked_attrs.c | 132 ++++++++++++-----
ldap/servers/plugins/mep/mep.c | 172 +++++++++++++++--------
ldap/servers/plugins/replication/urp.c | 60 +++++---
ldap/servers/plugins/replication/urp.h | 10 -
ldap/servers/plugins/replication/urp_glue.c | 12 -
ldap/servers/plugins/replication/urp_tombstone.c | 14 +
ldap/servers/plugins/retrocl/retrocl_po.c | 4
ldap/servers/plugins/uiduniq/plugin-utils.h | 6
ldap/servers/plugins/uiduniq/uid.c | 43 +++--
ldap/servers/plugins/uiduniq/utils.c | 29 ++-
ldap/servers/slapd/modify.c | 4
ldap/servers/slapd/passwd_extop.c | 4
ldap/servers/slapd/proto-slap.h | 1
ldap/servers/slapd/pw.c | 11 +
ldap/servers/slapd/pw_mgmt.c | 16 +-
ldap/servers/slapd/pw_retry.c | 26 ++-
24 files changed, 618 insertions(+), 303 deletions(-)
New commits:
commit 77fdecc3a2bf6d9ce8e545ba0746f619fb14ce84
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Jan 11 15:04:05 2012 -0700
Ticket #167 - Mixing transaction and non-transaction plugins can cause deadlock
https://fedorahosted.org/389/ticket/167
Resolves: Ticket #167
Bug Description: Mixing transaction and non-transaction plugins can cause deadlock
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Make all code that uses internal database operations be
transaction aware. This excludes code that works exclusively on the
config DSEs such as cn=schema or cn=config. This also excludes code in
a couple of areas, because of difficulty in passing in the txn handle:
1) views_entry_exists Slapi APIB functions
2) acllas.c code that does internal searching
3) cos_cache_follow_pointer()
Also allow dna, linkedattrs, automember, and mep to run as betxn plugins by
configuring the plugin config entry in the dse
Platforms tested: RHEL6 x86_64, Fedora 16
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/acctpolicy/acct_plugin.c
b/ldap/servers/plugins/acctpolicy/acct_plugin.c
index 5969bec..9c74278 100644
--- a/ldap/servers/plugins/acctpolicy/acct_plugin.c
+++ b/ldap/servers/plugins/acctpolicy/acct_plugin.c
@@ -90,7 +90,7 @@ done:
with the current time.
*/
static int
-acct_record_login( const char *dn )
+acct_record_login( const char *dn, void *txn )
{
int ldrc;
int rc = 0; /* Optimistic default */
@@ -125,6 +125,7 @@ acct_record_login( const char *dn )
slapi_modify_internal_set_pb( modpb, dn, mods, NULL, NULL,
plugin_id, SLAPI_OP_FLAG_NO_ACCESS_CHECK |
SLAPI_OP_FLAG_BYPASS_REFERRALS );
+ slapi_pblock_set( modpb, SLAPI_TXN, txn );
slapi_modify_internal_pb( modpb );
slapi_pblock_get( modpb, SLAPI_PLUGIN_INTOP_RESULT, &ldrc );
@@ -160,6 +161,7 @@ acct_bind_preop( Slapi_PBlock *pb )
int ldrc;
acctPolicy *policy = NULL;
void *plugin_id;
+ void *txn = NULL;
slapi_log_error( SLAPI_LOG_PLUGIN, PRE_PLUGIN_NAME,
"=> acct_bind_preop\n" );
@@ -180,8 +182,9 @@ acct_bind_preop( Slapi_PBlock *pb )
goto done;
}
- ldrc = slapi_search_internal_get_entry( sdn, NULL, &target_entry,
- plugin_id );
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
+ ldrc = slapi_search_internal_get_entry_ext( sdn, NULL, &target_entry,
+ plugin_id, txn );
/* There was a problem retrieving the entry */
if( ldrc != LDAP_SUCCESS ) {
@@ -194,7 +197,7 @@ acct_bind_preop( Slapi_PBlock *pb )
goto done;
}
- if( get_acctpolicy( pb, target_entry, plugin_id, &policy ) ) {
+ if( get_acctpolicy( pb, target_entry, plugin_id, &policy, txn ) ) {
slapi_log_error( SLAPI_LOG_FATAL, PRE_PLUGIN_NAME,
"Account Policy object for \"%s\" is missing\n", dn );
rc = -1;
@@ -244,6 +247,7 @@ acct_bind_postop( Slapi_PBlock *pb )
Slapi_Entry *target_entry = NULL;
acctPluginCfg *cfg;
void *plugin_id;
+ void *txn = NULL;
slapi_log_error( SLAPI_LOG_PLUGIN, POST_PLUGIN_NAME,
"=> acct_bind_postop\n" );
@@ -263,6 +267,7 @@ acct_bind_postop( Slapi_PBlock *pb )
goto done;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
cfg = get_config();
tracklogin = cfg->always_record_login;
@@ -270,8 +275,8 @@ acct_bind_postop( Slapi_PBlock *pb )
covered by an account policy to decide whether we should track */
if( tracklogin == 0 ) {
sdn = slapi_sdn_new_dn_byref( dn );
- ldrc = slapi_search_internal_get_entry( sdn, NULL, &target_entry,
- plugin_id );
+ ldrc = slapi_search_internal_get_entry_ext( sdn, NULL, &target_entry,
+ plugin_id, txn );
if( ldrc != LDAP_SUCCESS ) {
slapi_log_error( SLAPI_LOG_FATAL, POST_PLUGIN_NAME,
@@ -288,7 +293,7 @@ acct_bind_postop( Slapi_PBlock *pb )
}
if( tracklogin ) {
- rc = acct_record_login( dn );
+ rc = acct_record_login( dn, txn );
}
/* ...Any additional account policy postops go here... */
diff --git a/ldap/servers/plugins/acctpolicy/acct_util.c
b/ldap/servers/plugins/acctpolicy/acct_util.c
index 8e220c3..c421746 100644
--- a/ldap/servers/plugins/acctpolicy/acct_util.c
+++ b/ldap/servers/plugins/acctpolicy/acct_util.c
@@ -78,7 +78,7 @@ get_attr_string_val( Slapi_Entry* target_entry, char* attr_name ) {
*/
int
get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry, void *plugin_id,
- acctPolicy **policy ) {
+ acctPolicy **policy, void *txn ) {
Slapi_DN *sdn = NULL;
Slapi_Entry *policy_entry = NULL;
Slapi_Attr *attr;
@@ -114,8 +114,8 @@ get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry, void
*plugin_id,
}
sdn = slapi_sdn_new_dn_byref( policy_dn );
- ldrc = slapi_search_internal_get_entry( sdn, NULL, &policy_entry,
- plugin_id );
+ ldrc = slapi_search_internal_get_entry_ext( sdn, NULL, &policy_entry,
+ plugin_id, txn );
slapi_sdn_free( &sdn );
/* There should be a policy but it can't be retrieved; fatal error */
diff --git a/ldap/servers/plugins/acctpolicy/acctpolicy.h
b/ldap/servers/plugins/acctpolicy/acctpolicy.h
index e6f1497..0064009 100644
--- a/ldap/servers/plugins/acctpolicy/acctpolicy.h
+++ b/ldap/servers/plugins/acctpolicy/acctpolicy.h
@@ -65,7 +65,7 @@ typedef struct accountpolicy {
/* acct_util.c */
int get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry,
- void *plugin_id, acctPolicy **policy );
+ void *plugin_id, acctPolicy **policy, void *txn );
void free_acctpolicy( acctPolicy **policy );
int has_attr( Slapi_Entry* target_entry, char* attr_name,
char** val );
diff --git a/ldap/servers/plugins/automember/automember.c
b/ldap/servers/plugins/automember/automember.c
index 1195a15..c5e5667 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -84,9 +84,9 @@ static int automember_add_pre_op(Slapi_PBlock *pb);
/*
* Config cache management functions
*/
-static int automember_load_config();
+static int automember_load_config(Slapi_PBlock *pb);
static void automember_delete_config();
-static int automember_parse_config_entry(Slapi_Entry * e, int apply);
+static int automember_parse_config_entry(Slapi_Entry * e, int apply, Slapi_PBlock *pb);
static void automember_free_config_entry(struct configEntry ** entry);
/*
@@ -103,9 +103,9 @@ static struct automemberRegexRule *automember_parse_regex_rule(char
*rule_string
static void automember_free_regex_rule(struct automemberRegexRule *rule);
static int automember_parse_grouping_attr(char *value, char **grouping_attr,
char **grouping_value);
-static void automember_update_membership(struct configEntry *config, Slapi_Entry *e);
+static void automember_update_membership(struct configEntry *config, Slapi_Entry *e, void
*txn);
static void automember_add_member_value(Slapi_Entry *member_e, const char *group_dn,
- char *grouping_attr, char *grouping_value);
+ char *grouping_attr, char *grouping_value, void *txn);
/*
* Config cache locking functions
@@ -156,6 +156,7 @@ automember_get_plugin_sdn()
return _PluginDN;
}
+static int plugin_is_betxn = 0;
/*
* Plug-in initialization functions
@@ -165,10 +166,25 @@ automember_init(Slapi_PBlock *pb)
{
int status = 0;
char *plugin_identity = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int preadd = SLAPI_PLUGIN_PRE_ADD_FN;
+ int premod = SLAPI_PLUGIN_PRE_MODIFY_FN;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_init\n");
+ /* get args */
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0)
&&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry,
"nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ plugin_is_betxn = 1;
+ preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
+ premod = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
/* Store the plugin identity for later use.
* Used for internal operations. */
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
@@ -184,10 +200,14 @@ automember_init(Slapi_PBlock *pb)
(void *) automember_close) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
- (void *) automember_mod_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
- (void *) automember_add_pre_op) != 0 ||
+ slapi_pblock_set(pb, premod, (void *) automember_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, preadd, (void *) automember_add_pre_op) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
+ "automember_init: failed to register plugin\n");
+ status = -1;
+ }
+
+ if (!plugin_is_betxn && !status &&
slapi_register_plugin("internalpostoperation", /* op type */
1, /* Enabled */
"automember_init", /* this function
desc */
@@ -195,19 +215,30 @@ automember_init(Slapi_PBlock *pb)
AUTOMEMBER_INT_POSTOP_DESC, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
- ) ||
- slapi_register_plugin("postoperation", /* op type */
- 1, /* Enabled */
- "automember_init", /* this function desc */
- automember_postop_init, /* init func for post op */
- AUTOMEMBER_POSTOP_DESC, /* plugin desc */
- NULL, /* ? */
- plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
+ "automember_init: failed to register internalpostoperation
plugin\n");
+ status = -1;
+ }
+
+ if (!status) {
+ plugin_type = "postoperation";
+ if (plugin_is_betxn) {
+ plugin_type = "betxnpostoperation";
+ }
+ if (slapi_register_plugin(plugin_type, /* op type */
+ 1, /* Enabled */
+ "automember_init", /* this function desc
*/
+ automember_postop_init, /* init func for post op */
+ AUTOMEMBER_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
)
) {
slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
- "automember_init: failed to register plugin\n");
+ "automember_init: failed to register postop
plugin\n");
status = -1;
+ }
}
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
@@ -215,6 +246,7 @@ automember_init(Slapi_PBlock *pb)
return status;
}
+/* not used when using plugin as a betxn plugin - betxn plugins are called for both
internal and external ops */
static int
automember_internal_postop_init(Slapi_PBlock *pb)
{
@@ -244,19 +276,26 @@ static int
automember_postop_init(Slapi_PBlock *pb)
{
int status = 0;
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ if (plugin_is_betxn) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- (void *) automember_add_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- (void *) automember_del_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- (void *) automember_mod_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- (void *) automember_modrdn_post_op) != 0) {
+ slapi_pblock_set(pb, addfn, (void *) automember_add_post_op) != 0 ||
+ slapi_pblock_set(pb, delfn, (void *) automember_del_post_op) != 0 ||
+ slapi_pblock_set(pb, modfn, (void *) automember_mod_post_op) != 0 ||
+ slapi_pblock_set(pb, mdnfn, (void *) automember_modrdn_post_op) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"automember_postop_init: failed to register
plugin\n");
status = -1;
@@ -319,7 +358,7 @@ automember_start(Slapi_PBlock * pb)
g_automember_config = (PRCList *)slapi_ch_calloc(1, sizeof(struct configEntry));
PR_INIT_CLIST(g_automember_config);
- if (automember_load_config() != 0) {
+ if (automember_load_config(pb) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"automember_start: unable to load plug-in
configuration\n");
return -1;
@@ -391,13 +430,14 @@ automember_get_config()
* Parse and load the config entries.
*/
static int
-automember_load_config()
+automember_load_config(Slapi_PBlock *pb)
{
int status = 0;
int result;
int i;
Slapi_PBlock *search_pb;
Slapi_Entry **entries = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_load_config\n");
@@ -406,6 +446,7 @@ automember_load_config()
automember_config_write_lock();
automember_delete_config();
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
search_pb = slapi_pblock_new();
/* If an alternate config area is configured, find
@@ -432,6 +473,7 @@ automember_load_config()
NULL, 0, NULL, NULL, automember_get_plugin_id(),
0);
}
+ slapi_pblock_set(search_pb, SLAPI_TXN, txn);
slapi_search_internal_pb(search_pb);
slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -458,7 +500,7 @@ automember_load_config()
/* We don't care about the status here because we may have
* some invalid config entries, but we just want to continue
* looking for valid ones. */
- automember_parse_config_entry(entries[i], 1);
+ automember_parse_config_entry(entries[i], 1, pb);
}
cleanup:
@@ -482,7 +524,7 @@ automember_load_config()
* Returns 0 if the entry is valid and -1 if it is invalid.
*/
static int
-automember_parse_config_entry(Slapi_Entry * e, int apply)
+automember_parse_config_entry(Slapi_Entry * e, int apply, Slapi_PBlock *pb)
{
char *value = NULL;
char **values = NULL;
@@ -497,6 +539,7 @@ automember_parse_config_entry(Slapi_Entry * e, int apply)
int entry_added = 0;
int i = 0;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_parse_config_entry\n");
@@ -529,6 +572,7 @@ automember_parse_config_entry(Slapi_Entry * e, int apply)
goto bail;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
value = slapi_entry_get_ndn(e);
if (value) {
entry->dn = slapi_ch_strdup(value);
@@ -621,6 +665,7 @@ automember_parse_config_entry(Slapi_Entry * e, int apply)
slapi_search_internal_set_pb(search_pb, entry->dn, LDAP_SCOPE_SUBTREE,
AUTOMEMBER_REGEX_RULE_FILTER, NULL, 0, NULL,
NULL, automember_get_plugin_id(), 0);
+ slapi_pblock_set(search_pb, SLAPI_TXN, txn);
slapi_search_internal_pb(search_pb);
slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1302,7 +1347,7 @@ automember_parse_grouping_attr(char *value, char **grouping_attr,
char **groupin
* the rules in config, then performs the updates.
*/
static void
-automember_update_membership(struct configEntry *config, Slapi_Entry *e)
+automember_update_membership(struct configEntry *config, Slapi_Entry *e, void *txn)
{
PRCList *rule = NULL;
struct automemberRegexRule *curr_rule = NULL;
@@ -1456,14 +1501,14 @@ automember_update_membership(struct configEntry *config,
Slapi_Entry *e)
/* Add to each default group. */
for (i = 0; config->default_groups && config->default_groups[i];
i++) {
automember_add_member_value(e, config->default_groups[i],
- config->grouping_attr,
config->grouping_value);
+ config->grouping_attr,
config->grouping_value, txn);
}
} else {
/* Update the target groups. */
dnitem = (struct automemberDNListItem *)PR_LIST_HEAD(&targets);
while ((PRCList *)dnitem != &targets) {
automember_add_member_value(e, slapi_sdn_get_dn(dnitem->dn),
- config->grouping_attr,
config->grouping_value);
+ config->grouping_attr,
config->grouping_value, txn);
dnitem = (struct automemberDNListItem *)PR_NEXT_LINK((PRCList *)dnitem);
}
}
@@ -1491,7 +1536,7 @@ automember_update_membership(struct configEntry *config, Slapi_Entry
*e)
*/
static void
automember_add_member_value(Slapi_Entry *member_e, const char *group_dn,
- char *grouping_attr, char *grouping_value)
+ char *grouping_attr, char *grouping_value, void *txn)
{
Slapi_PBlock *mod_pb = slapi_pblock_new();
int result = LDAP_SUCCESS;
@@ -1527,6 +1572,7 @@ automember_add_member_value(Slapi_Entry *member_e, const char
*group_dn,
slapi_modify_internal_set_pb(mod_pb, group_dn,
mods, 0, 0, automember_get_plugin_id(), 0);
+ slapi_pblock_set(mod_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1573,6 +1619,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
int free_entry = 0;
char *errstr = NULL;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_pre_op\n");
@@ -1584,6 +1631,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
if (0 == (sdn = automember_get_sdn(pb)))
goto bail;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (automember_dn_is_config(sdn)) {
/* Validate config changes, but don't apply them.
* This allows us to reject invalid config changes
@@ -1602,7 +1650,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
/* Fetch the entry being modified so we can
* create the resulting entry for validation. */
if (sdn) {
- slapi_search_internal_get_entry(sdn, 0, &e,
automember_get_plugin_id());
+ slapi_search_internal_get_entry_ext(sdn, 0, &e,
automember_get_plugin_id(), txn);
free_entry = 1;
}
@@ -1630,7 +1678,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
goto bail;
}
- if (automember_parse_config_entry(e, 0) != 0) {
+ if (automember_parse_config_entry(e, 0, pb) != 0) {
/* Refuse the operation if config parsing failed. */
ret = LDAP_UNWILLING_TO_PERFORM;
if (LDAP_CHANGETYPE_ADD == modop) {
@@ -1700,7 +1748,7 @@ automember_mod_post_op(Slapi_PBlock *pb)
if (automember_oktodo(pb) && (sdn = automember_get_sdn(pb))) {
/* Check if the config is being modified and reload if so. */
if (automember_dn_is_config(sdn)) {
- automember_load_config();
+ automember_load_config(pb);
}
}
@@ -1718,6 +1766,7 @@ automember_add_post_op(Slapi_PBlock *pb)
Slapi_DN *sdn = NULL;
struct configEntry *config = NULL;
PRCList *list = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"--> automember_add_post_op\n");
@@ -1729,7 +1778,7 @@ automember_add_post_op(Slapi_PBlock *pb)
/* Reload config if a config entry was added. */
if ((sdn = automember_get_sdn(pb))) {
if (automember_dn_is_config(sdn)) {
- automember_load_config();
+ automember_load_config(pb);
}
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, AUTOMEMBER_PLUGIN_SUBSYSTEM,
@@ -1743,6 +1792,7 @@ automember_add_post_op(Slapi_PBlock *pb)
return 0;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Get the newly added entry. */
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &e);
@@ -1776,7 +1826,7 @@ automember_add_post_op(Slapi_PBlock *pb)
if (slapi_dn_issuffix(slapi_sdn_get_dn(sdn), config->scope)
&&
(slapi_filter_test_simple(e, config->filter) == 0)) {
/* Find out what membership changes are needed and make them. */
- automember_update_membership(config, e);
+ automember_update_membership(config, e, txn);
}
list = PR_NEXT_LINK(list);
@@ -1817,7 +1867,7 @@ automember_del_post_op(Slapi_PBlock *pb)
/* Reload config if a config entry was deleted. */
if ((sdn = automember_get_sdn(pb))) {
if (automember_dn_is_config(sdn))
- automember_load_config();
+ automember_load_config(pb);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"automember_del_post_op: Error "
@@ -1865,7 +1915,7 @@ automember_modrdn_post_op(Slapi_PBlock *pb)
if ((old_sdn = automember_get_sdn(pb))) {
if (automember_dn_is_config(old_sdn) || automember_dn_is_config(new_sdn))
- automember_load_config();
+ automember_load_config(pb);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, AUTOMEMBER_PLUGIN_SUBSYSTEM,
"automember_modrdn_post_op: Error "
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
index fb6a54a..86055b2 100644
--- a/ldap/servers/plugins/deref/deref.c
+++ b/ldap/servers/plugins/deref/deref.c
@@ -594,6 +594,7 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char
*derefdn,
Slapi_PBlock *derefpb = NULL;
Slapi_Entry **entries = NULL;
int rc;
+ void *txn = NULL;
if (deref_check_access(pb, NULL, derefdn, attrs, &retattrs,
(SLAPI_ACL_SEARCH|SLAPI_ACL_READ))) {
@@ -604,10 +605,11 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const
char *derefdn,
}
derefpb = slapi_pblock_new();
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_search_internal_set_pb(derefpb, derefdn, LDAP_SCOPE_BASE,
"(objectclass=*)", retattrs, 0,
NULL, NULL, deref_get_plugin_id(), 0);
-
+ slapi_pblock_set(derefpb, SLAPI_TXN, txn);
slapi_search_internal_pb(derefpb);
slapi_pblock_get(derefpb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
if (LDAP_SUCCESS == rc) {
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 858a0d7..32b6d11 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -230,15 +230,15 @@ static char *dna_get_dn(Slapi_PBlock * pb);
static Slapi_DN *dna_get_sdn(Slapi_PBlock * pb);
static int dna_dn_is_config(char *dn);
static int dna_get_next_value(struct configEntry * config_entry,
- char **next_value_ret);
+ char **next_value_ret, void *txn);
static int dna_first_free_value(struct configEntry *config_entry,
- PRUint64 *newval);
-static int dna_fix_maxval(struct configEntry *config_entry);
+ PRUint64 *newval, void *txn);
+static int dna_fix_maxval(struct configEntry *config_entry, void *txn);
static void dna_notice_allocation(struct configEntry *config_entry,
- PRUint64 new, PRUint64 last, int fix);
-static int dna_update_shared_config(struct configEntry * config_entry);
+ PRUint64 new, PRUint64 last, int fix, void *txn);
+static int dna_update_shared_config(struct configEntry * config_entry, void *txn);
static void dna_update_config_event(time_t event_time, void *arg);
-static int dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers);
+static int dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers,
void *txn);
static void dna_free_shared_server(struct dnaServer **server);
static void dna_delete_shared_servers(PRCList **servers);
static int dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper);
@@ -247,8 +247,8 @@ static int dna_request_range(struct configEntry *config_entry,
PRUint64 *lower, PRUint64 *upper);
static struct berval *dna_create_range_request(char *range_dn);
static int dna_update_next_range(struct configEntry *config_entry,
- PRUint64 lower, PRUint64 upper);
-static int dna_activate_next_range(struct configEntry *config_entry);
+ PRUint64 lower, PRUint64 upper, void *txn);
+static int dna_activate_next_range(struct configEntry *config_entry, void *txn);
static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn);
static int dna_get_replica_bind_creds(char *range_dn, struct dnaServer *server,
char **bind_dn, char **bind_passwd,
@@ -341,6 +341,8 @@ const char *getPluginDN()
return _PluginDN;
}
+static int plugin_is_betxn = 0;
+
/*
dna_init
-------------
@@ -351,11 +353,25 @@ dna_init(Slapi_PBlock *pb)
{
int status = DNA_SUCCESS;
char *plugin_identity = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int preadd = SLAPI_PLUGIN_PRE_ADD_FN;
+ int premod = SLAPI_PLUGIN_PRE_MODIFY_FN;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_init\n");
- /**
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0)
&&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry,
"nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ plugin_is_betxn = 1;
+ preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
+ premod = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
+ /**
* Store the plugin identity for later use.
* Used for internal operations
*/
@@ -372,10 +388,14 @@ dna_init(Slapi_PBlock *pb)
(void *) dna_close) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
- (void *) dna_mod_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
- (void *) dna_add_pre_op) != 0 ||
+ slapi_pblock_set(pb, premod, (void *) dna_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, preadd, (void *) dna_add_pre_op) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_init: failed to register plugin\n");
+ status = DNA_FAILURE;
+ }
+
+ if ((status == DNA_SUCCESS) && !plugin_is_betxn &&
/* internal preoperation */
slapi_register_plugin("internalpreoperation", /* op type */
1, /* Enabled */
@@ -384,16 +404,32 @@ dna_init(Slapi_PBlock *pb)
DNA_INT_PREOP_DESC, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
- ) ||
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_init: failed to register internalpreoperation
plugin\n");
+ status = DNA_FAILURE;
+ }
+ if (status == DNA_SUCCESS) {
+ plugin_type = "postoperation";
+ if (plugin_is_betxn) {
+ plugin_type = "betxnpostoperation";
+ }
/* the config change checking post op */
- slapi_register_plugin("postoperation", /* op type */
- 1, /* Enabled */
- "dna_init", /* this function desc */
- dna_postop_init, /* init func for post op */
- DNA_POSTOP_DESC, /* plugin desc */
- NULL, /* ? */
- plugin_identity /* access control */
- ) ||
+ if (slapi_register_plugin(plugin_type, /* op type */
+ 1, /* Enabled */
+ "dna_init", /* this function desc */
+ dna_postop_init, /* init func for post op */
+ DNA_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_init: failed to register postop plugin\n");
+ status = DNA_FAILURE;
+ }
+ }
+
+ if ((status == DNA_SUCCESS) &&
/* the range extension extended operation */
slapi_register_plugin("extendedop", /* op type */
1, /* Enabled */
@@ -414,6 +450,7 @@ dna_init(Slapi_PBlock *pb)
return status;
}
+/* not used when using plugin as a betxn plugin - betxn plugins are called for both
internal and external ops */
static int
dna_internal_preop_init(Slapi_PBlock *pb)
{
@@ -437,19 +474,26 @@ static int
dna_postop_init(Slapi_PBlock *pb)
{
int status = DNA_SUCCESS;
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ if (plugin_is_betxn) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- (void *) dna_config_check_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- (void *) dna_config_check_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- (void *) dna_config_check_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- (void *) dna_config_check_post_op) != 0) {
+ slapi_pblock_set(pb, addfn, (void *) dna_config_check_post_op) != 0 ||
+ slapi_pblock_set(pb, mdnfn, (void *) dna_config_check_post_op) != 0 ||
+ slapi_pblock_set(pb, delfn, (void *) dna_config_check_post_op) != 0 ||
+ slapi_pblock_set(pb, modfn, (void *) dna_config_check_post_op) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_postop_init: failed to register plugin\n");
status = DNA_FAILURE;
@@ -1263,7 +1307,7 @@ dna_update_config_event(time_t event_time, void *arg)
slapi_delete_internal_pb(pb);
/* Now force the entry to be recreated */
- dna_update_shared_config(config_entry);
+ dna_update_shared_config(config_entry, NULL);
slapi_unlock_mutex(config_entry->lock);
slapi_pblock_init(pb);
@@ -1291,7 +1335,7 @@ bail:
* The lock for configEntry should be obtained
* before calling this function.
*/
-static int dna_fix_maxval(struct configEntry *config_entry)
+static int dna_fix_maxval(struct configEntry *config_entry, void *txn)
{
PRCList *servers = NULL;
PRCList *server = NULL;
@@ -1306,7 +1350,7 @@ static int dna_fix_maxval(struct configEntry *config_entry)
/* If we already have a next range we only need
* to activate it. */
if (config_entry->next_range_lower != 0) {
- ret = dna_activate_next_range(config_entry);
+ ret = dna_activate_next_range(config_entry, txn);
if (ret != 0) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_fix_maxval: Unable to activate the "
@@ -1315,7 +1359,7 @@ static int dna_fix_maxval(struct configEntry *config_entry)
} else if (config_entry->shared_cfg_base) {
/* Find out if there are any other servers to request
* range from. */
- dna_get_shared_servers(config_entry, &servers);
+ dna_get_shared_servers(config_entry, &servers, txn);
if (servers) {
/* We have other servers we can try to extend
@@ -1330,7 +1374,7 @@ static int dna_fix_maxval(struct configEntry *config_entry)
} else {
/* Someone provided us with a new range. Attempt
* to update the config. */
- if ((ret = dna_update_next_range(config_entry, lower, upper)) == 0)
{
+ if ((ret = dna_update_next_range(config_entry, lower, upper, txn)) ==
0) {
break;
}
}
@@ -1362,7 +1406,7 @@ bail:
* this function. */
static void
dna_notice_allocation(struct configEntry *config_entry, PRUint64 new,
- PRUint64 last, int fix)
+ PRUint64 last, int fix, void *txn)
{
/* update our cached config entry */
if ((new != 0) && (new <= (config_entry->maxval +
config_entry->interval))) {
@@ -1376,7 +1420,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64
new,
* new active range. */
if (config_entry->next_range_lower != 0) {
/* Make the next range active */
- if (dna_activate_next_range(config_entry) != 0) {
+ if (dna_activate_next_range(config_entry, txn) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_notice_allocation: Unable to activate "
"the next range for range %s.\n",
config_entry->dn);
@@ -1384,7 +1428,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64
new,
} else {
config_entry->remaining = 0;
/* update the shared configuration */
- dna_update_shared_config(config_entry);
+ dna_update_shared_config(config_entry, txn);
}
} else {
if (config_entry->next_range_lower != 0) {
@@ -1397,7 +1441,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64
new,
}
/* update the shared configuration */
- dna_update_shared_config(config_entry);
+ dna_update_shared_config(config_entry, txn);
}
/* Check if we passed the threshold and try to fix maxval if so. We
@@ -1409,7 +1453,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64
new,
config_entry->threshold, config_entry->dn,
config_entry->remaining);
/* Only attempt to fix maxval if the fix flag is set. */
if (fix != 0) {
- dna_fix_maxval(config_entry);
+ dna_fix_maxval(config_entry, txn);
}
}
@@ -1417,7 +1461,7 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64
new,
}
static int
-dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
+dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers, void *txn)
{
int ret = LDAP_SUCCESS;
Slapi_PBlock *pb = NULL;
@@ -1442,6 +1486,7 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList
**servers)
LDAP_SCOPE_ONELEVEL, "objectclass=*",
attrs, 0, NULL,
NULL, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -1826,7 +1871,7 @@ static LDAPControl *dna_build_sort_control(const char *attr)
* maximum configured value for this range. */
static int
dna_first_free_value(struct configEntry *config_entry,
- PRUint64 *newval)
+ PRUint64 *newval, void *txn)
{
Slapi_Entry **entries = NULL;
Slapi_PBlock *pb = NULL;
@@ -1894,6 +1939,7 @@ dna_first_free_value(struct configEntry *config_entry,
LDAP_SCOPE_SUBTREE, filter,
config_entry->types, 0, ctrls,
NULL, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1933,6 +1979,7 @@ dna_first_free_value(struct configEntry *config_entry,
config_entry->types, 0, 0,
NULL, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2006,7 +2053,7 @@ cleanup:
* Return the next value to be assigned
*/
static int dna_get_next_value(struct configEntry *config_entry,
- char **next_value_ret)
+ char **next_value_ret, void *txn)
{
Slapi_PBlock *pb = NULL;
LDAPMod mod_replace;
@@ -2026,12 +2073,12 @@ static int dna_get_next_value(struct configEntry *config_entry,
slapi_lock_mutex(config_entry->lock);
/* get the first value */
- ret = dna_first_free_value(config_entry, &setval);
+ ret = dna_first_free_value(config_entry, &setval, txn);
if (LDAP_SUCCESS != ret) {
/* check if we overflowed the configured range */
if (setval > config_entry->maxval) {
/* try for a new range or fail */
- ret = dna_fix_maxval(config_entry);
+ ret = dna_fix_maxval(config_entry, txn);
if (LDAP_SUCCESS != ret) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
"dna_get_next_value: no more values
available!!\n");
@@ -2039,7 +2086,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
}
/* get the first value from our newly extended range */
- ret = dna_first_free_value(config_entry, &setval);
+ ret = dna_first_free_value(config_entry, &setval, txn);
if (LDAP_SUCCESS != ret)
goto done;
} else {
@@ -2076,6 +2123,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
slapi_modify_internal_set_pb(pb, config_entry->dn,
mods, 0, 0, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -2090,7 +2138,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
}
/* update our cached config */
- dna_notice_allocation(config_entry, nextval, setval, 1);
+ dna_notice_allocation(config_entry, nextval, setval, 1, txn);
}
done:
@@ -2116,7 +2164,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
* before calling this function.
* */
static int
-dna_update_shared_config(struct configEntry * config_entry)
+dna_update_shared_config(struct configEntry * config_entry, void *txn)
{
int ret = LDAP_SUCCESS;
@@ -2148,7 +2196,7 @@ dna_update_shared_config(struct configEntry * config_entry)
} else {
slapi_modify_internal_set_pb(pb, config_entry->shared_cfg_dn,
mods, NULL, NULL, getPluginID(), 0);
-
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -2176,6 +2224,7 @@ dna_update_shared_config(struct configEntry * config_entry)
/* e will be consumed by slapi_add_internal() */
slapi_add_entry_internal_set_pb(pb, e, NULL, getPluginID(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
}
@@ -2205,7 +2254,7 @@ dna_update_shared_config(struct configEntry * config_entry)
*/
static int
dna_update_next_range(struct configEntry *config_entry,
- PRUint64 lower, PRUint64 upper)
+ PRUint64 lower, PRUint64 upper, void *txn)
{
Slapi_PBlock *pb = NULL;
LDAPMod mod_replace;
@@ -2236,7 +2285,7 @@ dna_update_next_range(struct configEntry *config_entry,
slapi_modify_internal_set_pb(pb, config_entry->dn,
mods, 0, 0, getPluginID(), 0);
-
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -2252,7 +2301,7 @@ dna_update_next_range(struct configEntry *config_entry,
/* update the cached config and the shared config */
config_entry->next_range_lower = lower;
config_entry->next_range_upper = upper;
- dna_notice_allocation(config_entry, 0, 0, 0);
+ dna_notice_allocation(config_entry, 0, 0, 0, txn);
}
bail:
@@ -2269,7 +2318,7 @@ bail:
* be obtained before calling this function.
*/
static int
-dna_activate_next_range(struct configEntry *config_entry)
+dna_activate_next_range(struct configEntry *config_entry, void *txn)
{
Slapi_PBlock *pb = NULL;
LDAPMod mod_maxval;
@@ -2318,7 +2367,7 @@ dna_activate_next_range(struct configEntry *config_entry)
slapi_modify_internal_set_pb(pb, config_entry->dn,
mods, 0, 0, getPluginID(), 0);
-
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -2339,7 +2388,7 @@ dna_activate_next_range(struct configEntry *config_entry)
config_entry->remaining = ((config_entry->maxval - config_entry->nextval
+ 1) /
config_entry->interval);
/* update the shared configuration */
- dna_update_shared_config(config_entry);
+ dna_update_shared_config(config_entry, txn);
}
bail:
@@ -2781,6 +2830,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
char *errstr = NULL;
int i = 0;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
"--> dna_pre_op\n");
@@ -2792,6 +2842,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
if (0 == (dn = dna_get_dn(pb)))
goto bail;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (LDAP_CHANGETYPE_ADD == modtype) {
slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
} else {
@@ -2808,7 +2859,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
*/
Slapi_DN *tmp_dn = dna_get_sdn(pb);
if (tmp_dn) {
- slapi_search_internal_get_entry(tmp_dn, 0, &e, getPluginID());
+ slapi_search_internal_get_entry_ext(tmp_dn, 0, &e, getPluginID(), txn);
free_entry = 1;
}
@@ -3047,7 +3098,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype)
int len;
/* create the value to add */
- ret = dna_get_next_value(config_entry, &value);
+ ret = dna_get_next_value(config_entry, &value, txn);
if (DNA_SUCCESS != ret) {
errstr = slapi_ch_smprintf("Allocation of a new value for
range"
" %s failed! Unable to
proceed.",
@@ -3420,7 +3471,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
/* Try to set the new next range in the config */
ret = dna_update_next_range(config_entry,
config_entry->next_range_lower,
- *lower - 1);
+ *lower - 1, NULL);
} else {
/* We release up to half of our remaining values,
* but we'll only release a range that is a multiple
@@ -3457,7 +3508,6 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
slapi_modify_internal_set_pb(pb, config_entry->dn,
mods, 0, 0, getPluginID(), 0);
-
slapi_modify_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
@@ -3468,7 +3518,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
if (ret == LDAP_SUCCESS) {
/* Adjust maxval in our cached config and shared config */
config_entry->maxval = *lower - 1;
- dna_notice_allocation(config_entry, config_entry->nextval, 0, 0);
+ dna_notice_allocation(config_entry, config_entry->nextval, 0, 0,
NULL);
}
}
diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c
b/ldap/servers/plugins/linkedattrs/fixup_task.c
index d5d0b14..ef2c7e0 100644
--- a/ldap/servers/plugins/linkedattrs/fixup_task.c
+++ b/ldap/servers/plugins/linkedattrs/fixup_task.c
@@ -48,7 +48,7 @@
*/
static void linked_attrs_fixup_task_destructor(Slapi_Task *task);
static void linked_attrs_fixup_task_thread(void *arg);
-static void linked_attrs_fixup_links(struct configEntry *config);
+static void linked_attrs_fixup_links(struct configEntry *config, void *txn);
static int linked_attrs_remove_backlinks_callback(Slapi_Entry *e, void *callback_data);
static int linked_attrs_add_backlinks_callback(Slapi_Entry *e, void *callback_data);
static const char *fetch_attr(Slapi_Entry *e, const char *attrname,
@@ -163,7 +163,7 @@ linked_attrs_fixup_task_thread(void *arg)
"Fixing up linked attribute pair (%s)\n",
config_entry->dn);
- linked_attrs_fixup_links(config_entry);
+ linked_attrs_fixup_links(config_entry, NULL);
break;
}
} else {
@@ -173,7 +173,7 @@ linked_attrs_fixup_task_thread(void *arg)
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
"Fixing up linked attribute pair (%s)\n",
config_entry->dn);
- linked_attrs_fixup_links(config_entry);
+ linked_attrs_fixup_links(config_entry, NULL);
}
list = PR_NEXT_LINK(list);
@@ -200,12 +200,19 @@ linked_attrs_fixup_task_thread(void *arg)
slapi_task_finish(task, rc);
}
+struct fixup_cb_data {
+ char *attrtype;
+ void *txn;
+ struct configEntry *config;
+};
+
static void
-linked_attrs_fixup_links(struct configEntry *config)
+linked_attrs_fixup_links(struct configEntry *config, void *txn)
{
Slapi_PBlock *pb = slapi_pblock_new();
char *del_filter = NULL;
char *add_filter = NULL;
+ struct fixup_cb_data cb_data = {NULL, NULL, NULL};
del_filter = slapi_ch_smprintf("%s=*", config->managedtype);
add_filter = slapi_ch_smprintf("%s=*", config->linktype);
@@ -218,8 +225,11 @@ linked_attrs_fixup_links(struct configEntry *config)
* within the scope and remove the managed type. */
slapi_search_internal_set_pb(pb, config->scope, LDAP_SCOPE_SUBTREE,
del_filter, 0, 0, 0, 0, linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
- slapi_search_internal_callback_pb(pb, config->managedtype, 0,
+ cb_data.attrtype = config->managedtype;
+ cb_data.txn = txn;
+ slapi_search_internal_callback_pb(pb, &cb_data, 0,
linked_attrs_remove_backlinks_callback, 0);
/* Clean out pblock for reuse. */
@@ -229,8 +239,12 @@ linked_attrs_fixup_links(struct configEntry *config)
* scope and add backlinks to the entries they point to. */
slapi_search_internal_set_pb(pb, config->scope, LDAP_SCOPE_SUBTREE,
add_filter, 0, 0, 0, 0, linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
- slapi_search_internal_callback_pb(pb, config, 0,
+ cb_data.attrtype = NULL;
+ cb_data.txn = txn;
+ cb_data.config = config;
+ slapi_search_internal_callback_pb(pb, &cb_data, 0,
linked_attrs_add_backlinks_callback, 0);
} else {
/* Loop through all non-private backend suffixes and
@@ -245,7 +259,10 @@ linked_attrs_fixup_links(struct configEntry *config)
LDAP_SCOPE_SUBTREE, del_filter,
0, 0, 0, 0,
linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
+ cb_data.attrtype = config->managedtype;
+ cb_data.txn = txn;
slapi_search_internal_callback_pb(pb, config->managedtype, 0,
linked_attrs_remove_backlinks_callback, 0);
@@ -256,8 +273,11 @@ linked_attrs_fixup_links(struct configEntry *config)
LDAP_SCOPE_SUBTREE, add_filter,
0, 0, 0, 0,
linked_attrs_get_plugin_id(), 0);
-
- slapi_search_internal_callback_pb(pb, config, 0,
+ slapi_pblock_set(pb, SLAPI_TXN, txn);
+ cb_data.attrtype = NULL;
+ cb_data.txn = txn;
+ cb_data.config = config;
+ slapi_search_internal_callback_pb(pb, &cb_data, 0,
linked_attrs_add_backlinks_callback, 0);
/* Clean out pblock for reuse. */
@@ -280,7 +300,8 @@ linked_attrs_remove_backlinks_callback(Slapi_Entry *e, void
*callback_data)
{
int rc = 0;
Slapi_DN *sdn = slapi_entry_get_sdn(e);
- char *type = (char *)callback_data;
+ struct fixup_cb_data *cb_data = (struct fixup_cb_data *)callback_data;
+ char *type = cb_data->attrtype;
Slapi_PBlock *pb = slapi_pblock_new();
char *val[1];
LDAPMod mod;
@@ -303,6 +324,7 @@ linked_attrs_remove_backlinks_callback(Slapi_Entry *e, void
*callback_data)
/* Perform the operation. */
slapi_modify_internal_set_pb_ext(pb, sdn, mods, 0, 0,
linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, cb_data->txn);
slapi_modify_internal_pb(pb);
slapi_pblock_destroy(pb);
@@ -315,7 +337,8 @@ linked_attrs_add_backlinks_callback(Slapi_Entry *e, void
*callback_data)
{
int rc = 0;
char *linkdn = slapi_entry_get_dn(e);
- struct configEntry *config = (struct configEntry *)callback_data;
+ struct fixup_cb_data *cb_data = (struct fixup_cb_data *)callback_data;
+ struct configEntry *config = cb_data->config;
Slapi_PBlock *pb = slapi_pblock_new();
int i = 0;
char **targets = NULL;
@@ -365,6 +388,7 @@ linked_attrs_add_backlinks_callback(Slapi_Entry *e, void
*callback_data)
/* Perform the modify operation. */
slapi_modify_internal_set_pb_ext(pb, targetsdn, mods, 0, 0,
linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(pb, SLAPI_TXN, cb_data->txn);
slapi_modify_internal_pb(pb);
/* Initialize the pblock so we can reuse it. */
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c
b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 5c6d462..2b5127d 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -107,13 +107,13 @@ static int linked_attrs_oktodo(Slapi_PBlock *pb);
void linked_attrs_load_array(Slapi_Value **array, Slapi_Attr *attr);
int linked_attrs_compare(const void *a, const void *b);
static void linked_attrs_add_backpointers(char *linkdn, struct configEntry *config,
- Slapi_Mod *smod);
+ Slapi_Mod *smod, void *txn);
static void linked_attrs_del_backpointers(Slapi_PBlock *pb, char *linkdn,
struct configEntry *config, Slapi_Mod *smod);
static void linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
struct configEntry *config, Slapi_Mod *smod);
static void linked_attrs_mod_backpointers(char *linkdn, char *type, char *scope,
- int modop, Slapi_ValueSet *targetvals);
+ int modop, Slapi_ValueSet *targetvals, void *txn);
/*
* Config cache locking functions
@@ -164,6 +164,7 @@ linked_attrs_get_plugin_dn()
return _PluginDN;
}
+static int plugin_is_betxn = 0;
/*
* Plug-in initialization functions
@@ -173,10 +174,24 @@ linked_attrs_init(Slapi_PBlock *pb)
{
int status = 0;
char *plugin_identity = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int preadd = SLAPI_PLUGIN_PRE_ADD_FN;
+ int premod = SLAPI_PLUGIN_PRE_MODIFY_FN;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_init\n");
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0)
&&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry,
"nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ plugin_is_betxn = 1;
+ preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
+ premod = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
/* Store the plugin identity for later use.
* Used for internal operations. */
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
@@ -192,10 +207,14 @@ linked_attrs_init(Slapi_PBlock *pb)
(void *) linked_attrs_close) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
- (void *) linked_attrs_mod_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
- (void *) linked_attrs_add_pre_op) != 0 ||
+ slapi_pblock_set(pb, premod, (void *) linked_attrs_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, preadd, (void *) linked_attrs_add_pre_op) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
+ "linked_attrs_init: failed to register plugin\n");
+ status = -1;
+ }
+
+ if (!status && !plugin_is_betxn &&
slapi_register_plugin("internalpostoperation", /* op type */
1, /* Enabled */
"linked_attrs_init", /* this function desc */
@@ -203,26 +222,37 @@ linked_attrs_init(Slapi_PBlock *pb)
LINK_INT_POSTOP_DESC, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
- ) ||
- slapi_register_plugin("postoperation", /* op type */
- 1, /* Enabled */
- "linked_attrs_init", /* this function desc */
- linked_attrs_postop_init, /* init func for post op */
- LINK_POSTOP_DESC, /* plugin desc */
- NULL, /* ? */
- plugin_identity /* access control */
- )
- ) {
+ )) {
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
- "linked_attrs_init: failed to register plugin\n");
+ "linked_attrs_init: failed to register internalpostoperation
plugin\n");
status = -1;
}
+ if (!status) {
+ plugin_type = "postoperation";
+ if (plugin_is_betxn) {
+ plugin_type = "betxnpostoperation";
+ }
+ if (slapi_register_plugin(plugin_type, /* op type */
+ 1, /* Enabled */
+ "linked_attrs_init", /* this function desc
*/
+ linked_attrs_postop_init, /* init func for post op */
+ LINK_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
+ "linked_attrs_init: failed to register postop
plugin\n");
+ status = -1;
+ }
+ }
+
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"<-- linked_attrs_init\n");
return status;
}
+/* not used when using plugin as a betxn plugin - betxn plugins are called for both
internal and external ops */
static int
linked_attrs_internal_postop_init(Slapi_PBlock *pb)
{
@@ -252,19 +282,26 @@ static int
linked_attrs_postop_init(Slapi_PBlock *pb)
{
int status = 0;
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ if (plugin_is_betxn) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- (void *) linked_attrs_add_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- (void *) linked_attrs_del_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- (void *) linked_attrs_mod_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- (void *) linked_attrs_modrdn_post_op) != 0) {
+ slapi_pblock_set(pb, addfn, (void *) linked_attrs_add_post_op) != 0 ||
+ slapi_pblock_set(pb, delfn, (void *) linked_attrs_del_post_op) != 0 ||
+ slapi_pblock_set(pb, modfn, (void *) linked_attrs_mod_post_op) != 0 ||
+ slapi_pblock_set(pb, mdnfn, (void *) linked_attrs_modrdn_post_op) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
"linked_attrs_postop_init: failed to register
plugin\n");
status = -1;
@@ -1218,13 +1255,13 @@ linked_attrs_compare(const void *a, const void *b)
*/
static void
linked_attrs_add_backpointers(char *linkdn, struct configEntry *config,
- Slapi_Mod *smod)
+ Slapi_Mod *smod, void *txn)
{
Slapi_ValueSet *vals = slapi_valueset_new();
slapi_valueset_set_from_smod(vals, smod);
linked_attrs_mod_backpointers(linkdn, config->managedtype, config->scope,
- LDAP_MOD_ADD, vals);
+ LDAP_MOD_ADD, vals, txn);
slapi_valueset_free(vals);
}
@@ -1240,6 +1277,7 @@ linked_attrs_del_backpointers(Slapi_PBlock *pb, char *linkdn,
struct configEntry *config, Slapi_Mod *smod)
{
Slapi_ValueSet *vals = NULL;
+ void *txn = NULL;
/* If no values are listed in the smod, we need to get
* a list of all of the values that were deleted by
@@ -1256,8 +1294,9 @@ linked_attrs_del_backpointers(Slapi_PBlock *pb, char *linkdn,
slapi_valueset_set_from_smod(vals, smod);
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
linked_attrs_mod_backpointers(linkdn, config->managedtype, config->scope,
- LDAP_MOD_DELETE, vals);
+ LDAP_MOD_DELETE, vals, txn);
slapi_valueset_free(vals);
}
@@ -1278,6 +1317,7 @@ linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
Slapi_Entry *post_e = NULL;
Slapi_Attr *pre_attr = 0;
Slapi_Attr *post_attr = 0;
+ void *txn = NULL;
/* Get the pre and post copy of the entry to see
* what values have been added and removed. */
@@ -1288,6 +1328,7 @@ linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
slapi_entry_attr_find(pre_e, config->linktype, &pre_attr);
slapi_entry_attr_find(post_e, config->linktype, &post_attr);
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if(pre_attr || post_attr) {
int pre_total = 0;
@@ -1374,13 +1415,13 @@ linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
/* Perform the actual updates to the target entries. */
if (delvals) {
linked_attrs_mod_backpointers(linkdn, config->managedtype,
- config->scope, LDAP_MOD_DELETE, delvals);
+ config->scope, LDAP_MOD_DELETE, delvals,
txn);
slapi_valueset_free(delvals);
}
if (addvals) {
linked_attrs_mod_backpointers(linkdn, config->managedtype,
- config->scope, LDAP_MOD_ADD, addvals);
+ config->scope, LDAP_MOD_ADD, addvals, txn);
slapi_valueset_free(addvals);
}
@@ -1396,7 +1437,7 @@ linked_attrs_replace_backpointers(Slapi_PBlock *pb, char *linkdn,
*/
static void
linked_attrs_mod_backpointers(char *linkdn, char *type,
- char *scope, int modop, Slapi_ValueSet *targetvals)
+ char *scope, int modop, Slapi_ValueSet *targetvals, void *txn)
{
char *val[2];
int i = 0;
@@ -1449,6 +1490,7 @@ linked_attrs_mod_backpointers(char *linkdn, char *type,
/* Perform the modify operation. */
slapi_modify_internal_set_pb_ext(mod_pb, targetsdn, mods, 0, 0,
linked_attrs_get_plugin_id(), 0);
+ slapi_pblock_set(mod_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mod_pb);
/* Initialize the pblock so we can reuse it. */
@@ -1482,6 +1524,7 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
int free_entry = 0;
char *errstr = NULL;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_pre_op\n");
@@ -1493,6 +1536,7 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
if (0 == (dn = linked_attrs_get_dn(pb)))
goto bail;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (linked_attrs_dn_is_config(dn)) {
/* Validate config changes, but don't apply them.
* This allows us to reject invalid config changes
@@ -1507,7 +1551,7 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
/* int free_sdn = 0; */
Slapi_DN *tmp_dn = linked_attrs_get_sdn(pb);
if (tmp_dn) {
- slapi_search_internal_get_entry(tmp_dn, 0, &e,
linked_attrs_get_plugin_id());
+ slapi_search_internal_get_entry_ext(tmp_dn, 0, &e,
linked_attrs_get_plugin_id(), txn);
free_entry = 1;
}
@@ -1579,6 +1623,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
char *dn = NULL;
struct configEntry *config = NULL;
void *caller_id = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_mod_post_op\n");
@@ -1596,6 +1641,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
/* Just return without processing */
return 0;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (linked_attrs_oktodo(pb) &&
(dn = linked_attrs_get_dn(pb))) {
@@ -1638,7 +1684,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
case LDAP_MOD_ADD:
/* Find the entries pointed to by the new
* values and add the backpointers. */
- linked_attrs_add_backpointers(dn, config, smod);
+ linked_attrs_add_backpointers(dn, config, smod, txn);
break;
case LDAP_MOD_DELETE:
/* Find the entries pointed to by the deleted
@@ -1682,6 +1728,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
{
Slapi_Entry *e = NULL;
char *dn = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_add_post_op\n");
@@ -1700,6 +1747,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
"retrieving dn\n");
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Get the newly added entry. */
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &e);
@@ -1732,7 +1780,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
slapi_lock_mutex(config->lock);
linked_attrs_mod_backpointers(dn, config->managedtype,
- config->scope, LDAP_MOD_ADD, vals);
+ config->scope, LDAP_MOD_ADD, vals,
txn);
slapi_unlock_mutex(config->lock);
@@ -1761,6 +1809,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
{
char *dn = NULL;
Slapi_Entry *e = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_del_post_op\n");
@@ -1769,6 +1818,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
if (!g_plugin_started || !linked_attrs_oktodo(pb))
return 0;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Reload config if a config entry was deleted. */
if ((dn = linked_attrs_get_dn(pb))) {
if (linked_attrs_dn_is_config(dn))
@@ -1811,7 +1861,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
slapi_lock_mutex(config->lock);
linked_attrs_mod_backpointers(dn, config->managedtype,
- config->scope, LDAP_MOD_DELETE, vals);
+ config->scope, LDAP_MOD_DELETE, vals,
txn);
slapi_unlock_mutex(config->lock);
@@ -1840,7 +1890,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
/* Delete forward link value. */
linked_attrs_mod_backpointers(dn, config->linktype,
- config->scope, LDAP_MOD_DELETE,
vals);
+ config->scope, LDAP_MOD_DELETE,
vals, txn);
slapi_unlock_mutex(config->lock);
@@ -1878,6 +1928,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
char *type = NULL;
struct configEntry *config = NULL;
int rc = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
"--> linked_attrs_modrdn_post_op\n");
@@ -1887,6 +1938,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
goto done;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Reload config if an existing config entry was renamed,
* or if the new dn brings an entry into the scope of the
* config entries. */
@@ -1939,7 +1991,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* Delete old dn value. */
linked_attrs_mod_backpointers(old_dn, config->managedtype,
- config->scope, LDAP_MOD_DELETE, vals);
+ config->scope, LDAP_MOD_DELETE, vals, txn);
slapi_unlock_mutex(config->lock);
@@ -1962,7 +2014,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* Add new dn value. */
linked_attrs_mod_backpointers(new_dn, config->managedtype,
- config->scope, LDAP_MOD_ADD, vals);
+ config->scope, LDAP_MOD_ADD, vals, txn);
slapi_unlock_mutex(config->lock);
@@ -1991,11 +2043,11 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
/* Delete old dn value. */
linked_attrs_mod_backpointers(old_dn, config->linktype,
- config->scope, LDAP_MOD_DELETE,
vals);
+ config->scope, LDAP_MOD_DELETE,
vals, txn);
/* Add new dn value. */
linked_attrs_mod_backpointers(new_dn, config->linktype,
- config->scope, LDAP_MOD_ADD, vals);
+ config->scope, LDAP_MOD_ADD, vals,
txn);
slapi_unlock_mutex(config->lock);
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index 237ef91..82acdbd 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -86,9 +86,9 @@ static int mep_modrdn_pre_op(Slapi_PBlock *pb);
/*
* Config cache management functions
*/
-static int mep_load_config();
+static int mep_load_config(Slapi_PBlock *pb);
static void mep_delete_config();
-static int mep_parse_config_entry(Slapi_Entry * e, int apply);
+static int mep_parse_config_entry(Slapi_Entry * e, int apply, Slapi_PBlock *pb);
static void mep_free_config_entry(struct configEntry ** entry);
/*
@@ -107,9 +107,9 @@ static int mep_isrepl(Slapi_PBlock *pb);
static Slapi_Entry *mep_create_managed_entry(struct configEntry *config,
Slapi_Entry *origin);
static void mep_add_managed_entry(struct configEntry *config,
- Slapi_Entry *origin);
+ Slapi_Entry *origin, void *txn);
static void mep_rename_managed_entry(Slapi_Entry *origin,
- Slapi_DN *new_dn, Slapi_DN *old_dn);
+ Slapi_DN *new_dn, Slapi_DN *old_dn, void *txn);
static Slapi_Mods *mep_get_mapped_mods(struct configEntry *config,
Slapi_Entry *origin, char **mapped_dn);
static int mep_parse_mapped_attr(char *mapping, Slapi_Entry *origin,
@@ -168,6 +168,8 @@ mep_get_plugin_sdn()
}
+static int plugin_is_betxn = 0;
+
/*
* Plug-in initialization functions
*/
@@ -176,10 +178,28 @@ mep_init(Slapi_PBlock *pb)
{
int status = 0;
char *plugin_identity = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+ int preadd = SLAPI_PLUGIN_PRE_ADD_FN;
+ int premod = SLAPI_PLUGIN_PRE_MODIFY_FN;
+ int predel = SLAPI_PLUGIN_PRE_DELETE_FN;
+ int premdn = SLAPI_PLUGIN_PRE_MODRDN_FN;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_init\n");
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0)
&&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry,
"nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ plugin_is_betxn = 1;
+ preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
+ premod = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
+ predel = SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN;
+ premdn = SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
/* Store the plugin identity for later use.
* Used for internal operations. */
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
@@ -195,14 +215,16 @@ mep_init(Slapi_PBlock *pb)
(void *) mep_close) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
- (void *) mep_mod_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
- (void *) mep_add_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_DELETE_FN,
- (void *) mep_del_pre_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODRDN_FN,
- (void *) mep_modrdn_pre_op) != 0 ||
+ slapi_pblock_set(pb, premod, (void *) mep_mod_pre_op) != 0 ||
+ slapi_pblock_set(pb, preadd, (void *) mep_add_pre_op) != 0 ||
+ slapi_pblock_set(pb, predel, (void *) mep_del_pre_op) != 0 ||
+ slapi_pblock_set(pb, premdn, (void *) mep_modrdn_pre_op) != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
+ "mep_init: failed to register plugin\n");
+ status = -1;
+ }
+
+ if (!status && !plugin_is_betxn &&
slapi_register_plugin("internalpostoperation", /* op type */
1, /* Enabled */
"mep_init", /* this function desc */
@@ -210,26 +232,34 @@ mep_init(Slapi_PBlock *pb)
MEP_INT_POSTOP_DESC, /* plugin desc */
NULL, /* ? */
plugin_identity /* access control */
- ) ||
- slapi_register_plugin("postoperation", /* op type */
- 1, /* Enabled */
- "mep_init", /* this function desc */
- mep_postop_init, /* init func for post op */
- MEP_POSTOP_DESC, /* plugin desc */
- NULL, /* ? */
- plugin_identity /* access control */
- )
- ) {
+ )) {
slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
- "mep_init: failed to register plugin\n");
+ "mep_init: failed to register internalpostoperation
plugin\n");
status = -1;
}
+ if (!status) {
+ plugin_type = plugin_is_betxn ? "betxnpostoperation" :
"postoperation";
+ if (slapi_register_plugin(plugin_type, /* op type */
+ 1, /* Enabled */
+ "mep_init", /* this function desc */
+ mep_postop_init, /* init func for post op */
+ MEP_POSTOP_DESC, /* plugin desc */
+ NULL, /* ? */
+ plugin_identity /* access control */
+ )) {
+ slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
+ "mep_init: failed to register plugin\n");
+ status = -1;
+ }
+ }
+
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"<-- mep_init\n");
return status;
}
+/* not used when using plugin as a betxn plugin - betxn plugins are called for both
internal and external ops */
static int
mep_internal_postop_init(Slapi_PBlock *pb)
{
@@ -259,19 +289,26 @@ static int
mep_postop_init(Slapi_PBlock *pb)
{
int status = 0;
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+
+ if (plugin_is_betxn) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ }
if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01) != 0 ||
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
(void *) &pdesc) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- (void *) mep_add_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- (void *) mep_del_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- (void *) mep_mod_post_op) != 0 ||
- slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- (void *) mep_modrdn_post_op) != 0) {
+ slapi_pblock_set(pb, addfn, (void *) mep_add_post_op) != 0 ||
+ slapi_pblock_set(pb, delfn, (void *) mep_del_post_op) != 0 ||
+ slapi_pblock_set(pb, modfn, (void *) mep_mod_post_op) != 0 ||
+ slapi_pblock_set(pb, mdnfn, (void *) mep_modrdn_post_op) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
"mep_postop_init: failed to register plugin\n");
status = -1;
@@ -333,7 +370,7 @@ mep_start(Slapi_PBlock * pb)
g_mep_config = (PRCList *)slapi_ch_calloc(1, sizeof(struct configEntry));
PR_INIT_CLIST(g_mep_config);
- if (mep_load_config() != 0) {
+ if (mep_load_config(pb) != 0) {
slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
"mep_start: unable to load plug-in configuration\n");
return -1;
@@ -401,13 +438,14 @@ mep_get_config()
* --- cn=etc,...
*/
static int
-mep_load_config()
+mep_load_config(Slapi_PBlock *pb)
{
int status = 0;
int result;
int i;
Slapi_PBlock *search_pb;
Slapi_Entry **entries = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_load_config\n");
@@ -442,6 +480,8 @@ mep_load_config()
NULL, 0, NULL, NULL, mep_get_plugin_id(), 0);
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
+ slapi_pblock_set(search_pb, SLAPI_TXN, txn);
slapi_search_internal_pb(search_pb);
slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -465,7 +505,7 @@ mep_load_config()
/* We don't care about the status here because we may have
* some invalid config entries, but we just want to continue
* looking for valid ones. */
- mep_parse_config_entry(entries[i], 1);
+ mep_parse_config_entry(entries[i], 1, pb);
}
cleanup:
@@ -489,7 +529,7 @@ mep_load_config()
* Returns 0 if the entry is valid and -1 if it is invalid.
*/
static int
-mep_parse_config_entry(Slapi_Entry * e, int apply)
+mep_parse_config_entry(Slapi_Entry * e, int apply, Slapi_PBlock *pb)
{
char *value;
struct configEntry *entry = NULL;
@@ -497,6 +537,7 @@ mep_parse_config_entry(Slapi_Entry * e, int apply)
PRCList *list;
int entry_added = 0;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_parse_config_entry\n");
@@ -530,6 +571,7 @@ mep_parse_config_entry(Slapi_Entry * e, int apply)
slapi_log_error(SLAPI_LOG_CONFIG, MEP_PLUGIN_SUBSYSTEM,
"----------> dn [%s]\n", entry->dn);
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Load the origin scope */
value = slapi_entry_attr_get_charptr(e, MEP_SCOPE_TYPE);
if (value) {
@@ -592,8 +634,8 @@ mep_parse_config_entry(Slapi_Entry * e, int apply)
/* Fetch the managed entry template */
template_sdn = slapi_sdn_new_dn_byref(entry->template_dn);
- slapi_search_internal_get_entry(template_sdn, 0,
- &entry->template_entry, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(template_sdn, 0,
+ &entry->template_entry, mep_get_plugin_id(), txn);
slapi_sdn_free(&template_sdn);
if (entry->template_entry == NULL) {
@@ -1178,7 +1220,7 @@ mep_create_managed_entry(struct configEntry *config, Slapi_Entry
*origin)
*/
static void
mep_add_managed_entry(struct configEntry *config,
- Slapi_Entry *origin)
+ Slapi_Entry *origin, void *txn)
{
Slapi_Entry *managed_entry = NULL;
char *managed_dn = NULL;
@@ -1208,6 +1250,7 @@ mep_add_managed_entry(struct configEntry *config,
"entry \"%s\"\n.", managed_dn,
slapi_entry_get_dn(origin));
slapi_add_entry_internal_set_pb(mod_pb, managed_entry, NULL,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mod_pb, SLAPI_TXN, txn);
slapi_add_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1253,6 +1296,7 @@ mep_add_managed_entry(struct configEntry *config,
slapi_modify_internal_set_pb_ext(mod_pb,
slapi_entry_get_sdn(origin),
mods, 0, 0, mep_get_plugin_id(), 0);
+ slapi_pblock_set(mod_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mod_pb);
slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1277,7 +1321,7 @@ mep_add_managed_entry(struct configEntry *config,
*/
static void
mep_rename_managed_entry(Slapi_Entry *origin,
- Slapi_DN *new_dn, Slapi_DN *old_dn)
+ Slapi_DN *new_dn, Slapi_DN *old_dn, void *txn)
{
Slapi_RDN *srdn = slapi_rdn_new();
Slapi_PBlock *mep_pb = slapi_pblock_new();
@@ -1298,6 +1342,7 @@ mep_rename_managed_entry(Slapi_Entry *origin,
slapi_rename_internal_set_pb_ext(mep_pb, old_dn,
slapi_rdn_get_rdn(srdn),
NULL, 1, NULL, NULL, mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modrdn_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1326,6 +1371,7 @@ mep_rename_managed_entry(Slapi_Entry *origin,
vals[0], slapi_entry_get_dn(origin));
slapi_modify_internal_set_pb_ext(mep_pb, slapi_entry_get_sdn(origin),
mods, 0, 0, mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -1744,6 +1790,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
struct configEntry *config = NULL;
void *caller_id = NULL;
int ret = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_pre_op\n");
@@ -1758,6 +1805,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
if (0 == (sdn = mep_get_sdn(pb)))
goto bail;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (mep_dn_is_config(sdn)) {
/* Validate config changes, but don't apply them.
* This allows us to reject invalid config changes
@@ -1771,7 +1819,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
/* Fetch the entry being modified so we can
* create the resulting entry for validation. */
if (sdn) {
- slapi_search_internal_get_entry(sdn, 0, &e, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(sdn, 0, &e, mep_get_plugin_id(),
txn);
free_entry = 1;
}
@@ -1800,7 +1848,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
goto bail;
}
- if (mep_parse_config_entry(e, 0) != 0) {
+ if (mep_parse_config_entry(e, 0, pb) != 0) {
/* Refuse the operation if config parsing failed. */
ret = LDAP_UNWILLING_TO_PERFORM;
if (LDAP_CHANGETYPE_ADD == modop) {
@@ -1852,7 +1900,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
case LDAP_CHANGETYPE_MODIFY:
/* Fetch the existing template entry. */
if (sdn) {
- slapi_search_internal_get_entry(sdn, 0, &e,
mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(sdn, 0, &e,
mep_get_plugin_id(), txn);
free_entry = 1;
}
@@ -1920,7 +1968,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
slapi_entry_free(e);
}
- slapi_search_internal_get_entry(sdn, 0, &e, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(sdn, 0, &e, mep_get_plugin_id(),
txn);
free_entry = 1;
}
@@ -1930,8 +1978,8 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
origin_dn = slapi_entry_attr_get_charptr(e, MEP_MANAGED_BY_TYPE);
if (origin_dn) {
origin_sdn = slapi_sdn_new_dn_byref(origin_dn);
- slapi_search_internal_get_entry(origin_sdn, 0,
- &origin_e, mep_get_plugin_id());
+ slapi_search_internal_get_entry_ext(origin_sdn, 0,
+ &origin_e, mep_get_plugin_id(), txn);
slapi_sdn_free(&origin_sdn);
}
@@ -2062,6 +2110,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
Slapi_DN *mapped_sdn = NULL;
struct configEntry *config = NULL;
int result = 0;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_mod_post_op\n");
@@ -2070,10 +2119,11 @@ mep_mod_post_op(Slapi_PBlock *pb)
if (!g_plugin_started)
return 0;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if (mep_oktodo(pb) && (sdn = mep_get_sdn(pb))) {
/* First check if the config or a template is being modified. */
if (mep_dn_is_config(sdn) || mep_dn_is_template(slapi_sdn_get_dn(sdn))) {
- mep_load_config();
+ mep_load_config(pb);
}
/* If replication, just bail. */
@@ -2121,6 +2171,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
slapi_modify_internal_set_pb(mep_pb, managed_dn,
slapi_mods_get_ldapmods_byref(smods), 0, 0,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2142,7 +2193,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
managed_sdn = slapi_sdn_new_dn_byref(managed_dn);
if (slapi_sdn_compare(managed_sdn, mapped_sdn) != 0) {
- mep_rename_managed_entry(e, mapped_sdn, managed_sdn);
+ mep_rename_managed_entry(e, mapped_sdn, managed_sdn, txn);
}
slapi_sdn_free(&mapped_sdn);
@@ -2174,6 +2225,7 @@ mep_add_post_op(Slapi_PBlock *pb)
Slapi_Entry *e = NULL;
Slapi_DN *sdn = NULL;
struct configEntry *config = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_add_post_op\n");
@@ -2182,10 +2234,11 @@ mep_add_post_op(Slapi_PBlock *pb)
if (!g_plugin_started || !mep_oktodo(pb))
return 0;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Reload config if a config entry was added. */
if ((sdn = mep_get_sdn(pb))) {
if (mep_dn_is_config(sdn)) {
- mep_load_config();
+ mep_load_config(pb);
}
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
@@ -2219,7 +2272,7 @@ mep_add_post_op(Slapi_PBlock *pb)
mep_find_config(e, &config);
if (config) {
- mep_add_managed_entry(config, e);
+ mep_add_managed_entry(config, e, txn);
}
mep_config_unlock();
@@ -2240,6 +2293,7 @@ mep_del_post_op(Slapi_PBlock *pb)
{
Slapi_Entry *e = NULL;
Slapi_DN *sdn = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_del_post_op\n");
@@ -2252,7 +2306,7 @@ mep_del_post_op(Slapi_PBlock *pb)
/* Reload config if a config entry was deleted. */
if ((sdn = mep_get_sdn(pb))) {
if (mep_dn_is_config(sdn))
- mep_load_config();
+ mep_load_config(pb);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
"mep_del_post_op: Error "
@@ -2264,6 +2318,7 @@ mep_del_post_op(Slapi_PBlock *pb)
return 0;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/* Get deleted entry, then go through types to find config. */
slapi_pblock_get( pb, SLAPI_ENTRY_PRE_OP, &e );
@@ -2287,6 +2342,7 @@ mep_del_post_op(Slapi_PBlock *pb)
"\"%s\".\n ", managed_dn,
slapi_sdn_get_dn(sdn));
slapi_delete_internal_set_pb(mep_pb, managed_dn, NULL,
NULL, mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_delete_internal_pb(mep_pb);
slapi_ch_free_string(&managed_dn);
@@ -2313,6 +2369,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
Slapi_Entry *post_e = NULL;
char *managed_dn = NULL;
struct configEntry *config = NULL;
+ void *txn = NULL;
slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
"--> mep_modrdn_post_op\n");
@@ -2335,9 +2392,10 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
return 0;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if ((old_sdn = mep_get_sdn(pb))) {
if (mep_dn_is_config(old_sdn) || mep_dn_is_config(new_sdn))
- mep_load_config();
+ mep_load_config(pb);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
"mep_modrdn_post_op: Error "
@@ -2388,6 +2446,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
managed_dn, slapi_sdn_get_dn(old_sdn));
slapi_delete_internal_set_pb (mep_pb, managed_dn, NULL, NULL,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_delete_internal_pb(mep_pb);
/* Clear out the pblock for reuse. */
@@ -2417,6 +2476,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
MEP_MANAGED_ENTRY_TYPE, MEP_ORIGIN_OC, new_dn);
slapi_modify_internal_set_pb_ext(mep_pb, new_sdn, mods, 0, 0,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2454,8 +2514,8 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
* perform our updates. */
managed_sdn = slapi_sdn_new_dn_byref(managed_dn);
- if (slapi_search_internal_get_entry(managed_sdn, 0,
- NULL, mep_get_plugin_id()) == LDAP_NO_SUCH_OBJECT) {
+ if (slapi_search_internal_get_entry_ext(managed_sdn, 0,
+ NULL, mep_get_plugin_id(), txn) == LDAP_NO_SUCH_OBJECT) {
slapi_ch_free_string(&managed_dn);
/* This DN is not a copy, so we don't want to free it later. */
managed_dn = slapi_entry_get_dn(new_managed_entry);
@@ -2469,6 +2529,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
"in entry \"%s\".\n", MEP_MANAGED_BY_TYPE,
new_dn, managed_dn);
slapi_modify_internal_set_pb(mep_pb, managed_dn, mods, 0, 0,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2489,7 +2550,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
slapi_sdn_get_dn(old_sdn));
mep_rename_managed_entry(post_e,
slapi_entry_get_sdn(new_managed_entry),
- managed_sdn);
+ managed_sdn, txn);
}
/* Update all of the mapped attributes
@@ -2507,6 +2568,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
slapi_entry_get_sdn(new_managed_entry),
slapi_mods_get_ldapmods_byref(smods), 0, 0,
mep_get_plugin_id(), 0);
+ slapi_pblock_set(mep_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(mep_pb);
slapi_pblock_get(mep_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
@@ -2549,7 +2611,7 @@ bailmod:
mep_find_config(post_e, &config);
if (config) {
- mep_add_managed_entry(config, post_e);
+ mep_add_managed_entry(config, post_e, txn);
}
mep_config_unlock();
diff --git a/ldap/servers/plugins/replication/urp.c
b/ldap/servers/plugins/replication/urp.c
index 1328996..33be252 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -53,10 +53,10 @@
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, Slapi_Entry *entry, CSN *opcsn, const char
*optype);
+static int urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, const char
*optype, void *txn);
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 del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags);
+static int mod_namingconflict_attr (const char *uniqueid, const Slapi_DN *entrysdn, const
Slapi_DN *conflictsdn, CSN *opcsn, void *txn);
+static int del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags, void
*txn);
static char *get_dn_plus_uniqueid(char *sessionid,const char *olddn,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);
@@ -123,12 +123,14 @@ urp_add_operation( Slapi_PBlock *pb )
int op_result= 0;
int rc= 0; /* OK */
Slapi_DN *sdn = NULL;
+ void *txn = NULL;
if ( slapi_op_abandoned(pb) )
{
return rc;
}
+ slapi_pblock_get( pb, SLAPI_TXN, &txn );
slapi_pblock_get( pb, SLAPI_ADD_EXISTING_UNIQUEID_ENTRY, &existing_uniqueid_entry
);
if (existing_uniqueid_entry!=NULL)
{
@@ -227,7 +229,7 @@ urp_add_operation( Slapi_PBlock *pb )
else if(r>0)
{
/* Existing entry is a loser */
- if (!urp_annotate_dn(sessionid, existing_dn_entry, opcsn, "ADD"))
+ if (!urp_annotate_dn(sessionid, existing_dn_entry, opcsn, "ADD", txn))
{
op_result= LDAP_OPERATIONS_ERROR;
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &op_result);
@@ -286,12 +288,14 @@ urp_modrdn_operation( Slapi_PBlock *pb )
int op_result= 0;
int rc= 0; /* OK */
int del_old_replconflict_attr = 0;
+ void *txn = NULL;
if ( slapi_op_abandoned(pb) )
{
return rc;
}
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
slapi_pblock_get (pb, SLAPI_MODRDN_TARGET_ENTRY, &target_entry);
if(target_entry==NULL)
{
@@ -417,7 +421,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, txn);
slapi_pblock_set(pb, SLAPI_MODRDN_NEWRDN, newrdn_with_uniqueid);
slapi_log_error(slapi_log_urp, sessionid,
"Naming conflict MODRDN. Rename target entry to %s\n",
@@ -432,7 +436,7 @@ urp_modrdn_operation( Slapi_PBlock *pb )
{
/* The existing entry is a loser */
- int resolve = urp_annotate_dn (sessionid, existing_entry, opcsn, "MODRDN");
+ int resolve = urp_annotate_dn (sessionid, existing_entry, opcsn, "MODRDN",
txn);
if(!resolve)
{
op_result= LDAP_OPERATIONS_ERROR;
@@ -543,7 +547,7 @@ urp_modrdn_operation( Slapi_PBlock *pb )
bailout:
if ( del_old_replconflict_attr && rc == 0 )
{
- del_replconflict_attr (target_entry, opcsn, 0);
+ del_replconflict_attr (target_entry, opcsn, 0, txn);
}
if ( parentdn )
slapi_sdn_free(&parentdn);
@@ -561,12 +565,14 @@ urp_delete_operation( Slapi_PBlock *pb )
char sessionid[REPL_SESSION_ID_SIZE];
int op_result= 0;
int rc= 0; /* OK */
+ void *txn = NULL;
if ( slapi_op_abandoned(pb) )
{
return rc;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_pblock_get(pb, SLAPI_DELETE_EXISTING_ENTRY, &deleteentry);
if(deleteentry==NULL) /* uniqueid can't be found */
@@ -592,14 +598,14 @@ urp_delete_operation( Slapi_PBlock *pb )
if(!slapi_entry_has_children(deleteentry))
{
/* Remove possible conflict attributes */
- del_replconflict_attr (deleteentry, opcsn, 0);
+ del_replconflict_attr (deleteentry, opcsn, 0, txn);
rc= 0; /* OK, to delete the entry */
PROFILE_POINT; /* Delete Operation; OK. */
}
else
{
/* Turn this entry into a glue_absent_parent entry */
- entry_to_glue(sessionid, deleteentry, REASON_RESURRECT_ENTRY, opcsn);
+ entry_to_glue(sessionid, deleteentry, REASON_RESURRECT_ENTRY, opcsn, txn);
/* Turn the Delete into a No-Op */
op_result= LDAP_SUCCESS;
@@ -712,7 +718,7 @@ urp_post_delete_operation( Slapi_PBlock *pb )
}
int
-urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char
*parentuniqueid, CSN *opcsn, int opflags)
+urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char
*parentuniqueid, CSN *opcsn, int opflags, void *txn)
{
Slapi_PBlock *newpb;
Slapi_Operation *op;
@@ -743,6 +749,7 @@ urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid,
const char *pa
slapi_pblock_get ( newpb, SLAPI_OPERATION, &op );
operation_set_csn ( op, opcsn );
+ slapi_pblock_set ( newpb, SLAPI_TXN, txn );
slapi_add_internal_pb ( newpb );
slapi_pblock_get ( newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result );
slapi_pblock_destroy ( newpb );
@@ -751,7 +758,7 @@ urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid,
const char *pa
}
int
-urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags)
+urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags, void *txn)
{
Slapi_PBlock *newpb;
Slapi_Operation *op;
@@ -780,6 +787,7 @@ urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int
opflags)
slapi_pblock_get (newpb, SLAPI_OPERATION, &op);
operation_set_csn (op, opcsn);
+ slapi_pblock_set(newpb, SLAPI_TXN, txn);
slapi_modrdn_internal_pb(newpb);
slapi_pblock_get(newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result);
@@ -788,7 +796,7 @@ urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int
opflags)
}
int
-urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int opflags)
+urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int opflags,
void *txn)
{
Slapi_PBlock *newpb;
Slapi_Operation *op;
@@ -810,6 +818,7 @@ urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN
*opcsn, int op
slapi_pblock_get ( newpb, SLAPI_OPERATION, &op );
operation_set_csn ( op, opcsn );
+ slapi_pblock_set ( newpb, SLAPI_TXN, txn );
slapi_delete_internal_pb ( newpb );
slapi_pblock_get ( newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result );
slapi_pblock_destroy ( newpb );
@@ -818,7 +827,7 @@ urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN
*opcsn, int op
}
int
-urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn, Slapi_Mods
*smods, int opflags)
+urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn, Slapi_Mods
*smods, int opflags, void *txn)
{
Slapi_PBlock *newpb;
Slapi_Operation *op;
@@ -839,6 +848,7 @@ urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN
*opcsn, S
slapi_pblock_get (newpb, SLAPI_OPERATION, &op);
operation_set_csn (op, opcsn);
+ slapi_pblock_set (newpb, SLAPI_TXN, txn);
/* do modify */
slapi_modify_internal_pb (newpb);
slapi_pblock_get (newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result);
@@ -962,7 +972,7 @@ bailout:
* a new entry (the operation entry) see urp_add_operation.
*/
static int
-urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, const char *optype)
+urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn, const char *optype,
void *txn)
{
int rc = 0; /* Fail */
int op_result;
@@ -978,8 +988,8 @@ urp_annotate_dn (char *sessionid, Slapi_Entry *entry, CSN *opcsn,
const char *op
newrdn = get_rdn_plus_uniqueid ( sessionid, basedn, uniqueid );
if(newrdn!=NULL)
{
- mod_namingconflict_attr (uniqueid, basesdn, basesdn, opcsn);
- op_result = urp_fixup_rename_entry ( entry, newrdn, 0 );
+ mod_namingconflict_attr (uniqueid, basesdn, basesdn, opcsn, txn);
+ op_result = urp_fixup_rename_entry ( entry, newrdn, 0, txn );
switch(op_result)
{
case LDAP_SUCCESS:
@@ -1041,7 +1051,9 @@ urp_get_min_naming_conflict_entry ( Slapi_PBlock *pb, char
*sessionid, CSN *opcs
int i = 0;
int min_i = -1;
int op_result = LDAP_SUCCESS;
+ void *txn = NULL;
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
slapi_pblock_get (pb, SLAPI_URP_NAMING_COLLISION_DN, &basedn);
if (NULL == basedn || strncmp (basedn, SLAPI_ATTR_UNIQUEID, strlen(SLAPI_ATTR_UNIQUEID))
== 0)
return NULL;
@@ -1068,6 +1080,7 @@ urp_get_min_naming_conflict_entry ( Slapi_PBlock *pb, char
*sessionid, CSN *opcs
NULL, /* UniqueID */
repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION),
0);
+ slapi_pblock_set(newpb, SLAPI_TXN, txn);
slapi_search_internal_pb(newpb);
slapi_pblock_get(newpb, SLAPI_PLUGIN_INTOP_RESULT, &op_result);
slapi_pblock_get(newpb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
@@ -1133,6 +1146,9 @@ urp_naming_conflict_removal ( Slapi_PBlock *pb, char *sessionid, CSN
*opcsn, con
Slapi_RDN *oldrdn, *newrdn;
const char *oldrdnstr, *newrdnstr;
int op_result;
+ void *txn = NULL;
+
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
/*
* Backend op has set SLAPI_URP_NAMING_COLLISION_DN to the basedn.
@@ -1158,7 +1174,7 @@ urp_naming_conflict_removal ( Slapi_PBlock *pb, char *sessionid, CSN
*opcsn, con
* is done after DB lock was released. The backend modrdn
* will acquire the DB lock if it sees this flag.
*/
- op_result = urp_fixup_rename_entry (min_naming_conflict_entry, newrdnstr,
OP_FLAG_ACTION_INVOKE_FOR_REPLOP);
+ op_result = urp_fixup_rename_entry (min_naming_conflict_entry, newrdnstr,
OP_FLAG_ACTION_INVOKE_FOR_REPLOP, txn);
if ( op_result != LDAP_SUCCESS )
{
slapi_log_error (slapi_log_urp, sessionid,
@@ -1173,7 +1189,7 @@ urp_naming_conflict_removal ( Slapi_PBlock *pb, char *sessionid, CSN
*opcsn, con
* A fixup op will not invoke urp_modrdn_operation(). Even it does,
* urp_modrdn_operation() will do nothing because of the same CSN.
*/
- op_result = del_replconflict_attr (min_naming_conflict_entry, opcsn,
OP_FLAG_ACTION_INVOKE_FOR_REPLOP);
+ op_result = del_replconflict_attr (min_naming_conflict_entry, opcsn,
OP_FLAG_ACTION_INVOKE_FOR_REPLOP, txn);
if (op_result != LDAP_SUCCESS) {
slapi_log_error(SLAPI_LOG_REPL, sessionid,
"Failed to remove nsds5ReplConflict for %s, err=%d\n",
@@ -1277,7 +1293,7 @@ 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, void *txn)
{
Slapi_Mods smods;
char buf[BUFSIZ];
@@ -1300,13 +1316,13 @@ mod_namingconflict_attr (const char *uniqueid, const Slapi_DN
*entrysdn,
*/
slapi_mods_add (&smods, LDAP_MOD_REPLACE, ATTR_NSDS5_REPLCONFLICT, strlen(buf),
buf);
}
- op_result = urp_fixup_modify_entry (uniqueid, entrysdn, opcsn, &smods, 0);
+ op_result = urp_fixup_modify_entry (uniqueid, entrysdn, opcsn, &smods, 0, txn);
slapi_mods_done (&smods);
return op_result;
}
static int
-del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags)
+del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags, void *txn)
{
Slapi_Attr *attr;
int op_result = 0;
@@ -1321,7 +1337,7 @@ del_replconflict_attr (Slapi_Entry *entry, CSN *opcsn, int opflags)
entrysdn = slapi_entry_get_sdn_const (entry);
slapi_mods_init (&smods, 2);
slapi_mods_add (&smods, LDAP_MOD_DELETE, ATTR_NSDS5_REPLCONFLICT, 0, NULL);
- op_result = urp_fixup_modify_entry (uniqueid, entrysdn, opcsn, &smods, opflags);
+ op_result = urp_fixup_modify_entry (uniqueid, entrysdn, opcsn, &smods, opflags,
txn);
slapi_mods_done (&smods);
}
return op_result;
diff --git a/ldap/servers/plugins/replication/urp.h
b/ldap/servers/plugins/replication/urp.h
index 2ca7ad2..77ac8a4 100644
--- a/ldap/servers/plugins/replication/urp.h
+++ b/ldap/servers/plugins/replication/urp.h
@@ -57,10 +57,10 @@ int urp_modrdn_operation( Slapi_PBlock *pb );
int urp_post_modrdn_operation( Slapi_PBlock *pb );
/* urp internal ops */
-int urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char
*parentuniqueid, CSN *opcsn, int opflags);
-int urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int
opflags);
-int urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags);
-int urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn,
Slapi_Mods *smods, int opflags);
+int urp_fixup_add_entry (Slapi_Entry *e, const char *target_uniqueid, const char
*parentuniqueid, CSN *opcsn, int opflags, void *txn);
+int urp_fixup_delete_entry (const char *uniqueid, const char *dn, CSN *opcsn, int
opflags, void *txn);
+int urp_fixup_rename_entry (Slapi_Entry *entry, const char *newrdn, int opflags, void
*txn);
+int urp_fixup_modify_entry (const char *uniqueid, const Slapi_DN *sdn, CSN *opcsn,
Slapi_Mods *smods, int opflags, void *txn);
int is_suffix_dn (Slapi_PBlock *pb, const Slapi_DN *dn, Slapi_DN **parenddn);
@@ -69,7 +69,7 @@ int is_suffix_dn (Slapi_PBlock *pb, const Slapi_DN *dn, Slapi_DN
**parenddn);
*/
int is_glue_entry(const Slapi_Entry* entry);
int create_glue_entry ( Slapi_PBlock *pb, char *sessionid, Slapi_DN *dn, const char
*uniqueid, CSN *opcsn );
-int entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN
*opcsn);
+int entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN
*opcsn, void *txn);
int glue_to_entry (Slapi_PBlock *pb, Slapi_Entry *entry );
PRBool get_glue_csn(const Slapi_Entry *entry, const CSN **gluecsn);
diff --git a/ldap/servers/plugins/replication/urp_glue.c
b/ldap/servers/plugins/replication/urp_glue.c
index e51712c..499cb97 100644
--- a/ldap/servers/plugins/replication/urp_glue.c
+++ b/ldap/servers/plugins/replication/urp_glue.c
@@ -92,7 +92,7 @@ get_glue_csn(const Slapi_Entry *entry, const CSN **gluecsn)
* Submit a Modify operation to turn the Entry into Glue.
*/
int
-entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN *opcsn)
+entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char *reason, CSN *opcsn,
void *txn)
{
int op_result = 0;
const char *dn;
@@ -135,7 +135,7 @@ entry_to_glue(char *sessionid, const Slapi_Entry* entry, const char
*reason, CSN
if (slapi_mods_get_num_mods(&smods) > 0)
{
- op_result = urp_fixup_modify_entry (NULL, sdn, opcsn, &smods, 0);
+ op_result = urp_fixup_modify_entry (NULL, sdn, opcsn, &smods, 0, txn);
if (op_result == LDAP_SUCCESS)
{
slapi_log_error (slapi_log_urp, repl_plugin_name,
@@ -158,7 +158,7 @@ static const char *glue_entry =
"%s: %s\n"; /* Add why it's been created */
static int
-do_create_glue_entry(const Slapi_RDN *rdn, const Slapi_DN *superiordn, const char
*uniqueid, const char *reason, CSN *opcsn)
+do_create_glue_entry(const Slapi_RDN *rdn, const Slapi_DN *superiordn, const char
*uniqueid, const char *reason, CSN *opcsn, void *txn)
{
int op_result= LDAP_OPERATIONS_ERROR;
int rdnval_index = 0;
@@ -202,7 +202,7 @@ do_create_glue_entry(const Slapi_RDN *rdn, const Slapi_DN *superiordn,
const cha
if ( e!=NULL )
{
slapi_entry_set_uniqueid (e, slapi_ch_strdup(uniqueid));
- op_result = urp_fixup_add_entry (e, NULL, NULL, opcsn, 0);
+ op_result = urp_fixup_add_entry (e, NULL, NULL, opcsn, 0, txn);
}
slapi_ch_free_string(&estr);
slapi_sdn_free(&sdn);
@@ -214,12 +214,14 @@ create_glue_entry ( Slapi_PBlock *pb, char *sessionid, Slapi_DN *dn,
const char
{
int op_result;
const char *dnstr;
+ void *txn = NULL;
if ( slapi_sdn_get_dn (dn) )
dnstr = slapi_sdn_get_dn (dn);
else
dnstr = "";
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
if ( NULL == uniqueid )
{
op_result = LDAP_OPERATIONS_ERROR;
@@ -239,7 +241,7 @@ create_glue_entry ( Slapi_PBlock *pb, char *sessionid, Slapi_DN *dn,
const char
while(!done)
{
- op_result= do_create_glue_entry(rdn, superiordn, uniqueid, "missingEntry",
opcsn);
+ op_result= do_create_glue_entry(rdn, superiordn, uniqueid, "missingEntry",
opcsn, txn);
switch(op_result)
{
case LDAP_SUCCESS:
diff --git a/ldap/servers/plugins/replication/urp_tombstone.c
b/ldap/servers/plugins/replication/urp_tombstone.c
index 6dd9a2a..7c36421 100644
--- a/ldap/servers/plugins/replication/urp_tombstone.c
+++ b/ldap/servers/plugins/replication/urp_tombstone.c
@@ -94,6 +94,10 @@ tombstone_to_glue_resolve_parent (
{
int op_result;
Slapi_PBlock *newpb= slapi_pblock_new();
+ void *txn = NULL;
+
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
+ slapi_pblock_set(newpb, SLAPI_TXN, txn);
slapi_search_internal_set_pb(
newpb,
slapi_sdn_get_dn(parentdn), /* JCM - This DN just identifies the backend to be
searched. */
@@ -156,6 +160,7 @@ tombstone_to_glue (
Slapi_Entry *addingentry;
const char *addingdn;
int op_result;
+ void *txn = NULL;
/* JCMREPL
* Nothing logged to the 5.0 Change Log
@@ -189,7 +194,8 @@ tombstone_to_glue (
slapi_entry_add_string(addingentry, ATTR_NSDS5_REPLCONFLICT, reason);
}
tombstoneuniqueid= slapi_entry_get_uniqueid(tombstoneentry);
- op_result = urp_fixup_add_entry (addingentry, tombstoneuniqueid, parentuniqueid, opcsn,
OP_FLAG_RESURECT_ENTRY);
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
+ op_result = urp_fixup_add_entry (addingentry, tombstoneuniqueid, parentuniqueid, opcsn,
OP_FLAG_RESURECT_ENTRY, txn);
if (op_result == LDAP_SUCCESS)
{
slapi_log_error (slapi_log_urp, repl_plugin_name,
@@ -213,6 +219,7 @@ entry_to_tombstone ( Slapi_PBlock *pb, Slapi_Entry *entry )
CSN *opcsn;
const char *uniqueid;
int op_result = LDAP_SUCCESS;
+ void *txn = NULL;
slapi_pblock_get ( pb, SLAPI_OPERATION, &op );
opcsn = operation_get_csn ( op );
@@ -227,9 +234,10 @@ entry_to_tombstone ( Slapi_PBlock *pb, Slapi_Entry *entry )
*/
slapi_mods_add ( &smods, LDAP_MOD_DELETE, ATTR_NSDS5_REPLCONFLICT, 0, NULL );
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
op_result = urp_fixup_modify_entry (uniqueid,
slapi_entry_get_sdn_const (entry),
- opcsn, &smods, 0);
+ opcsn, &smods, 0, txn);
slapi_mods_done ( &smods );
/*
@@ -242,7 +250,7 @@ entry_to_tombstone ( Slapi_PBlock *pb, Slapi_Entry *entry )
* through the urp operations and trigger the recursive
* fixup if applicable.
*/
- op_result = urp_fixup_delete_entry (uniqueid, slapi_entry_get_dn_const (entry), opcsn,
0);
+ op_result = urp_fixup_delete_entry (uniqueid, slapi_entry_get_dn_const (entry), opcsn,
0, txn);
}
return op_result;
diff --git a/ldap/servers/plugins/retrocl/retrocl_po.c
b/ldap/servers/plugins/retrocl/retrocl_po.c
index 29ce79f..729ffbb 100644
--- a/ldap/servers/plugins/retrocl/retrocl_po.c
+++ b/ldap/servers/plugins/retrocl/retrocl_po.c
@@ -178,12 +178,15 @@ write_replog_db(
changeNumber changenum;
int i;
int extensibleObject = 0;
+ void *txn = NULL;
if (!dn) {
slapi_log_error( SLAPI_LOG_PLUGIN, RETROCL_PLUGIN_NAME, "write_replog_db:
NULL dn\n");
return;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
+
PR_Lock(retrocl_internal_lock);
changenum = retrocl_assign_changenumber();
@@ -361,6 +364,7 @@ write_replog_db(
slapi_add_entry_internal_set_pb( newPb, e, NULL /* controls */,
g_plg_identity[PLUGIN_RETROCL],
0 /* actions */ );
+ slapi_pblock_set (newPb, SLAPI_TXN, txn);
slapi_add_internal_pb (newPb);
slapi_pblock_get( newPb, SLAPI_PLUGIN_INTOP_RESULT, &rc );
slapi_pblock_destroy(newPb);
diff --git a/ldap/servers/plugins/uiduniq/plugin-utils.h
b/ldap/servers/plugins/uiduniq/plugin-utils.h
index 5cdd95b..9c5eeb1 100644
--- a/ldap/servers/plugins/uiduniq/plugin-utils.h
+++ b/ldap/servers/plugins/uiduniq/plugin-utils.h
@@ -87,10 +87,10 @@
int op_error(int internal_error);
Slapi_PBlock *readPblockAndEntry( const char *baseDN, const char *filter,
- char *attrs[] );
+ char *attrs[], void *txn, void *pluginid );
int entryHasObjectClass(Slapi_PBlock *pb, Slapi_Entry *e,
const char *objectClass);
-Slapi_PBlock *dnHasObjectClass( const char *baseDN, const char *objectClass );
-Slapi_PBlock *dnHasAttribute( const char *baseDN, const char *attrName );
+Slapi_PBlock *dnHasObjectClass( const char *baseDN, const char *objectClass, void *txn,
void *pluginid );
+Slapi_PBlock *dnHasAttribute( const char *baseDN, const char *attrName, void *txn, void
*pluginid );
#endif /* _PLUGIN_UTILS_H_ */
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index 8bd5e17..e1b855c 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -70,7 +70,7 @@ int ldap_quote_filter_value(
static int search_one_berval(const char *baseDN, const char *attrName,
- const struct berval *value, const char *requiredObjectClass, const char *target);
+ const struct berval *value, const char *requiredObjectClass, const char *target, void
*txn);
/*
* ISSUES:
@@ -226,7 +226,7 @@ create_filter(const char *attribute, const struct berval *value, const
char *req
static int
search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
struct berval **values, const char *requiredObjectClass,
- const char *target)
+ const char *target, void *txn)
{
int result;
@@ -260,7 +260,7 @@ search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
{
result = search_one_berval(baseDN, attrName,
slapi_value_get_berval(v),
- requiredObjectClass, target);
+ requiredObjectClass, target, txn);
}
}
else
@@ -268,7 +268,7 @@ search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
for (;*values != NULL && LDAP_SUCCESS == result; values++)
{
result = search_one_berval(baseDN, attrName, *values, requiredObjectClass,
- target);
+ target, txn);
}
}
@@ -284,7 +284,7 @@ search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
static int
search_one_berval(const char *baseDN, const char *attrName,
const struct berval *value, const char *requiredObjectClass,
- const char *target)
+ const char *target, void *txn)
{
int result;
char *filter;
@@ -319,6 +319,7 @@ search_one_berval(const char *baseDN, const char *attrName,
slapi_search_internal_set_pb(spb, baseDN, LDAP_SCOPE_SUBTREE,
filter, attrs, 0 /* attrs only */, NULL, NULL, plugin_identity, 0 /* actions */);
+ slapi_pblock_set(spb, SLAPI_TXN, txn);
slapi_search_internal_pb(spb);
err = slapi_pblock_get(spb, SLAPI_PLUGIN_INTOP_RESULT, &sres);
@@ -394,7 +395,7 @@ search_one_berval(const char *baseDN, const char *attrName,
static int
searchAllSubtrees(int argc, char *argv[], const char *attrName,
Slapi_Attr *attr, struct berval **values, const char *requiredObjectClass,
- const char *dn)
+ const char *dn, void *txn)
{
int result = LDAP_SUCCESS;
@@ -409,7 +410,7 @@ searchAllSubtrees(int argc, char *argv[], const char *attrName,
* worry about that here.
*/
if (slapi_dn_issuffix(dn, *argv)) {
- result = search(*argv, attrName, attr, values, requiredObjectClass, dn);
+ result = search(*argv, attrName, attr, values, requiredObjectClass, dn, txn);
if (result) break;
}
}
@@ -499,14 +500,14 @@ getArguments(Slapi_PBlock *pb, char **attrName, char
**markerObjectClass,
static int
findSubtreeAndSearch(char *parentDN, const char *attrName, Slapi_Attr *attr,
struct berval **values, const char *requiredObjectClass, const char *target,
- const char *markerObjectClass)
+ const char *markerObjectClass, void *txn)
{
int result = LDAP_SUCCESS;
Slapi_PBlock *spb = NULL;
while (NULL != (parentDN = slapi_dn_parent(parentDN)))
{
- if ((spb = dnHasObjectClass(parentDN, markerObjectClass)))
+ if ((spb = dnHasObjectClass(parentDN, markerObjectClass, txn, plugin_identity)))
{
freePblock(spb);
/*
@@ -514,7 +515,7 @@ findSubtreeAndSearch(char *parentDN, const char *attrName, Slapi_Attr
*attr,
* to have the attribute already.
*/
result = search(parentDN, attrName, attr, values, requiredObjectClass,
- target);
+ target, txn);
break;
}
}
@@ -554,6 +555,7 @@ preop_add(Slapi_PBlock *pb)
Slapi_Attr *attr;
int argc;
char **argv = NULL;
+ void *txn = NULL;
/*
* If this is a replication update, just be a noop.
@@ -565,6 +567,7 @@ preop_add(Slapi_PBlock *pb)
break;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/*
* Get the arguments
*/
@@ -631,12 +634,12 @@ preop_add(Slapi_PBlock *pb)
/* Subtree defined by location of marker object class */
result = findSubtreeAndSearch((char *)dn, attrName, attr, NULL,
requiredObjectClass, dn,
- markerObjectClass);
+ markerObjectClass, txn);
} else
{
/* Subtrees listed on invocation line */
result = searchAllSubtrees(argc, argv, attrName, attr, NULL,
- requiredObjectClass, dn);
+ requiredObjectClass, dn, txn);
}
END
@@ -708,6 +711,7 @@ preop_modify(Slapi_PBlock *pb)
int isupdatedn;
int argc;
char **argv = NULL;
+ void *txn = NULL;
/*
* If this is a replication update, just be a noop.
@@ -719,6 +723,7 @@ preop_modify(Slapi_PBlock *pb)
break;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/*
* Get the arguments
*/
@@ -780,7 +785,7 @@ preop_modify(Slapi_PBlock *pb)
* Check if it has the required object class
*/
if (requiredObjectClass &&
- !(spb = dnHasObjectClass(dn, requiredObjectClass))) {
+ !(spb = dnHasObjectClass(dn, requiredObjectClass, txn, plugin_identity))) {
break;
}
@@ -800,12 +805,12 @@ preop_modify(Slapi_PBlock *pb)
/* Subtree defined by location of marker object class */
result = findSubtreeAndSearch((char *)dn, attrName, NULL,
mod->mod_bvalues, requiredObjectClass,
- dn, markerObjectClass);
+ dn, markerObjectClass, txn);
} else
{
/* Subtrees listed on invocation line */
result = searchAllSubtrees(argc, argv, attrName, NULL,
- mod->mod_bvalues, requiredObjectClass, dn);
+ mod->mod_bvalues, requiredObjectClass, dn,
txn);
}
}
END
@@ -866,6 +871,7 @@ preop_modrdn(Slapi_PBlock *pb)
Slapi_Attr *attr;
int argc;
char **argv = NULL;
+ void *txn = NULL;
/*
* If this is a replication update, just be a noop.
@@ -877,6 +883,7 @@ preop_modrdn(Slapi_PBlock *pb)
break;
}
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
/*
* Get the arguments
*/
@@ -935,7 +942,7 @@ preop_modrdn(Slapi_PBlock *pb)
/* Get the entry that is being renamed so we can make a dummy copy
* of what it will look like after the rename. */
- err = slapi_search_internal_get_entry(sdn, NULL, &e, plugin_identity);
+ err = slapi_search_internal_get_entry_ext(sdn, NULL, &e, plugin_identity, txn);
if (err != LDAP_SUCCESS) {
result = uid_op_error(35);
/* We want to return a no such object error if the target doesn't exist. */
@@ -971,12 +978,12 @@ preop_modrdn(Slapi_PBlock *pb)
/* Subtree defined by location of marker object class */
result = findSubtreeAndSearch(slapi_entry_get_dn(e), attrName, attr,
NULL,
requiredObjectClass, dn,
- markerObjectClass);
+ markerObjectClass, txn);
} else
{
/* Subtrees listed on invocation line */
result = searchAllSubtrees(argc, argv, attrName, attr, NULL,
- requiredObjectClass, dn);
+ requiredObjectClass, dn, txn);
}
END
/* Clean-up */
diff --git a/ldap/servers/plugins/uiduniq/utils.c b/ldap/servers/plugins/uiduniq/utils.c
index 4966089..567218a 100644
--- a/ldap/servers/plugins/uiduniq/utils.c
+++ b/ldap/servers/plugins/uiduniq/utils.c
@@ -82,19 +82,22 @@ op_error(int internal_error) {
*/
Slapi_PBlock *
readPblockAndEntry( const char *baseDN, const char *filter,
- char *attrs[] ) {
+ char *attrs[], void *txn, void *pluginid ) {
Slapi_PBlock *spb = NULL;
BEGIN
int sres;
- /* Perform the search - the new pblock needs to be freed */
- spb = slapi_search_internal((char *)baseDN, LDAP_SCOPE_BASE,
- (char *)filter, NULL, attrs, 0);
- if ( !spb ) {
+ spb = slapi_pblock_new();
+ if (!spb) {
op_error(20);
break;
}
+ slapi_search_internal_set_pb (spb, baseDN, LDAP_SCOPE_BASE, filter,
+ attrs, 0, NULL,
+ NULL, pluginid, 0);
+ slapi_pblock_set(spb, SLAPI_TXN, txn);
+ slapi_search_internal_pb (spb);
if ( slapi_pblock_get( spb, SLAPI_PLUGIN_INTOP_RESULT, &sres ) ) {
op_error(21);
@@ -150,7 +153,7 @@ entryHasObjectClass(Slapi_PBlock *pb, Slapi_Entry *e,
* A pblock containing the entry, or NULL
*/
Slapi_PBlock *
-dnHasObjectClass( const char *baseDN, const char *objectClass ) {
+dnHasObjectClass( const char *baseDN, const char *objectClass, void *txn, void *pluginid
) {
char *filter = NULL;
Slapi_PBlock *spb = NULL;
@@ -162,7 +165,7 @@ dnHasObjectClass( const char *baseDN, const char *objectClass ) {
attrs[0] = "objectclass";
attrs[1] = NULL;
filter = PR_smprintf("objectclass=%s", objectClass );
- if ( !(spb = readPblockAndEntry( baseDN, filter, attrs) ) ) {
+ if ( !(spb = readPblockAndEntry( baseDN, filter, attrs, txn, pluginid ) ) ) {
break;
}
@@ -196,7 +199,7 @@ dnHasObjectClass( const char *baseDN, const char *objectClass ) {
* The entry, or NULL
*/
Slapi_PBlock *
-dnHasAttribute( const char *baseDN, const char *attrName ) {
+dnHasAttribute( const char *baseDN, const char *attrName, void *txn, void *pluginid ) {
Slapi_PBlock *spb = NULL;
char *filter = NULL;
@@ -209,12 +212,16 @@ dnHasAttribute( const char *baseDN, const char *attrName ) {
attrs[0] = (char *)attrName;
attrs[1] = NULL;
filter = PR_smprintf( "%s=*", attrName );
- spb = slapi_search_internal((char *)baseDN, LDAP_SCOPE_BASE,
- filter, NULL, attrs, 0);
- if ( !spb ) {
+ spb = slapi_pblock_new();
+ if (!spb) {
op_error(20);
break;
}
+ slapi_search_internal_set_pb (spb, baseDN, LDAP_SCOPE_BASE, filter,
+ attrs, 0, NULL,
+ NULL, pluginid, 0);
+ slapi_pblock_set(spb, SLAPI_TXN, txn);
+ slapi_search_internal_pb (spb);
if ( slapi_pblock_get( spb, SLAPI_PLUGIN_INTOP_RESULT, &sres ) ) {
op_error(21);
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index a0af006..e872f35 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -1013,6 +1013,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
char *proxydn = NULL;
char *proxystr = NULL;
char *errtext = NULL;
+ void *txn = NULL;
slapi_pblock_get (pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op);
if (repl_op) {
@@ -1027,6 +1028,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
slapi_pblock_get (pb, SLAPI_PWPOLICY, &pwresponse_req);
internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL);
+ slapi_pblock_get (pb, SLAPI_TXN, &txn);
slapi_sdn_init_dn_byref (&sdn, dn);
pwpolicy = new_passwdPolicy(pb, (char *)slapi_sdn_get_ndn(&sdn));
@@ -1056,7 +1058,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
mods[1] = NULL;
/* We need to actually fetch the target here to use for ACI checking. */
- slapi_search_internal_get_entry(&sdn, NULL, &e, (void
*)plugin_get_default_component_id());
+ slapi_search_internal_get_entry_ext(&sdn, NULL, &e, (void
*)plugin_get_default_component_id(), txn);
/* Create a bogus entry with just the target dn if we were unable to
* find the actual entry. This will only be used for checking the ACIs. */
diff --git a/ldap/servers/slapd/passwd_extop.c b/ldap/servers/slapd/passwd_extop.c
index c77d3b7..c05dd81 100644
--- a/ldap/servers/slapd/passwd_extop.c
+++ b/ldap/servers/slapd/passwd_extop.c
@@ -153,6 +153,7 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn,
Slapi_Mods *mods,
LDAPControl **req_controls_copy = NULL;
LDAPControl **pb_resp_controls = NULL;
int ret=0;
+ void *txn = NULL;
LDAPDebug( LDAP_DEBUG_TRACE, "=> passwd_apply_mods\n", 0, 0, 0 );
@@ -179,6 +180,9 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn,
Slapi_Mods *mods,
* that it was done by the root DN. */
pb.pb_conn = pb_orig->pb_conn;
+ slapi_pblock_get(pb_orig, SLAPI_TXN, &txn);
+ slapi_pblock_set(&pb, SLAPI_TXN, txn);
+
ret =slapi_modify_internal_pb (&pb);
/* We now clean up the connection that we copied into the
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index da58f9b..9714871 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -862,6 +862,7 @@ void pw_add_allowchange_aci(Slapi_Entry *e, int pw_prohibit_change);
*/
int update_pw_retry ( Slapi_PBlock *pb );
void pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods);
+void pw_apply_mods_ext(const Slapi_DN *sdn, Slapi_Mods *mods, void *txn);
void pw_set_componentID(struct slapi_componentid * cid);
struct slapi_componentid * pw_get_componentID();
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index ed8d2c8..58fce28 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -593,7 +593,9 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) {
passwdPolicy *pwpolicy = NULL;
int internal_op = 0;
Slapi_Operation *operation = NULL;
+ void *txn = NULL;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_pblock_get(pb, SLAPI_OPERATION, &operation);
internal_op = slapi_operation_is_flag_set(operation, SLAPI_OP_FLAG_INTERNAL);
@@ -666,7 +668,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) {
} else if (prev_exp_date == SLAPD_END_TIME) {
/* Special entries' passwords never expire */
slapi_ch_free((void**)&prev_exp_date_str);
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
return 0;
@@ -683,7 +685,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) {
*/
pw_exp_date = NOT_FIRST_TIME;
} else {
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
return 0;
@@ -697,7 +699,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw) {
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpWarned",
"0");
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
if (pb->pb_conn) { /* no conn for internal op */
/* reset c_needpw to 0 */
@@ -1080,6 +1082,7 @@ update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char
*old_pw )
char *str;
passwdPolicy *pwpolicy = NULL;
const char *dn = slapi_sdn_get_dn(sdn);
+ void *txn = NULL;
pwpolicy = new_passwdPolicy(pb, dn);
@@ -1138,8 +1141,10 @@ update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char
*old_pw )
list_of_mods[1] = NULL;
pblock_init(&mod_pb);
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_modify_internal_set_pb_ext(&mod_pb, sdn, list_of_mods, NULL, NULL,
pw_get_componentID(), 0);
+ slapi_pblock_set(&mod_pb, SLAPI_TXN, txn);
slapi_modify_internal_pb(&mod_pb);
slapi_pblock_get(&mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
if (res != LDAP_SUCCESS){
diff --git a/ldap/servers/slapd/pw_mgmt.c b/ldap/servers/slapd/pw_mgmt.c
index 8d99879..28b0491 100644
--- a/ldap/servers/slapd/pw_mgmt.c
+++ b/ldap/servers/slapd/pw_mgmt.c
@@ -67,7 +67,9 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int
pwresponse_req )
passwdPolicy *pwpolicy = NULL;
int pwdGraceUserTime = 0;
char graceUserTime[8];
+ void *txn = NULL;
+ slapi_pblock_get(pb, SLAPI_TXN, &txn);
slapi_mods_init (&smods, 0);
sdn = slapi_entry_get_sdn_const( e );
dn = slapi_entry_get_ndn( e );
@@ -102,9 +104,9 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int
pwresponse_req )
slapi_ch_free((void **)×tring);
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE, "passwordExpWarned",
"0");
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
} else if (pwpolicy->pw_lockout == 1) {
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
}
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
@@ -150,7 +152,7 @@ skip:
}
slapi_add_pwd_control ( pb, LDAP_CONTROL_PWEXPIRED, 0);
}
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
return ( 0 );
@@ -173,7 +175,7 @@ skip:
sprintf ( graceUserTime, "%d", pwdGraceUserTime );
slapi_mods_add_string(&smods, LDAP_MOD_REPLACE,
"passwordGraceUserTime", graceUserTime);
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
if (pwresponse_req) {
/* check for "changeafterreset" condition */
@@ -216,7 +218,7 @@ skip:
pb->pb_op->o_opid, SLAPD_DISCONNECT_UNBIND, 0);
}
/* Apply current modifications */
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
return (-1);
@@ -263,7 +265,7 @@ skip:
*t = (long)diff_t; /* jcm: had to cast double to long */
}
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
if (pwresponse_req) {
/* check for "changeafterreset" condition */
@@ -283,7 +285,7 @@ skip:
return (2);
}
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
/* Leftover from "changeafterreset" condition */
if (pb->pb_conn->c_needpw == 1) {
diff --git a/ldap/servers/slapd/pw_retry.c b/ldap/servers/slapd/pw_retry.c
index 5244622..48849fb 100644
--- a/ldap/servers/slapd/pw_retry.c
+++ b/ldap/servers/slapd/pw_retry.c
@@ -130,7 +130,9 @@ void set_retry_cnt_and_time ( Slapi_PBlock *pb, int count, time_t
cur_time ) {
time_t reset_time;
char *timestr;
passwdPolicy *pwpolicy = NULL;
+ void *txn = NULL;
+ slapi_pblock_get( pb, SLAPI_TXN, &txn );
slapi_pblock_get( pb, SLAPI_TARGET_SDN, &sdn );
dn = slapi_sdn_get_dn(sdn);
pwpolicy = new_passwdPolicy(pb, dn);
@@ -146,7 +148,7 @@ void set_retry_cnt_and_time ( Slapi_PBlock *pb, int count, time_t
cur_time ) {
set_retry_cnt_mods(pb, &smods, count);
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
delete_passwdPolicy(&pwpolicy);
}
@@ -193,11 +195,13 @@ void set_retry_cnt ( Slapi_PBlock *pb, int count)
{
Slapi_DN *sdn = NULL;
Slapi_Mods smods;
-
+ void *txn = NULL;
+
+ slapi_pblock_get( pb, SLAPI_TXN, &txn );
slapi_pblock_get( pb, SLAPI_TARGET_SDN, &sdn );
slapi_mods_init(&smods, 0);
set_retry_cnt_mods(pb, &smods, count);
- pw_apply_mods(sdn, &smods);
+ pw_apply_mods_ext(sdn, &smods, txn);
slapi_mods_done(&smods);
}
@@ -208,6 +212,7 @@ Slapi_Entry *get_entry ( Slapi_PBlock *pb, const char *dn)
Slapi_Entry *retentry = NULL;
Slapi_DN *target_sdn = NULL;
Slapi_DN sdn;
+ void *txn = NULL;
if (NULL == pb) {
LDAPDebug(LDAP_DEBUG_ANY, "get_entry - no pblock specified.\n",
@@ -216,6 +221,7 @@ Slapi_Entry *get_entry ( Slapi_PBlock *pb, const char *dn)
}
slapi_pblock_get( pb, SLAPI_TARGET_SDN, &target_sdn );
+ slapi_pblock_get( pb, SLAPI_TXN, &txn );
if (dn == NULL) {
dn = slapi_sdn_get_dn(target_sdn);
@@ -232,9 +238,9 @@ Slapi_Entry *get_entry ( Slapi_PBlock *pb, const char *dn)
target_sdn = &sdn;
}
- search_result = slapi_search_internal_get_entry(target_sdn, NULL,
- &retentry,
- pw_get_componentID());
+ search_result = slapi_search_internal_get_entry_ext(target_sdn, NULL,
+ &retentry,
+ pw_get_componentID(), txn);
if (search_result != LDAP_SUCCESS) {
LDAPDebug (LDAP_DEBUG_TRACE, "WARNING: 'get_entry' can't find entry
'%s', err %d\n", dn, search_result, 0);
}
@@ -244,7 +250,7 @@ bail:
}
void
-pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
+pw_apply_mods_ext(const Slapi_DN *sdn, Slapi_Mods *mods, void *txn)
{
Slapi_PBlock pb;
int res;
@@ -260,6 +266,7 @@ pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
NULL, /* UniqueID */
pw_get_componentID(), /* PluginID */
OP_FLAG_SKIP_MODIFIED_ATTRS); /* Flags */
+ slapi_pblock_set(&pb, SLAPI_TXN, txn);
slapi_modify_internal_pb (&pb);
slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
@@ -275,6 +282,11 @@ pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
return;
}
+void
+pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
+{
+ pw_apply_mods_ext(sdn, mods, NULL);
+}
/* Handle the component ID for the password policy */
static struct slapi_componentid * pw_componentid = NULL;
commit 89a862674858f3457e360033690e983316a73e50
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Fri Jan 13 12:03:07 2012 -0700
bump version to 1.2.10.a7
diff --git a/VERSION.sh b/VERSION.sh
index 701bddc..fce68b0 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -14,7 +14,7 @@ VERSION_MAINT=10
# if this is a PRERELEASE, set VERSION_PREREL
# otherwise, comment it out
# be sure to include the dot prefix in the prerel
-VERSION_PREREL=.a6
+VERSION_PREREL=.a7
# NOTES on VERSION_PREREL
# use aN for an alpha release e.g. a1, a2, etc.
# use rcN for a release candidate e.g. rc1, rc2, etc.