diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-12-19 14:59:59 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-12-19 11:38:35 -0500 |
commit | 8edf0e447266d68f10264eb3f3ea514cd1687041 (patch) | |
tree | 8f2c21f5346a0cfba1162165962638a64c3983f6 | |
parent | 69420a154fc9fb8b04f437125a6a0604b26b1292 (diff) | |
download | sssd-8edf0e447266d68f10264eb3f3ea514cd1687041.tar.gz sssd-8edf0e447266d68f10264eb3f3ea514cd1687041.tar.bz2 sssd-8edf0e447266d68f10264eb3f3ea514cd1687041.zip |
Pass sdap_id_ctx to online check from IPA provider
-rw-r--r-- | src/providers/ipa/ipa_id.c | 10 | ||||
-rw-r--r-- | src/providers/ipa/ipa_id.h | 3 | ||||
-rw-r--r-- | src/providers/ipa/ipa_init.c | 2 | ||||
-rw-r--r-- | src/providers/ldap/ldap_common.h | 2 | ||||
-rw-r--r-- | src/providers/ldap/ldap_id.c | 57 |
5 files changed, 56 insertions, 18 deletions
diff --git a/src/providers/ipa/ipa_id.c b/src/providers/ipa/ipa_id.c index a014c9f2..7302a8da 100644 --- a/src/providers/ipa/ipa_id.c +++ b/src/providers/ipa/ipa_id.c @@ -321,3 +321,13 @@ static void ipa_account_info_netgroups_done(struct tevent_req *req) ipa_account_info_complete(breq, dp_error, ret, "Netgroup lookup failed"); } + +void ipa_check_online(struct be_req *be_req) +{ + struct ipa_id_ctx *ipa_ctx; + + ipa_ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_ID].pvt_bet_data, + struct ipa_id_ctx); + + return sdap_do_online_check(be_req, ipa_ctx->sdap_id_ctx); +} diff --git a/src/providers/ipa/ipa_id.h b/src/providers/ipa/ipa_id.h index aa2dfe7f..04a6c2b8 100644 --- a/src/providers/ipa/ipa_id.h +++ b/src/providers/ipa/ipa_id.h @@ -45,4 +45,7 @@ int ipa_get_netgroups_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, size_t *reply_count, struct sysdb_attrs ***reply); + +void ipa_check_online(struct be_req *be_req); + #endif diff --git a/src/providers/ipa/ipa_init.c b/src/providers/ipa/ipa_init.c index 9acee7bf..e16a9533 100644 --- a/src/providers/ipa/ipa_init.c +++ b/src/providers/ipa/ipa_init.c @@ -41,7 +41,7 @@ struct ipa_options *ipa_options = NULL; struct bet_ops ipa_id_ops = { .handler = ipa_account_info_handler, .finalize = NULL, - .check_online = sdap_check_online + .check_online = ipa_check_online }; struct bet_ops ipa_auth_ops = { diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h index d7aa71ab..e6bb8b6a 100644 --- a/src/providers/ldap/ldap_common.h +++ b/src/providers/ldap/ldap_common.h @@ -69,6 +69,8 @@ struct sdap_auth_ctx { }; void sdap_check_online(struct be_req *breq); +void sdap_do_online_check(struct be_req *be_req, struct sdap_id_ctx *ctx); + /* id */ void sdap_account_info_handler(struct be_req *breq); void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx); diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c index a1984cef..feac63b6 100644 --- a/src/providers/ldap/ldap_id.c +++ b/src/providers/ldap/ldap_id.c @@ -666,36 +666,57 @@ static void sdap_check_online_done(struct tevent_req *req); void sdap_check_online(struct be_req *be_req) { struct sdap_id_ctx *ctx; - struct tevent_req *req; ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_ID].pvt_bet_data, struct sdap_id_ctx); + return sdap_do_online_check(be_req, ctx); +} + +struct sdap_online_check_ctx { + struct be_req *be_req; + struct sdap_id_ctx *id_ctx; +}; + +void sdap_do_online_check(struct be_req *be_req, struct sdap_id_ctx *ctx) +{ + struct tevent_req *req; + struct sdap_online_check_ctx *check_ctx; + errno_t ret; + + check_ctx = talloc_zero(be_req, struct sdap_online_check_ctx); + if (!check_ctx) { + ret = ENOMEM; + DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_zero failed\n")); + goto fail; + } + check_ctx->id_ctx = ctx; + check_ctx->be_req = be_req; + req = sdap_cli_connect_send(be_req, be_req->be_ctx->ev, ctx->opts, be_req->be_ctx, ctx->service, false, CON_TLS_DFL, false); if (req == NULL) { DEBUG(1, ("sdap_cli_connect_send failed.\n")); - goto done; + ret = EIO; + goto fail; } - tevent_req_set_callback(req, sdap_check_online_done, be_req); + tevent_req_set_callback(req, sdap_check_online_done, check_ctx); return; -done: - sdap_handler_done(be_req, DP_ERR_FATAL, 0, NULL); +fail: + sdap_handler_done(be_req, DP_ERR_FATAL, ret, NULL); } static void sdap_check_online_done(struct tevent_req *req) { - struct be_req *be_req = tevent_req_callback_data(req, struct be_req); + struct sdap_online_check_ctx *check_ctx = tevent_req_callback_data(req, + struct sdap_online_check_ctx); int ret; int dp_err = DP_ERR_FATAL; bool can_retry; - struct sdap_id_ctx *ctx; struct sdap_server_opts *srv_opts; - - ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_ID].pvt_bet_data, - struct sdap_id_ctx); + struct be_req *be_req; ret = sdap_cli_connect_recv(req, NULL, &can_retry, NULL, &srv_opts); talloc_zfree(req); @@ -707,20 +728,22 @@ static void sdap_check_online_done(struct tevent_req *req) } else { dp_err = DP_ERR_OK; - if (!ctx->srv_opts) { + if (!check_ctx->id_ctx->srv_opts) { srv_opts->max_user_value = 0; srv_opts->max_group_value = 0; - } else if (strcmp(srv_opts->server_id, ctx->srv_opts->server_id) == 0 + } else if (strcmp(srv_opts->server_id, check_ctx->id_ctx->srv_opts->server_id) == 0 && srv_opts->supports_usn - && ctx->srv_opts->last_usn > srv_opts->last_usn) { - ctx->srv_opts->max_user_value = 0; - ctx->srv_opts->max_group_value = 0; - ctx->srv_opts->last_usn = srv_opts->last_usn; + && check_ctx->id_ctx->srv_opts->last_usn > srv_opts->last_usn) { + check_ctx->id_ctx->srv_opts->max_user_value = 0; + check_ctx->id_ctx->srv_opts->max_group_value = 0; + check_ctx->id_ctx->srv_opts->last_usn = srv_opts->last_usn; } - sdap_steal_server_opts(ctx, &srv_opts); + sdap_steal_server_opts(check_ctx->id_ctx, &srv_opts); } + be_req = check_ctx->be_req; + talloc_free(check_ctx); sdap_handler_done(be_req, dp_err, 0, NULL); } |