The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Asynchronous connection management functions for LDAP. More...
#include <freeradius-devel/ldap/base.h>
#include <freeradius-devel/util/debug.h>
Go to the source code of this file.
Macros | |
#define | do_ldap_option(_option, _name, _value) |
#define | maybe_ldap_option(_option, _name, _value) if (_value) do_ldap_option(_option, _name, _value) |
#define | POPULATE_LDAP_CONTROLS(_dest, _src) |
Functions | |
static void | _ldap_connection_close (fr_event_list_t *el, void *h, UNUSED void *uctx) |
Free the handle, closing the connection to ldap. More... | |
static void | _ldap_connection_close_watch (connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Watcher for LDAP connections being closed. More... | |
static int | _ldap_connection_free (fr_ldap_connection_t *c) |
Close and delete a connection. More... | |
static void | _ldap_trunk_idle_timeout (fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Callback for closing idle LDAP trunk. More... | |
static int | _thread_ldap_trunk_free (fr_ldap_thread_trunk_t *ttrunk) |
CC_NO_UBSAN (function) | |
(Re-)Initialises the libldap side of the connection handle More... | |
fr_ldap_connection_t * | fr_ldap_connection_alloc (TALLOC_CTX *ctx) |
Allocate our ldap connection handle layer. More... | |
int | fr_ldap_connection_configure (fr_ldap_connection_t *c, fr_ldap_config_t const *config) |
Allocate and configure a new connection. More... | |
connection_t * | fr_ldap_connection_state_alloc (TALLOC_CTX *ctx, fr_event_list_t *el, fr_ldap_config_t const *config, char const *log_prefix) |
Alloc a self re-establishing connection to an LDAP server. More... | |
int | fr_ldap_connection_timeout_reset (fr_ldap_connection_t const *c) |
int | fr_ldap_connection_timeout_set (fr_ldap_connection_t const *c, fr_time_delta_t timeout) |
fr_ldap_thread_trunk_t * | fr_thread_ldap_bind_trunk_get (fr_ldap_thread_t *thread) |
Find the thread specific trunk to use for LDAP bind auths. More... | |
fr_ldap_thread_trunk_t * | fr_thread_ldap_trunk_get (fr_ldap_thread_t *thread, char const *uri, char const *bind_dn, char const *bind_password, request_t *request, fr_ldap_config_t const *config) |
Find a thread specific LDAP connection for a specific URI / bind DN. More... | |
trunk_state_t | fr_thread_ldap_trunk_state (fr_ldap_thread_t *thread, char const *uri, char const *bind_dn) |
Lookup the state of a thread specific LDAP connection trunk for a specific URI / bind DN. More... | |
static void | ldap_request_cancel (UNUSED connection_t *conn, void *preq, UNUSED trunk_cancel_reason_t reason, UNUSED void *uctx) |
Callback when an LDAP trunk request is cancelled. More... | |
static void | ldap_request_fail (request_t *request, void *preq, UNUSED void *rctx, UNUSED trunk_request_state_t state, UNUSED void *uctx) |
Callback to tidy up when a trunk request fails. More... | |
static void | ldap_trunk_bind_auth_fail (request_t *request, void *preq, UNUSED void *rctx, UNUSED trunk_request_state_t state, UNUSED void *uctx) |
Callback to tidy up when a bind auth trunk request fails. More... | |
Variables | |
static USES_APPLE_DEPRECATED_API char const * | ldap_msg_types [UINT8_MAX] |
Asynchronous connection management functions for LDAP.
Definition in file connection.c.
#define do_ldap_option | ( | _option, | |
_name, | |||
_value | |||
) |
#define maybe_ldap_option | ( | _option, | |
_name, | |||
_value | |||
) | if (_value) do_ldap_option(_option, _name, _value) |
#define POPULATE_LDAP_CONTROLS | ( | _dest, | |
_src | |||
) |
Definition at line 552 of file connection.c.
|
static |
Free the handle, closing the connection to ldap.
[in] | el | UNUSED. |
[in] | h | to close. |
[in] | uctx | Connection config and handle. |
Definition at line 195 of file connection.c.
|
static |
Watcher for LDAP connections being closed.
If there are any outstanding queries on the connection then re-parent the connection to the NULL ctx so that it remains until all the queries have been dealt with.
Definition at line 286 of file connection.c.
|
static |
Close and delete a connection.
Unbinds the LDAP connection, informing the server and freeing any memory, then releases the memory used by the connection handle.
[in] | c | to destroy. |
Definition at line 221 of file connection.c.
|
static |
Callback for closing idle LDAP trunk.
Definition at line 456 of file connection.c.
|
static |
Definition at line 897 of file connection.c.
CC_NO_UBSAN | ( | function | ) |
(Re-)Initialises the libldap side of the connection handle
A special version of the trunk/event loop glue function which always discards incoming data.
Return how many nodes there are in a trie.
Remove an entry, without freeing the data.
Insert data into a trie.
Match an element exactly in the trie, returning the data.
Return how many nodes there are in a tree.
Remove node and free data (if a free function was specified)
Remove an entry from the tree, without freeing the data.
Insert data into a tree.
Remove and free data (if a free function was specified)
Remove an entry from the hash table, without freeing the data.
Replace old data with new data, OR insert if there is no old.
Insert data into a hash table.
Return the next item, starting with the current item, that satisfies an evaluation function.
Return the first item that satisfies an evaluation function.
Return the next item, skipping the current item, that satisfies an evaluation function.
Callback to cancel LDAP bind auth.
Read LDAP bind auth responses.
Take pending LDAP bind auths from the queue and send them.
Read LDAP responses.
Take LDAP pending queries from the queue and send them.
Allocate an LDAP trunk connection.
Callback to cancel LDAP queries.
The first ldap state transition is either:
init -> start tls or init -> bind
Either way libldap will try an open the connection so when fr_ldap_state_next returns we should have the file descriptor to pass back.
The complete order of operations is:
[out] | h | Underlying file descriptor from libldap handle. |
[in] | conn | Being initialised. |
[in] | uctx | Our LDAP connection handle (a fr_ldap_connection_t). |
Inform the remote LDAP server that we no longer want responses to specific queries.
[in] | el | For timer management. |
[in] | tconn | The trunk connection handle |
[in] | conn | The specific connection queries will be cancelled on |
[in] | uctx | Context provided to trunk_alloc |
[in] | tconn | Trunk handle. |
[in] | el | Event list which will be used for I/O and timer events. |
[in] | conn_conf | Configuration of the connection. |
[in] | log_prefix | What to prefix log messages with. |
[in] | uctx | User context passed to trunk_alloc. |
[in] | el | Event list for timers. |
[in] | tconn | Trunk handle. |
[in] | conn | on which to send the queries |
[in] | uctx | User context passed to trunk_alloc |
Responses from the LDAP server will cause the fd to become readable and trigger this callback. Most LDAP search responses have multiple messages in their response - we only gather those which are complete before either following a referral or passing the head of the resulting chain of messages back.
[in] | el | To insert timers into. |
[in] | tconn | Trunk connection associated with these results. |
[in] | conn | Connection handle for these results. |
[in] | uctx | Thread specific trunk structure - contains tree of pending queries. |
[in] | el | To insert timers into. |
[in] | tconn | Trunk connection associated with these results. |
[in] | conn | Connection handle for these results. |
[in] | uctx | Thread specific trunk structure - contains tree of pending queries. |
Inform the remote LDAP server that we no longer want responses to specific bind.
[in] | el | For timer management. |
[in] | tconn | The trunk connection handle |
[in] | conn | The specific connection binds will be cancelled on |
[in] | uctx | Context provided to trunk_alloc |
[in] | cursor | to operate on |
[in] | eval | evaluation function |
[in] | uctx | context for the evaluation function |
[in] | cursor | to operate on |
[in] | eval | evaluation function |
[in] | uctx | context for the evaluation function |
[in] | ht | to insert data into. |
[in] | data | to insert. Will be passed to the hashing function. |
[out] | old | data that was replaced. If this argument is not NULL, then the old data will not be freed, even if a free function is configured. |
[in] | ht | to insert data into. |
[in] | data | to replace. Will be passed to the hashing function. |
[in] | ht | to remove data from. |
[in] | data | to remove. Will be passed to the hashing function. |
[in] | ht | to remove data from. |
[in] | data | to remove/free. |
[in] | tree | to insert data into. |
[in] | data | to insert. |
[out] | old | data that was replaced. If this argument is not NULL, then the old data will not be freed, even if a free function is configured. |
[in] | tree | to insert data into. |
[in] | data | to replace. |
[in] | tree | to remove data from. |
[in] | data | to remove. |
[in] | tree | to remove data from. |
[in] | data | to remove/free. |
[in] | tree | to return node count for. |
[in] | ft | to search in. |
[in] | data | to find. |
[in] | ft | to insert data into. |
[in] | data | to insert. |
[out] | old | data that was replaced. If this argument is not NULL, then the old data will not be freed, even if a free function is configured. |
[in] | ft | to insert data into. |
[in] | data | to replace. |
[in] | ft | to remove data from. |
[in] | data | to remove. |
[in] | ft | to remove data from. |
[in] | data | to remove/free. |
[in] | ft | to return node count for. |
Definition at line 341 of file connection.c.
fr_ldap_connection_t* fr_ldap_connection_alloc | ( | TALLOC_CTX * | ctx | ) |
Allocate our ldap connection handle layer.
This is using handles outside of the connection state machine.
[in] | ctx | to allocate connection handle in. |
Definition at line 258 of file connection.c.
int fr_ldap_connection_configure | ( | fr_ldap_connection_t * | c, |
fr_ldap_config_t const * | config | ||
) |
Allocate and configure a new connection.
Configures both our ldap handle, and libldap's handle.
This can be used by async code and async code as no attempt is made to connect to the LDAP server. An attempt will only be made if ldap_start_tls* or ldap_bind* functions are called.
If called on an fr_ldap_connection_t which has already been initialised, will clear any memory allocated to the connection, unbind the ldap handle, and reinitialise everything.
[in] | c | to configure. |
[in] | config | to apply. |
Definition at line 67 of file connection.c.
connection_t* fr_ldap_connection_state_alloc | ( | TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
fr_ldap_config_t const * | config, | ||
char const * | log_prefix | ||
) |
Alloc a self re-establishing connection to an LDAP server.
[in] | ctx | to allocate any memory in, and to bind the lifetime of the connection to. |
[in] | el | to insert I/O and timer callbacks into. |
[in] | config | to use to bind the connection to an LDAP server. |
[in] | log_prefix | to prepend to connection state messages. |
Definition at line 386 of file connection.c.
int fr_ldap_connection_timeout_reset | ( | fr_ldap_connection_t const * | c | ) |
int fr_ldap_connection_timeout_set | ( | fr_ldap_connection_t const * | c, |
fr_time_delta_t | timeout | ||
) |
fr_ldap_thread_trunk_t* fr_thread_ldap_bind_trunk_get | ( | fr_ldap_thread_t * | thread | ) |
Find the thread specific trunk to use for LDAP bind auths.
If there is no current trunk then a new one is created.
[in] | thread | to which the connection belongs |
Definition at line 1295 of file connection.c.
fr_ldap_thread_trunk_t* fr_thread_ldap_trunk_get | ( | fr_ldap_thread_t * | thread, |
char const * | uri, | ||
char const * | bind_dn, | ||
char const * | bind_password, | ||
request_t * | request, | ||
fr_ldap_config_t const * | config | ||
) |
Find a thread specific LDAP connection for a specific URI / bind DN.
If no existing connection exists for that combination then create a new one
[in] | thread | to which the connection belongs |
[in] | uri | of the host to find / create a connection to |
[in] | bind_dn | to make the connection as |
[in] | bind_password | for making connection |
[in] | request | currently being processed (only for debug messages) |
[in] | config | LDAP config of the module requesting the connection. |
Definition at line 918 of file connection.c.
trunk_state_t fr_thread_ldap_trunk_state | ( | fr_ldap_thread_t * | thread, |
char const * | uri, | ||
char const * | bind_dn | ||
) |
Lookup the state of a thread specific LDAP connection trunk for a specific URI / bind DN.
[in] | thread | to which the connection belongs |
[in] | uri | of the host to find / create a connection to |
[in] | bind_dn | to make the connection as |
Definition at line 996 of file connection.c.
|
static |
Callback when an LDAP trunk request is cancelled.
Ensure the request is removed from the list of outstanding requests
Definition at line 477 of file connection.c.
|
static |
Callback to tidy up when a trunk request fails.
Definition at line 515 of file connection.c.
|
static |
Callback to tidy up when a bind auth trunk request fails.
Definition at line 1267 of file connection.c.
|
static |
Definition at line 34 of file connection.c.