Skip to content

Conversation

@pbrezina
Copy link
Member

@pbrezina pbrezina commented Dec 9, 2025

sdap: remove be context from sdap_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).

@pbrezina
Copy link
Member Author

pbrezina commented Dec 9, 2025

The underlying code will be reused in the new failover mechanism, but I expect the the new failover code will likely be part of the master branch before the code starts using it and the old failover is removed, so I'd like to get this reviewed and merged.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the LDAP connection logic by separating server resolution and kinit from the core connection function sdap_cli_connect. The server resolution and kinit logic is moved into a new set of functions, sdap_cli_resolve_and_connect_*. This change is a step towards a new failover mechanism and also changes the authentication flow to perform kinit before connecting to the LDAP server. The changes are mostly in src/providers/ldap/sdap_async_connection.c and affect several call sites. The refactoring is well-structured, but I found one issue where a configuration option check was missed during the refactoring.

@alexey-tikhonov alexey-tikhonov self-assigned this Dec 9, 2025
@alexey-tikhonov alexey-tikhonov self-requested a review December 9, 2025 13:10
@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Dec 9, 2025
To indicate server communication error.
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).
@alexey-tikhonov alexey-tikhonov added the coverity Trigger a coverity scan label Dec 16, 2025
@alexey-tikhonov
Copy link
Member

Note: Covscan is green.

@alexey-tikhonov alexey-tikhonov removed the coverity Trigger a coverity scan label Dec 16, 2025
state->srv = NULL;
state->srv_opts = NULL;
state->use_rootdse = !skip_rootdse;
state->rootdse_access = decide_rootdse_access (opts->basic);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use of rootdse_access in sdap_cli_resolve_and_connect_state?

Btw, copy-pasted with a space before "(" that was removed in sdap_cli_connect_send().

}

ret = decide_tls_usage(state->force_tls, state->opts->basic,
state->service->uri, &state->use_tls);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed here? It will be done (again) in sdap_cli_connect_step() later.

@alexey-tikhonov
Copy link
Member

I did a first round and have no other comments so far (besides two questions inline), but I must admit it's easy to get lost in sdap_cli_connect_step() vs sdap_connect_send, etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants