From cbbd8ce524a7e1ae0a1b553c2af18fbef59a06ce Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Jul 29 2015 15:24:15 +0000 Subject: AD: Use ad_site also when site search fails https://fedorahosted.org/sssd/ticket/2725 Some deployments use the ad_site option for cases where the AD clients are not able to find a site for one reason or another. With our current code, the ad_site option value can only override a site that the client found, not supply the value for cases no site could be found. This patch fixes the issue. Reviewed-by: Jakub Hrozek --- diff --git a/src/providers/ad/ad_srv.c b/src/providers/ad/ad_srv.c index 910f82d..123aac6 100644 --- a/src/providers/ad/ad_srv.c +++ b/src/providers/ad/ad_srv.c @@ -541,7 +541,7 @@ done: int ad_get_client_site_recv(TALLOC_CTX *mem_ctx, struct tevent_req *req, const char **_site, - char **_forest) + const char **_forest) { struct ad_get_client_site_state *state = NULL; state = tevent_req_data(req, struct ad_get_client_site_state); @@ -617,7 +617,7 @@ struct ad_srv_plugin_state { const char *site; char *dns_domain; uint32_t ttl; - char *forest; + const char *forest; struct fo_server_info *primary_servers; size_t num_primary_servers; struct fo_server_info *backup_servers; @@ -774,6 +774,14 @@ static void ad_srv_plugin_site_done(struct tevent_req *subreq) "using configured value: '%s' instead.\n", state->site, state->ctx->ad_site_override); state->site = state->ctx->ad_site_override; + + if (state->forest == NULL) { + DEBUG(SSSDBG_TRACE_FUNC, "Missing forest information, using %s\n", + state->discovery_domain); + state->forest = state->discovery_domain; + } + + ret = EOK; } if (ret == EOK) { if (strcmp(state->service, "gc") == 0) {