ldap/servers/plugins/replication/repl5.h | 1
ldap/servers/plugins/replication/repl5_agmt.c | 30 ++++++++++++++++++++++
ldap/servers/plugins/replication/repl5_agmtlist.c | 19 +++++++++++++
3 files changed, 50 insertions(+)
New commits:
commit d4e13f59c12384d608d6c54b1eecea646650f70c
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Mar 4 11:16:59 2014 -0500
Ticket 47727 - Updating nsds5ReplicaHost attribute in a replication agreement fails
with error 53
Description: Allow the modification of the nsds5ReplicaHost in replication
agreements.
https://fedorahosted.org/389/ticket/47727
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5.h
b/ldap/servers/plugins/replication/repl5.h
index 04d5a82..9aee2b5 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -353,6 +353,7 @@ int agmt_set_binddn_from_entry( Repl_Agmt *ra, const Slapi_Entry *e
);
int agmt_set_bind_method_from_entry( Repl_Agmt *ra, const Slapi_Entry *e );
int agmt_set_transportinfo_from_entry( Repl_Agmt *ra, const Slapi_Entry *e );
int agmt_set_port_from_entry( Repl_Agmt *ra, const Slapi_Entry *e );
+int agmt_set_host_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
const char *agmt_get_long_name(const Repl_Agmt *ra);
int agmt_initialize_replica(const Repl_Agmt *agmt);
void agmt_replica_init_done (const Repl_Agmt *agmt);
diff --git a/ldap/servers/plugins/replication/repl5_agmt.c
b/ldap/servers/plugins/replication/repl5_agmt.c
index 4f0fa35..8fb5a02 100644
--- a/ldap/servers/plugins/replication/repl5_agmt.c
+++ b/ldap/servers/plugins/replication/repl5_agmt.c
@@ -1198,6 +1198,36 @@ agmt_set_port_from_entry(Repl_Agmt *ra, const Slapi_Entry *e)
return return_value;
}
+/*
+ * Reset the hostname of the remote replica.
+ *
+ * Returns 0 if hostname is set, or -1 if an error occurred.
+ */
+int
+agmt_set_host_from_entry(Repl_Agmt *ra, const Slapi_Entry *e)
+{
+ Slapi_Attr *sattr = NULL;
+ int return_value = -1;
+
+ PR_ASSERT(NULL != ra);
+ slapi_entry_attr_find(e, type_nsds5ReplicaHost, &sattr);
+ PR_Lock(ra->lock);
+ if (NULL != sattr)
+ {
+ Slapi_Value *sval = NULL;
+ slapi_attr_first_value(sattr, &sval);
+ if (NULL != sval)
+ {
+ ra->hostname = (char *)slapi_value_get_string(sval);
+ return_value = 0;
+ }
+ }
+ PR_Unlock(ra->lock);
+ prot_notify_agmt_changed(ra->protocol, ra->long_name);
+
+ return return_value;
+}
+
static int
agmt_parse_excluded_attrs_filter(const char *attr_string, size_t *offset)
{
diff --git a/ldap/servers/plugins/replication/repl5_agmtlist.c
b/ldap/servers/plugins/replication/repl5_agmtlist.c
index 53c12a9..8a70055 100644
--- a/ldap/servers/plugins/replication/repl5_agmtlist.c
+++ b/ldap/servers/plugins/replication/repl5_agmtlist.c
@@ -368,6 +368,25 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore,
Slapi_Entry
rc = SLAPI_DSE_CALLBACK_ERROR;
}
}
+ else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_nsds5ReplicaHost))
+ {
+ /* New replica host */
+ if (agmt_set_host_from_entry(agmt, e) != 0)
+ {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
+ "agmtlist_modify_callback: "
+ "failed to update host for agreement %s\n",
+ agmt_get_long_name(agmt));
+ *returncode = LDAP_OPERATIONS_ERROR;
+ rc = SLAPI_DSE_CALLBACK_ERROR;
+ } else {
+ /*
+ * Changing the host invalidates the agmt maxcsn, so remove it.
+ * The next update will add the correct maxcsn back to the agmt/local ruv.
+ */
+ agmt_remove_maxcsn(agmt);
+ }
+ }
else if (slapi_attr_types_equivalent(mods[i]->mod_type,
type_nsds5ReplicaPort))
{