>From 09a30632e4a925daa011904a75709830c6f360d7 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 21 Jul 2015 16:24:36 +0200 Subject: [PATCH] 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. --- src/providers/ad/ad_srv.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/providers/ad/ad_srv.c b/src/providers/ad/ad_srv.c index 910f82dd049902c01bdb14edf0cdf44b18c94b0b..f3a4e64e6c9fa8e2535826b9784ebfc2cbbeaaa0 100644 --- a/src/providers/ad/ad_srv.c +++ b/src/providers/ad/ad_srv.c @@ -775,6 +775,7 @@ static void ad_srv_plugin_site_done(struct tevent_req *subreq) state->site, state->ctx->ad_site_override); state->site = state->ctx->ad_site_override; } + if (ret == EOK) { if (strcmp(state->service, "gc") == 0) { primary_domain = talloc_asprintf(state, AD_SITE_DOMAIN_FMT, @@ -796,8 +797,19 @@ static void ad_srv_plugin_site_done(struct tevent_req *subreq) backup_domain = state->discovery_domain; } } else if (ret == ENOENT) { - primary_domain = state->discovery_domain; - backup_domain = NULL; + if (state->site != NULL) { + primary_domain = talloc_asprintf(state, AD_SITE_DOMAIN_FMT, + state->site, state->discovery_domain); + if (primary_domain == NULL) { + ret = ENOMEM; + goto done; + } + + backup_domain = state->discovery_domain; + } else { + primary_domain = state->discovery_domain; + backup_domain = NULL; + } } else { goto done; } -- 2.4.3