From 909a86af4eb99f5d311d7136cab78dca535ae304 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Fri, 31 May 2013 10:52:05 +0200 Subject: Lookup domains at startup To make sure that e.g. the short/NetBIOS domain name is available this patch make sure that the responders send a get_domains request to their backends at startup the collect the domain information or read it from the cache if the backend is offline. For completeness I added this to all responders even if they do not need the information at the moment. Fixes https://fedorahosted.org/sssd/ticket/1951 --- src/responder/common/responder_get_domains.c | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/responder/common/responder_get_domains.c') diff --git a/src/responder/common/responder_get_domains.c b/src/responder/common/responder_get_domains.c index defa4a430..592cd8dcd 100644 --- a/src/responder/common/responder_get_domains.c +++ b/src/responder/common/responder_get_domains.c @@ -369,3 +369,52 @@ static errno_t check_last_request(struct resp_ctx *rctx, const char *hint) return EOK; } + +static void get_domains_at_startup_done(struct tevent_req *req) +{ + int ret; + + ret = sss_dp_get_domains_recv(req); + talloc_free(req); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, ("sss_dp_get_domains request failed.\n")); + } + + return; +} + +static void get_domains_at_startup(struct tevent_context *ev, + struct tevent_immediate *imm, + void *pvt) +{ + struct tevent_req *req; + struct resp_ctx *rctx; + + rctx = talloc_get_type(pvt, struct resp_ctx); + + req = sss_dp_get_domains_send(rctx, rctx, true, NULL); + if (req == NULL) { + DEBUG(SSSDBG_OP_FAILURE, ("sss_dp_get_domains_send failed.\n")); + return; + } + + tevent_req_set_callback(req, get_domains_at_startup_done, NULL); + return; +} + +errno_t schedule_get_domains_task(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct resp_ctx *rctx) +{ + struct tevent_immediate *imm; + + imm = tevent_create_immediate(mem_ctx); + if (imm == NULL) { + DEBUG(SSSDBG_OP_FAILURE, ("tevent_create_immediate failed.\n")); + return ENOMEM; + } + + tevent_schedule_immediate(imm, ev, get_domains_at_startup, rctx); + + return EOK; +} -- cgit