|
|
c74acb |
From e07eeea7df55ede36ac0978ac904c1bb11188265 Mon Sep 17 00:00:00 2001
|
|
|
c74acb |
From: Sumit Bose <sbose@redhat.com>
|
|
|
c74acb |
Date: Wed, 20 Jan 2021 17:48:44 +0100
|
|
|
c74acb |
Subject: [PATCH 41/42] responders: add callback to schedule_get_domains_task()
|
|
|
c74acb |
MIME-Version: 1.0
|
|
|
c74acb |
Content-Type: text/plain; charset=UTF-8
|
|
|
c74acb |
Content-Transfer-Encoding: 8bit
|
|
|
c74acb |
|
|
|
c74acb |
To allow responders to run dedicated code at the end of the initial
|
|
|
c74acb |
getDomains request a callback is added.
|
|
|
c74acb |
|
|
|
c74acb |
Resolves: https://github.com/SSSD/sssd/issues/5469
|
|
|
c74acb |
|
|
|
c74acb |
Reviewed-by: Tomáš Halman <thalman@redhat.com>
|
|
|
c74acb |
---
|
|
|
c74acb |
src/responder/autofs/autofssrv.c | 2 +-
|
|
|
c74acb |
src/responder/common/responder.h | 5 ++++-
|
|
|
c74acb |
src/responder/common/responder_get_domains.c | 12 +++++++++++-
|
|
|
c74acb |
src/responder/ifp/ifpsrv.c | 2 +-
|
|
|
c74acb |
src/responder/nss/nsssrv.c | 3 ++-
|
|
|
c74acb |
src/responder/pac/pacsrv.c | 2 +-
|
|
|
c74acb |
src/responder/pam/pamsrv.c | 3 ++-
|
|
|
c74acb |
src/responder/ssh/sshsrv.c | 2 +-
|
|
|
c74acb |
src/responder/sudo/sudosrv.c | 2 +-
|
|
|
c74acb |
src/tests/cmocka/test_responder_common.c | 2 +-
|
|
|
c74acb |
10 files changed, 25 insertions(+), 10 deletions(-)
|
|
|
c74acb |
|
|
|
c74acb |
diff --git a/src/responder/autofs/autofssrv.c b/src/responder/autofs/autofssrv.c
|
|
|
c74acb |
index 27de1b44a..130eaf775 100644
|
|
|
c74acb |
--- a/src/responder/autofs/autofssrv.c
|
|
|
c74acb |
+++ b/src/responder/autofs/autofssrv.c
|
|
|
c74acb |
@@ -142,7 +142,7 @@ autofs_process_init(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
}
|
|
|
c74acb |
|
|
|
c74acb |
- ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
|
|
|
c74acb |
+ ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL, NULL, NULL);
|
|
|
c74acb |
if (ret != EOK) {
|
|
|
c74acb |
DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
|
|
|
c74acb |
index f83ba1bc0..ff0559c08 100644
|
|
|
c74acb |
--- a/src/responder/common/responder.h
|
|
|
c74acb |
+++ b/src/responder/common/responder.h
|
|
|
c74acb |
@@ -366,10 +366,13 @@ errno_t sss_dp_get_account_domain_recv(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
struct tevent_req *req,
|
|
|
c74acb |
char **_domain);
|
|
|
c74acb |
|
|
|
c74acb |
+typedef void (get_domains_callback_fn_t)(void *);
|
|
|
c74acb |
errno_t schedule_get_domains_task(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
struct tevent_context *ev,
|
|
|
c74acb |
struct resp_ctx *rctx,
|
|
|
c74acb |
- struct sss_nc_ctx *optional_ncache);
|
|
|
c74acb |
+ struct sss_nc_ctx *optional_ncache,
|
|
|
c74acb |
+ get_domains_callback_fn_t *callback,
|
|
|
c74acb |
+ void *callback_pvt);
|
|
|
c74acb |
|
|
|
c74acb |
errno_t csv_string_to_uid_array(TALLOC_CTX *mem_ctx, const char *csv_string,
|
|
|
c74acb |
bool allow_sss_loop,
|
|
|
c74acb |
diff --git a/src/responder/common/responder_get_domains.c b/src/responder/common/responder_get_domains.c
|
|
|
c74acb |
index e551b0fff..12b6e9028 100644
|
|
|
c74acb |
--- a/src/responder/common/responder_get_domains.c
|
|
|
c74acb |
+++ b/src/responder/common/responder_get_domains.c
|
|
|
c74acb |
@@ -430,6 +430,8 @@ static errno_t check_last_request(struct resp_ctx *rctx, const char *hint)
|
|
|
c74acb |
struct get_domains_state {
|
|
|
c74acb |
struct resp_ctx *rctx;
|
|
|
c74acb |
struct sss_nc_ctx *optional_ncache;
|
|
|
c74acb |
+ get_domains_callback_fn_t *callback;
|
|
|
c74acb |
+ void *callback_pvt;
|
|
|
c74acb |
};
|
|
|
c74acb |
|
|
|
c74acb |
static void get_domains_at_startup_done(struct tevent_req *req)
|
|
|
c74acb |
@@ -462,6 +464,10 @@ static void get_domains_at_startup_done(struct tevent_req *req)
|
|
|
c74acb |
}
|
|
|
c74acb |
}
|
|
|
c74acb |
|
|
|
c74acb |
+ if (state->callback != NULL) {
|
|
|
c74acb |
+ state->callback(state->callback_pvt);
|
|
|
c74acb |
+ }
|
|
|
c74acb |
+
|
|
|
c74acb |
talloc_free(state);
|
|
|
c74acb |
return;
|
|
|
c74acb |
}
|
|
|
c74acb |
@@ -489,7 +495,9 @@ static void get_domains_at_startup(struct tevent_context *ev,
|
|
|
c74acb |
errno_t schedule_get_domains_task(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
struct tevent_context *ev,
|
|
|
c74acb |
struct resp_ctx *rctx,
|
|
|
c74acb |
- struct sss_nc_ctx *optional_ncache)
|
|
|
c74acb |
+ struct sss_nc_ctx *optional_ncache,
|
|
|
c74acb |
+ get_domains_callback_fn_t *callback,
|
|
|
c74acb |
+ void *callback_pvt)
|
|
|
c74acb |
{
|
|
|
c74acb |
struct tevent_immediate *imm;
|
|
|
c74acb |
struct get_domains_state *state;
|
|
|
c74acb |
@@ -500,6 +508,8 @@ errno_t schedule_get_domains_task(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
}
|
|
|
c74acb |
state->rctx = rctx;
|
|
|
c74acb |
state->optional_ncache = optional_ncache;
|
|
|
c74acb |
+ state->callback = callback;
|
|
|
c74acb |
+ state->callback_pvt = callback_pvt;
|
|
|
c74acb |
|
|
|
c74acb |
imm = tevent_create_immediate(mem_ctx);
|
|
|
c74acb |
if (imm == NULL) {
|
|
|
c74acb |
diff --git a/src/responder/ifp/ifpsrv.c b/src/responder/ifp/ifpsrv.c
|
|
|
c74acb |
index 7407ee07b..ee1452728 100644
|
|
|
c74acb |
--- a/src/responder/ifp/ifpsrv.c
|
|
|
c74acb |
+++ b/src/responder/ifp/ifpsrv.c
|
|
|
c74acb |
@@ -266,7 +266,7 @@ int ifp_process_init(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
return EIO;
|
|
|
c74acb |
}
|
|
|
c74acb |
|
|
|
c74acb |
- ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
|
|
|
c74acb |
+ ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL, NULL, NULL);
|
|
|
c74acb |
if (ret != EOK) {
|
|
|
c74acb |
DEBUG(SSSDBG_FATAL_FAILURE,
|
|
|
c74acb |
"schedule_get_domains_tasks failed.\n");
|
|
|
c74acb |
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
|
|
|
c74acb |
index e80104e3d..2b7958e80 100644
|
|
|
c74acb |
--- a/src/responder/nss/nsssrv.c
|
|
|
c74acb |
+++ b/src/responder/nss/nsssrv.c
|
|
|
c74acb |
@@ -557,7 +557,8 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
}
|
|
|
c74acb |
responder_set_fd_limit(fd_limit);
|
|
|
c74acb |
|
|
|
c74acb |
- ret = schedule_get_domains_task(rctx, rctx->ev, rctx, nctx->rctx->ncache);
|
|
|
c74acb |
+ ret = schedule_get_domains_task(rctx, rctx->ev, rctx, nctx->rctx->ncache,
|
|
|
c74acb |
+ NULL, NULL);
|
|
|
c74acb |
if (ret != EOK) {
|
|
|
c74acb |
DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
diff --git a/src/responder/pac/pacsrv.c b/src/responder/pac/pacsrv.c
|
|
|
c74acb |
index 217f83c26..96935150b 100644
|
|
|
c74acb |
--- a/src/responder/pac/pacsrv.c
|
|
|
c74acb |
+++ b/src/responder/pac/pacsrv.c
|
|
|
c74acb |
@@ -129,7 +129,7 @@ int pac_process_init(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
}
|
|
|
c74acb |
|
|
|
c74acb |
- ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
|
|
|
c74acb |
+ ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL, NULL, NULL);
|
|
|
c74acb |
if (ret != EOK) {
|
|
|
c74acb |
DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c
|
|
|
c74acb |
index de1620e82..8b1ce2e92 100644
|
|
|
c74acb |
--- a/src/responder/pam/pamsrv.c
|
|
|
c74acb |
+++ b/src/responder/pam/pamsrv.c
|
|
|
c74acb |
@@ -246,7 +246,8 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
}
|
|
|
c74acb |
responder_set_fd_limit(fd_limit);
|
|
|
c74acb |
|
|
|
c74acb |
- ret = schedule_get_domains_task(rctx, rctx->ev, rctx, pctx->rctx->ncache);
|
|
|
c74acb |
+ ret = schedule_get_domains_task(rctx, rctx->ev, rctx, pctx->rctx->ncache,
|
|
|
c74acb |
+ NULL, NULL);
|
|
|
c74acb |
if (ret != EOK) {
|
|
|
c74acb |
DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
|
|
|
c74acb |
goto done;
|
|
|
c74acb |
diff --git a/src/responder/ssh/sshsrv.c b/src/responder/ssh/sshsrv.c
|
|
|
c74acb |
index 6072a702c..e79a0438c 100644
|
|
|
c74acb |
--- a/src/responder/ssh/sshsrv.c
|
|
|
c74acb |
+++ b/src/responder/ssh/sshsrv.c
|
|
|
c74acb |
@@ -126,7 +126,7 @@ int ssh_process_init(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
}
|
|
|
c74acb |
|
|
|
c74acb |
- ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
|
|
|
c74acb |
+ ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL, NULL, NULL);
|
|
|
c74acb |
if (ret != EOK) {
|
|
|
c74acb |
DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
diff --git a/src/responder/sudo/sudosrv.c b/src/responder/sudo/sudosrv.c
|
|
|
c74acb |
index 5951b17b1..dc4a44b2f 100644
|
|
|
c74acb |
--- a/src/responder/sudo/sudosrv.c
|
|
|
c74acb |
+++ b/src/responder/sudo/sudosrv.c
|
|
|
c74acb |
@@ -102,7 +102,7 @@ int sudo_process_init(TALLOC_CTX *mem_ctx,
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
}
|
|
|
c74acb |
|
|
|
c74acb |
- ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL);
|
|
|
c74acb |
+ ret = schedule_get_domains_task(rctx, rctx->ev, rctx, NULL, NULL, NULL);
|
|
|
c74acb |
if (ret != EOK) {
|
|
|
c74acb |
DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
|
|
|
c74acb |
goto fail;
|
|
|
c74acb |
diff --git a/src/tests/cmocka/test_responder_common.c b/src/tests/cmocka/test_responder_common.c
|
|
|
c74acb |
index 5fc0d712d..29356253b 100644
|
|
|
c74acb |
--- a/src/tests/cmocka/test_responder_common.c
|
|
|
c74acb |
+++ b/src/tests/cmocka/test_responder_common.c
|
|
|
c74acb |
@@ -265,7 +265,7 @@ void test_schedule_get_domains_task(void **state)
|
|
|
c74acb |
ret = schedule_get_domains_task(dummy_ncache_ptr,
|
|
|
c74acb |
parse_inp_ctx->rctx->ev,
|
|
|
c74acb |
parse_inp_ctx->rctx,
|
|
|
c74acb |
- dummy_ncache_ptr);
|
|
|
c74acb |
+ dummy_ncache_ptr, NULL, NULL);
|
|
|
c74acb |
assert_int_equal(ret, EOK);
|
|
|
c74acb |
|
|
|
c74acb |
ret = test_ev_loop(parse_inp_ctx->tctx);
|
|
|
c74acb |
--
|
|
|
c74acb |
2.21.3
|
|
|
c74acb |
|