From 8e26a5bf1b58f6a33cf1b44ab43353ae04beed89 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Wed, 30 Oct 2024 15:41:41 +0100 Subject: [PATCH] subdomains: check when going online Explanation Resolves: https://github.com/SSSD/sssd/issues/XXXX --- src/providers/ldap/sdap_online_check.c | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/providers/ldap/sdap_online_check.c b/src/providers/ldap/sdap_online_check.c index 9c104e54c8b..eaadda9c0ba 100644 --- a/src/providers/ldap/sdap_online_check.c +++ b/src/providers/ldap/sdap_online_check.c @@ -169,9 +169,11 @@ static errno_t sdap_online_check_recv(struct tevent_req *req) struct sdap_online_check_handler_state { struct dp_reply_std reply; + struct sdap_id_ctx *id_ctx; }; static void sdap_online_check_handler_done(struct tevent_req *subreq); +static void sdap_online_check_subdomains_done(struct tevent_req *subreq); struct tevent_req * sdap_online_check_handler_send(TALLOC_CTX *mem_ctx, @@ -191,6 +193,8 @@ sdap_online_check_handler_send(TALLOC_CTX *mem_ctx, return NULL; } + state->id_ctx = id_ctx; + subreq = sdap_online_check_send(state, id_ctx); if (subreq == NULL) { ret = ENOMEM; @@ -223,11 +227,43 @@ static void sdap_online_check_handler_done(struct tevent_req *subreq) ret = sdap_online_check_recv(subreq); talloc_zfree(subreq); + if (ret == EOK) { + subreq = dp_req_send(state->id_ctx->be, state->id_ctx->be->provider, + NULL, "Subdomains Check", 0, NULL, DPT_SUBDOMAINS, + DPM_DOMAINS_HANDLER, 0, NULL , NULL); + if (req != NULL) { + tevent_req_set_callback(subreq, sdap_online_check_subdomains_done, req); + return; + } + } + /* TODO For backward compatibility we always return EOK to DP now. */ dp_reply_std_set(&state->reply, DP_ERR_DECIDE, ret, NULL); tevent_req_done(req); } +static void sdap_online_check_subdomains_done(struct tevent_req *subreq) +{ + struct sdap_online_check_handler_state *state; + struct tevent_req *req; + struct dp_reply_std *reply; + errno_t ret; + + req = tevent_req_callback_data(subreq, struct tevent_req); + state = tevent_req_data(req, struct sdap_online_check_handler_state); + + ret = dp_req_recv_ptr(state, subreq, struct dp_reply_std, &reply); + talloc_zfree(subreq); + + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, "Suddomain online check failed.\n"); + } + + /* We return the EOK of the online check here */ + dp_reply_std_set(&state->reply, DP_ERR_DECIDE, EOK, NULL); + tevent_req_done(req); +} + errno_t sdap_online_check_handler_recv(TALLOC_CTX *mem_ctx, struct tevent_req *req, struct dp_reply_std *data)