From 52e37398d99603472946ea04180216a573a456c3 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Tue, 4 Mar 2014 11:16:59 -0500 Subject: [PATCH] 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: ? --- 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(+), 0 deletions(-) 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)) { -- 1.7.1