summaryrefslogtreecommitdiffstats
path: root/daemons
diff options
context:
space:
mode:
authorLudwig Krispenz <lkrispen@redhat.com>2015-10-30 09:44:21 +0100
committerMartin Basti <mbasti@redhat.com>2015-10-30 13:47:25 +0100
commit3f70c9aed7d1357ac5031b8f8b48af320acba567 (patch)
tree7063cc8f3f69b1156791e97af8a8e8c9746fe107 /daemons
parent22a999267c328bab7fd1d29434ac992f4b02e6c6 (diff)
downloadfreeipa-3f70c9aed7d1357ac5031b8f8b48af320acba567.tar.gz
freeipa-3f70c9aed7d1357ac5031b8f8b48af320acba567.tar.xz
freeipa-3f70c9aed7d1357ac5031b8f8b48af320acba567.zip
update list of managed servers when a suffix becomes managed
when a suffix becomes managed for a host, the host needs to be added to the managed servers, otherwise connectivity check would fail Reviewed-By: Thierry Bordaz <tbordaz@redhat.com>
Diffstat (limited to 'daemons')
-rw-r--r--daemons/ipa-slapi-plugins/topology/topology.h3
-rw-r--r--daemons/ipa-slapi-plugins/topology/topology_cfg.c36
-rw-r--r--daemons/ipa-slapi-plugins/topology/topology_post.c5
-rw-r--r--daemons/ipa-slapi-plugins/topology/topology_util.c28
4 files changed, 42 insertions, 30 deletions
diff --git a/daemons/ipa-slapi-plugins/topology/topology.h b/daemons/ipa-slapi-plugins/topology/topology.h
index fea8281ac..d264ed9c1 100644
--- a/daemons/ipa-slapi-plugins/topology/topology.h
+++ b/daemons/ipa-slapi-plugins/topology/topology.h
@@ -178,7 +178,7 @@ void ipa_topo_lock_conf(void);
void ipa_topo_unlock_conf(void);
int ipa_topo_acquire_startup_inprogress(void);
void ipa_topo_release_startup_inprogress(void);
-void ipa_topo_cfg_host_add(Slapi_Entry *hostentry);
+void ipa_topo_cfg_host_add(TopoReplica *tconf, char *host);
void ipa_topo_cfg_host_del(Slapi_Entry *hostentry);
TopoReplicaHost *ipa_topo_cfg_host_find(TopoReplica *tconf, char *host, int lock);
TopoReplicaHost *ipa_topo_cfg_host_new(char *newhost);
@@ -283,6 +283,7 @@ int ipa_topo_util_setup_servers(void);
void ipa_topo_util_update_segments_for_host(TopoReplica *conf, char *hostname);
char *ipa_topo_util_get_ldap_principal(char *repl_root, char *hostname);
void ipa_topo_util_disable_repl_for_principal(char *repl_root, char *principal);
+void ipa_topo_util_init_hosts(Slapi_Entry *hostentry);
void ipa_topo_util_add_host(Slapi_Entry *hostentry);
void ipa_topo_util_delete_host(Slapi_Entry *hostentry);
void ipa_topo_util_update_host(Slapi_Entry *hostentry, LDAPMod **mods);
diff --git a/daemons/ipa-slapi-plugins/topology/topology_cfg.c b/daemons/ipa-slapi-plugins/topology/topology_cfg.c
index d211f20f6..3ca61a8ea 100644
--- a/daemons/ipa-slapi-plugins/topology/topology_cfg.c
+++ b/daemons/ipa-slapi-plugins/topology/topology_cfg.c
@@ -471,38 +471,22 @@ ipa_topo_cfg_host_new(char *newhost)
}
void
-ipa_topo_cfg_host_add(Slapi_Entry *hostentry)
+ipa_topo_cfg_host_add(TopoReplica *replica, char *newhost)
{
- char *newhost;
- char **repl_root = NULL;
TopoReplicaHost *hostnode = NULL;
- TopoReplica *replica = NULL;
- int i;
-
- newhost = slapi_entry_attr_get_charptr(hostentry,"cn");
- if (newhost == NULL) return;
-
- repl_root = slapi_entry_attr_get_charray(hostentry,"ipaReplTopoManagedSuffix");
- if (repl_root == NULL || *repl_root == NULL) return;
-
- for (i=0; repl_root[i];i++) {
- replica = ipa_topo_cfg_replica_find(repl_root[i], 1);
- if (replica == NULL) continue;
+ if (replica == NULL || newhost == NULL) return;
- slapi_lock_mutex(replica->repl_lock);
- if (ipa_topo_cfg_host_find(replica, newhost, 0)) {
- /* log error */
- slapi_unlock_mutex(replica->repl_lock);
- continue;
- }
- hostnode = ipa_topo_cfg_host_new(slapi_ch_strdup(newhost));
- hostnode->next = replica->hosts;
- replica->hosts = hostnode;
+ slapi_lock_mutex(replica->repl_lock);
+ if (ipa_topo_cfg_host_find(replica, newhost, 0)) {
+ /* host already added */
slapi_unlock_mutex(replica->repl_lock);
+ return;
}
+ hostnode = ipa_topo_cfg_host_new(slapi_ch_strdup(newhost));
+ hostnode->next = replica->hosts;
+ replica->hosts = hostnode;
+ slapi_unlock_mutex(replica->repl_lock);
- slapi_ch_array_free(repl_root);
- slapi_ch_free_string(&newhost);
return;
}
diff --git a/daemons/ipa-slapi-plugins/topology/topology_post.c b/daemons/ipa-slapi-plugins/topology/topology_post.c
index 5ac029a86..c525d1222 100644
--- a/daemons/ipa-slapi-plugins/topology/topology_post.c
+++ b/daemons/ipa-slapi-plugins/topology/topology_post.c
@@ -98,12 +98,11 @@ ipa_topo_post_add(Slapi_PBlock *pb)
break;
}
case TOPO_HOST_ENTRY: {
- /* add to list of managed hosts */
- ipa_topo_cfg_host_add(add_entry);
/* we are adding a new master, there could be
* a segment which so far was inactive since
* the host was not managed
*/
+ /* It will also add to list of managed hosts */
ipa_topo_util_add_host(add_entry);
break;
}
@@ -194,6 +193,8 @@ ipa_topo_post_mod(Slapi_PBlock *pb)
break;
}
case TOPO_HOST_ENTRY: {
+ /* check i host needs to be added to the managed hosts
+ * and if segments need to be created */
ipa_topo_util_update_host(mod_entry, mods);
break;
}
diff --git a/daemons/ipa-slapi-plugins/topology/topology_util.c b/daemons/ipa-slapi-plugins/topology/topology_util.c
index 0e348ca74..de8147a4a 100644
--- a/daemons/ipa-slapi-plugins/topology/topology_util.c
+++ b/daemons/ipa-slapi-plugins/topology/topology_util.c
@@ -278,7 +278,7 @@ ipa_topo_util_setup_servers(void)
} else {
int i = 0;
for (i=0;entries[i];i++) {
- ipa_topo_cfg_host_add(entries[i]);
+ ipa_topo_util_init_hosts(entries[i]);
}
}
}
@@ -1445,12 +1445,38 @@ ipa_topo_util_delete_segments_for_host(char *repl_root, char *delhost)
"ipa_topo_util_delete_segments_for_host <-- done\n");
}
+void
+ipa_topo_util_init_hosts(Slapi_Entry *hostentry)
+{
+ char *newhost;
+ char **repl_root = NULL;
+ TopoReplica *replica = NULL;
+ int i;
+
+ newhost = slapi_entry_attr_get_charptr(hostentry,"cn");
+ if (newhost == NULL) return;
+
+ repl_root = slapi_entry_attr_get_charray(hostentry,"ipaReplTopoManagedSuffix");
+ if (repl_root == NULL || *repl_root == NULL) return;
+
+ for (i=0; repl_root[i];i++) {
+ replica = ipa_topo_cfg_replica_find(repl_root[i], 1);
+ if (replica == NULL) continue;
+
+ ipa_topo_cfg_host_add(replica, newhost);
+ }
+
+ slapi_ch_array_free(repl_root);
+ slapi_ch_free_string(&newhost);
+ return;
+}
void
ipa_topo_util_add_managed_host(char *suffix, char *addhost)
{
TopoReplica *conf = ipa_topo_cfg_replica_find(suffix,1);
if (conf) {
+ ipa_topo_cfg_host_add(conf, addhost);
ipa_topo_util_update_segments_for_host(conf, addhost);
}
}