>From 2d47aaae98953b954898171212e579f3463881a6 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sat, 24 Aug 2013 14:43:57 +0200 Subject: [PATCH 2/3] LDAP: sdap_id_setup_tasks accepts a custom enum request AD provider will override the default with its own. --- src/providers/ipa/ipa_subdomains.c | 4 +++- src/providers/ldap/ldap_common.c | 10 +++++++--- src/providers/ldap/ldap_common.h | 16 ++++++++++++++-- src/providers/ldap/ldap_id_enum.c | 17 +++++------------ 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c index c28af0e76a41352b80ab816076de156607243c1d..496af42b7c134bec8b106b3302cfb09a2a7fbc53 100644 --- a/src/providers/ipa/ipa_subdomains.c +++ b/src/providers/ipa/ipa_subdomains.c @@ -186,7 +186,9 @@ ipa_ad_ctx_new(struct be_ctx *be_ctx, } ret = sdap_id_setup_tasks(ad_id_ctx->sdap_id_ctx, - ad_id_ctx->ldap_ctx, sdom); + ad_id_ctx->ldap_ctx, sdom, + ldap_enumeration_send, + ldap_enumeration_recv); if (ret != EOK) { talloc_free(ad_options); return ret; diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index f7ad71182a4f46a20386e70ffda129347c5e3d87..3058bba4807069fd993c1bdefa9d7f095fe51551 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -938,12 +938,16 @@ void sdap_mark_offline(struct sdap_id_ctx *ctx) int ldap_id_setup_tasks(struct sdap_id_ctx *ctx) { - return sdap_id_setup_tasks(ctx, ctx->conn, ctx->opts->sdom); + return sdap_id_setup_tasks(ctx, ctx->conn, ctx->opts->sdom, + ldap_enumeration_send, + ldap_enumeration_recv); } int sdap_id_setup_tasks(struct sdap_id_ctx *ctx, struct sdap_id_conn_ctx *conn, - struct sdap_domain *sdom) + struct sdap_domain *sdom, + be_ptask_send_t send_fn, + be_ptask_recv_t recv_fn) { struct timeval tv; int ret = EOK; @@ -952,7 +956,7 @@ int sdap_id_setup_tasks(struct sdap_id_ctx *ctx, /* set up enumeration task */ if (sdom->dom->enumerate) { DEBUG(SSSDBG_TRACE_FUNC, ("Setting up enumeration for %s\n", sdom->dom->name)); - ret = ldap_setup_enumeration(ctx, conn, sdom); + ret = ldap_setup_enumeration(ctx, conn, sdom, send_fn, recv_fn); } else { /* the enumeration task, runs the cleanup process by itself, * but if enumeration is not running we need to schedule it */ diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h index e5b7f1151e57fd22bce856c81801c2df7a60f0c3..a2ab16d6e30d9fed12ac949c5e328d721958bc02 100644 --- a/src/providers/ldap/ldap_common.h +++ b/src/providers/ldap/ldap_common.h @@ -95,7 +95,9 @@ void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx, int ldap_id_setup_tasks(struct sdap_id_ctx *ctx); int sdap_id_setup_tasks(struct sdap_id_ctx *ctx, struct sdap_id_conn_ctx *conn, - struct sdap_domain *sdom); + struct sdap_domain *sdom, + be_ptask_send_t send_fn, + be_ptask_recv_t recv_fn); struct tevent_req * sdap_handle_acct_req_send(TALLOC_CTX *mem_ctx, @@ -169,7 +171,17 @@ int ldap_get_autofs_options(TALLOC_CTX *memctx, errno_t ldap_setup_enumeration(struct sdap_id_ctx *ctx, struct sdap_id_conn_ctx *conn, - struct sdap_domain *sdom); + struct sdap_domain *sdom, + be_ptask_send_t send_fn, + be_ptask_recv_t recv_fn); +struct tevent_req * +ldap_enumeration_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct be_ctx *be_ctx, + struct be_ptask *be_ptask, + void *pvt); +errno_t ldap_enumeration_recv(struct tevent_req *req); + errno_t ldap_id_cleanup(struct sdap_options *opts, struct sss_domain_info *dom); int ldap_id_cleanup_create_timer(struct sdap_id_ctx *ctx, diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c index 961c72f3d888fa92d1002ca483776319d007b679..2a42fdafb66eff9640b30c1f21b8c6470f5abc4f 100644 --- a/src/providers/ldap/ldap_id_enum.c +++ b/src/providers/ldap/ldap_id_enum.c @@ -27,14 +27,6 @@ #include "providers/ldap/ldap_common.h" #include "providers/ldap/sdap_async_enum.h" -static struct tevent_req * -ldap_enumeration_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct be_ctx *be_ctx, - struct be_ptask *be_ptask, - void *pvt); -errno_t ldap_enumeration_recv(struct tevent_req *req); - struct ldap_enum_ctx { struct sdap_id_ctx *ctx; struct sdap_domain *sdom; @@ -43,7 +35,9 @@ struct ldap_enum_ctx { errno_t ldap_setup_enumeration(struct sdap_id_ctx *ctx, struct sdap_id_conn_ctx *conn, - struct sdap_domain *sdom) + struct sdap_domain *sdom, + be_ptask_send_t send_fn, + be_ptask_recv_t recv_fn) { errno_t ret; time_t first_delay; @@ -88,7 +82,7 @@ errno_t ldap_setup_enumeration(struct sdap_id_ctx *ctx, 5, /* enabled delay */ period, /* timeout */ BE_PTASK_OFFLINE_SKIP, - ldap_enumeration_send, ldap_enumeration_recv, + send_fn, recv_fn, ectx, "enumeration", &sdom->enum_task); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, @@ -101,7 +95,6 @@ errno_t ldap_setup_enumeration(struct sdap_id_ctx *ctx, return EOK; } - struct ldap_enumeration_state { struct ldap_enum_ctx *ectx; struct sss_domain_info *dom; @@ -109,7 +102,7 @@ struct ldap_enumeration_state { static void ldap_enumeration_done(struct tevent_req *subreq); -static struct tevent_req * +struct tevent_req * ldap_enumeration_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct be_ctx *be_ctx, -- 1.8.3.1