Skip to content

Commit c95978d

Browse files
committed
sbus: remove be context from sbus_cli_connect code
This is a steps towards new implementation of new failover mechanism. The new code will reuse sdap_cli_connect to connect to the LDAP server but it will not use any be resolver stuff. This patch moves be resolver usage one level up so the connection code can be easily reused. It also moves kinit before connecting to LDAP into a separate, standalone step (previously it was connect -> kinit -> sasl bind, now it is kinit -> connect -> sasl bind).
1 parent 918fd83 commit c95978d

File tree

6 files changed

+371
-216
lines changed

6 files changed

+371
-216
lines changed

src/providers/ipa/ipa_auth.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,11 @@ static void ipa_pam_auth_handler_flag_done(struct tevent_req *subreq)
329329

330330
if (password_migration) {
331331
sdap_auth_ctx = state->auth_ctx->sdap_auth_ctx;
332-
subreq = sdap_cli_connect_send(state, state->ev,
333-
sdap_auth_ctx->opts,
334-
sdap_auth_ctx->be,
335-
sdap_auth_ctx->service,
336-
true, CON_TLS_ON, true);
332+
subreq = sdap_cli_resolve_and_connect_send(state, state->ev,
333+
sdap_auth_ctx->opts,
334+
sdap_auth_ctx->be,
335+
sdap_auth_ctx->service,
336+
true, CON_TLS_ON, true);
337337
if (subreq == NULL) {
338338
state->pd->pam_status = PAM_SYSTEM_ERR;
339339
goto done;
@@ -373,7 +373,7 @@ static void ipa_pam_auth_handler_connect_done(struct tevent_req *subreq)
373373

374374
state->pd->pam_status = PAM_SYSTEM_ERR;
375375

376-
ret = sdap_cli_connect_recv(subreq, state, NULL, &sh, NULL);
376+
ret = sdap_cli_resolve_and_connect_recv(subreq, state, NULL, &sh, NULL);
377377
talloc_free(subreq);
378378
if (ret != EOK) {
379379
DEBUG(SSSDBG_OP_FAILURE, "Cannot connect to LDAP server to perform "

src/providers/ldap/ldap_auth.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -797,11 +797,12 @@ static struct tevent_req *auth_connect_send(struct tevent_req *req)
797797
use_tls = false;
798798
}
799799

800-
subreq = sdap_cli_connect_send(state, state->ev, state->ctx->opts,
801-
state->ctx->be,
802-
state->sdap_service, false,
803-
use_tls ? CON_TLS_ON : CON_TLS_OFF,
804-
skip_conn_auth);
800+
subreq = sdap_cli_resolve_and_connect_send(state, state->ev,
801+
state->ctx->opts,
802+
state->ctx->be,
803+
state->sdap_service, false,
804+
use_tls ? CON_TLS_ON : CON_TLS_OFF,
805+
skip_conn_auth);
805806

806807
if (subreq == NULL) {
807808
tevent_req_error(req, ENOMEM);
@@ -850,16 +851,18 @@ static void auth_connect_done(struct tevent_req *subreq)
850851
struct auth_state);
851852
int ret;
852853

853-
ret = sdap_cli_connect_recv(subreq, state, NULL, &state->sh, NULL);
854+
ret = sdap_cli_resolve_and_connect_recv(subreq, state, NULL, &state->sh,
855+
NULL);
854856
talloc_zfree(subreq);
855857
if (ret != EOK) {
856-
/* As sdap_cli_connect_recv() returns EIO in case all the servers are
857-
* down and we have to go offline, let's treat it accordingly here and
858-
* allow the PAM responder to switch to offline authentication.
858+
/* As sdap_cli_resolve_and_connect_recv() returns EIO in case all the
859+
* servers are down and we have to go offline, let's treat it
860+
* accordingly here and allow the PAM responder to switch to offline
861+
* authentication.
859862
*
860863
* Unfortunately, there's not much pattern within our code and the way
861-
* to indicate we're going down in this part of the code is returning
862-
* an ETIMEDOUT.
864+
* to indicate we're going down in this part of the code is returning an
865+
* ETIMEDOUT.
863866
*/
864867
if (ret == EIO) {
865868
tevent_req_error(req, ETIMEDOUT);

src/providers/ldap/sdap_async.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,37 @@ enum connect_tls {
213213
struct tevent_req *sdap_cli_connect_send(TALLOC_CTX *memctx,
214214
struct tevent_context *ev,
215215
struct sdap_options *opts,
216-
struct be_ctx *be,
217-
struct sdap_service *service,
216+
const char *uri,
217+
struct sockaddr *sockaddr,
218+
socklen_t sockaddr_len,
218219
bool skip_rootdse,
219220
enum connect_tls force_tls,
220-
bool skip_auth);
221+
bool skip_auth,
222+
time_t kinit_expire_time);
223+
221224
int sdap_cli_connect_recv(struct tevent_req *req,
222225
TALLOC_CTX *memctx,
223-
bool *can_retry,
224226
struct sdap_handle **gsh,
225227
struct sdap_server_opts **srv_opts);
226228

229+
struct tevent_req *
230+
sdap_cli_resolve_and_connect_send(TALLOC_CTX *mem_ctx,
231+
struct tevent_context *ev,
232+
struct sdap_options *opts,
233+
struct be_ctx *be,
234+
struct sdap_service *service,
235+
bool skip_rootdse,
236+
enum connect_tls force_tls,
237+
bool skip_auth);
238+
239+
errno_t
240+
sdap_cli_resolve_and_connect_recv(struct tevent_req *req,
241+
TALLOC_CTX *memctx,
242+
bool *can_retry,
243+
struct sdap_handle **gsh,
244+
struct sdap_server_opts **srv_opts);
245+
246+
227247
/* Exposes all options of generic send while allowing to parse by map */
228248
struct tevent_req *sdap_get_and_parse_generic_send(TALLOC_CTX *memctx,
229249
struct tevent_context *ev,

0 commit comments

Comments
 (0)