URL: https://github.com/SSSD/sssd/pull/259 Author: fidencio Title: #259: RESPONDER: Also populate cr_domains when initializing the responders Action: synchronized
To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/259/head:pr259 git checkout pr259
From 58b8041b5ed019eefbe5f262c495a0c116a4ca4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <[email protected]> Date: Wed, 3 May 2017 13:24:40 +0200 Subject: [PATCH] CACHE_REQ: Ensure the domains are updated for "filter" related calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As contacting the infopipe responder on a "filter" related call may lead to the situation where the cr_domains' list is not populated yet (as the domains and subdomains lists from the data provider are not processed yet), let's explicitly call sss_dp_get_domains() for those cases and avoid returning a wrong result to the caller. This situation may happen only because the schedule_get_domains_task(), that's called when the infopipe responder is initialized, may take some time to run/finish. While I'm not exactly sure whether it's the best solution to avoid the "race", it seems to be sane enough to avoid the issues. Resolves: https://pagure.io/SSSD/sssd/issue/3387 Signed-off-by: Fabiano FidĂȘncio <[email protected]> --- src/responder/common/cache_req/cache_req.c | 81 ++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/src/responder/common/cache_req/cache_req.c b/src/responder/common/cache_req/cache_req.c index 797325a..87ec588 100644 --- a/src/responder/common/cache_req/cache_req.c +++ b/src/responder/common/cache_req/cache_req.c @@ -698,6 +698,13 @@ static errno_t cache_req_process_input(TALLOC_CTX *mem_ctx, struct cache_req *cr, const char *domain); +static errno_t cache_req_get_domains(TALLOC_CTX *mem_ctx, + struct tevent_req *req, + struct cache_req *cr, + const char *domain); + +static void cache_req_get_domains_done(struct tevent_req *subreq); + static void cache_req_input_parsed(struct tevent_req *subreq); static errno_t cache_req_select_domains(struct tevent_req *req, @@ -753,12 +760,12 @@ struct tevent_req *cache_req_send(TALLOC_CTX *mem_ctx, goto done; } + state->domain_name = domain; ret = cache_req_process_input(state, req, cr, domain); if (ret != EOK) { goto done; } - state->domain_name = domain; ret = cache_req_select_domains(req, domain); done: @@ -781,14 +788,15 @@ static errno_t cache_req_process_input(TALLOC_CTX *mem_ctx, struct tevent_req *subreq; const char *default_domain; - if (cr->data->name.input == NULL) { - /* Input was not name, there is no need to process it further. */ - return EOK; - } - - if (cr->plugin->parse_name == false || domain != NULL) { - /* We do not want to parse the name. */ - return cache_req_set_name(cr, cr->data->name.input); + if (cr->data->name.input == NULL + || (cr->plugin->parse_name == false || domain != NULL)) { + /* When reaching this point we may end up in a situation where + * the domains and subdomains from the data provider were not + * processed yet. + * + * In this case we just want to call sss_dp_get_domains() and + * do whatevet is needed when it's done. */ + return cache_req_get_domains(mem_ctx, req, cr, domain); } default_domain = NULL; @@ -812,6 +820,61 @@ static errno_t cache_req_process_input(TALLOC_CTX *mem_ctx, return EAGAIN; } +static errno_t cache_req_get_domains(TALLOC_CTX *mem_ctx, + struct tevent_req *req, + struct cache_req *cr, + const char *domain) +{ + struct tevent_req *subreq; + + subreq = sss_dp_get_domains_send(mem_ctx, cr->rctx, false, domain); + if (subreq == NULL) { + return ENOMEM; + } + + tevent_req_set_callback(subreq, cache_req_get_domains_done, req); + return EAGAIN; +} + +static void cache_req_get_domains_done(struct tevent_req *subreq) +{ + struct tevent_req *req; + struct cache_req_state *state; + errno_t ret; + + req = tevent_req_callback_data(subreq, struct tevent_req); + state = tevent_req_data(req, struct cache_req_state); + + ret = sss_dp_get_domains_recv(subreq); + talloc_free(subreq); + if (ret != EOK) { + goto done; + } + + if (state->cr->data->name.input == NULL) { + /* Input was not name, there is no need to process it further */ + goto immediately; + } + + /* If we reach this point, we just do not want to parse the name */ + ret = cache_req_set_name(state->cr, state->cr->data->name.input); + if (ret != EOK) { + goto done; + } + +immediately: + ret = cache_req_select_domains(req, state->domain_name); + +done: + if (ret == EOK) { + tevent_req_done(req); + tevent_req_post(req, state->ev); + } else if (ret != EAGAIN) { + tevent_req_error(req, ret); + tevent_req_post(req, state->ev); + } +} + static void cache_req_input_parsed(struct tevent_req *subreq) { struct tevent_req *req;
_______________________________________________ sssd-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
