>From 160d88b3c1ac0f1e019f19c7836fd232755222e9 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 31 Jul 2012 17:25:35 +0200 Subject: [PATCH] Failover: Return last tried server if it's still being tried In the failover, we treat both KDC and LDAP on the IPA server as a single "port", numbered 0. This was done in order to make sure that the SSSD always talks to the same server for both LDAP and Kerberos. However, this clever hack breaks when the IPA provider needs to establish an GSSAPI encrypted LDAP connection because we're asking the fail over code to yield a server while no server has yet been marked as tried. This triggers a fail over for the KDC, so in effect, the TGT is received from second server. If the second server is not available for some reason, the whole provider goes offline. The fail over needs to detect that the server asked for is still being resolved and return the same pointer. --- src/providers/fail_over.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c index 5ef1436de354fd70a80d35420aa1ce871fdd4657..b3dc25f9b79557a6b56c935de93d3f9760f5f284 100644 --- a/src/providers/fail_over.c +++ b/src/providers/fail_over.c @@ -74,7 +74,7 @@ struct fo_server { void *user_data; int port; - int port_status; + enum port_status port_status; struct srv_data *srv_data; struct fo_service *service; struct timeval last_status_change; @@ -670,6 +670,15 @@ get_first_server_entity(struct fo_service *service, struct fo_server **_server) /* First, try servers after the last one we tried. */ if (service->last_tried_server != NULL) { + /* In case this is a recursive resolve request in setups + * that treat services as monolithic, such as getting a TGT + * for an LDAP search, just return the server that is being + * tried */ + if (service->last_tried_server->port_status == PORT_NEUTRAL) { + server = service->last_tried_server; + goto done; + } + DLIST_FOR_EACH(server, service->last_tried_server->next) { if (service_works(server)) { goto done; -- 1.7.10.4