The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
LDAP sync handler. More...
#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
#include <freeradius-devel/internal/internal.h>
#include <freeradius-devel/server/protocol.h>
#include <freeradius-devel/server/request.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/application.h>
#include <freeradius-devel/unlang/call.h>
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/ldap/base.h>
#include <freeradius-devel/ldap/conf.h>
#include "proto_ldap_sync_ldap.h"
#include "rfc4533.h"
#include "persistent_search.h"
#include "active_directory.h"
Go to the source code of this file.
Data Structures | |
struct | proto_ldap_cookie_load_retry_ctx |
Context for "load Cookie" retry timed event. More... | |
struct | proto_ldap_dir_ctx |
Context used when looking up Directory types. More... | |
Macros | |
#define | LOG_PREFIX "proto_ldap_sync_ldap" |
Functions | |
static void | _proto_ldap_socket_closed (UNUSED connection_t *conn, connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Callback for closure of LDAP connection. More... | |
static void | _proto_ldap_socket_init (connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Allocate a child listener. More... | |
static void | _proto_ldap_socket_open_connected (connection_t *conn, UNUSED connection_state_t prev, UNUSED connection_state_t state, void *uctx) |
Query an LDAP server to establish its type. More... | |
static void | _proto_ldap_socket_open_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, UNUSED int fd_errno, void *uctx) |
Callback for socket errors when running initial root query. More... | |
static void | _proto_ldap_socket_open_read (fr_event_list_t *el, int fd, UNUSED int flags, void *uctx) |
Callback to process results of initial root query, identifying directory type. More... | |
void | ldap_sync_cookie_event (fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Event to handle storing of cookies on a timed basis. More... | |
int | ldap_sync_cookie_send (sync_packet_ctx_t *sync_packet_ctx) |
Enqueue a new cookie store packet. More... | |
int | ldap_sync_cookie_store (sync_state_t *sync, bool refresh) |
Add a new cookie packet ctx to the pending list. More... | |
int | ldap_sync_entry_send (sync_state_t *sync, uint8_t const uuid[SYNC_UUID_LENGTH], struct berval *orig_dn, LDAPMessage *msg, sync_op_t op) |
Enqueue a new entry change packet. More... | |
static int | ldap_sync_entry_send_network (sync_packet_ctx_t *sync_packet_ctx) |
Send a change packet to the workers. More... | |
static void | ldap_sync_retry_event (fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Event to handle sending of any change packets which failed to send. More... | |
static void | mod_event_list_set (fr_listen_t *li, fr_event_list_t *el, void *nr) |
Callback triggered when parent listener app_io has its event list set. More... | |
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
static int | proto_ldap_child_mod_close (fr_listen_t *li) |
Child listener mod_close. More... | |
static ssize_t | proto_ldap_child_mod_read (fr_listen_t *li, UNUSED void **packet_ctx, UNUSED fr_time_t *recv_time_p, UNUSED uint8_t *buffer, UNUSED size_t buffer_len, UNUSED size_t *leftover) |
LDAP sync mod_read for child listener. More... | |
static ssize_t | proto_ldap_child_mod_write (fr_listen_t *li, void *packet_ctx, UNUSED fr_time_t request_time, uint8_t *buffer, size_t buffer_len, UNUSED size_t written) |
LDAP sync mod_write for child listener. More... | |
static void | proto_ldap_connection_init (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *user_ctx) |
Attempt to (re)initialise a connection. More... | |
static void | proto_ldap_cookie_load_retry (fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Timer event to retry running "load Cookie" on failures. More... | |
static int | proto_ldap_cookie_load_send (TALLOC_CTX *ctx, proto_ldap_sync_ldap_t const *inst, size_t sync_no, proto_ldap_sync_ldap_thread_t *thread) |
Send a fake packet to run the "load Cookie" section. More... | |
sync_state_t * | sync_state_alloc (TALLOC_CTX *ctx, fr_ldap_connection_t *conn, proto_ldap_sync_t const *inst, size_t sync_no, sync_config_t const *config) |
Allocate a sync state. More... | |
int8_t | sync_state_cmp (void const *one, void const *two) |
Compare two sync state structures on msgid. More... | |
static int | sync_state_free (sync_state_t *sync) |
Tell the remote server to stop the sync. More... | |
LDAP sync handler.
Definition in file proto_ldap_sync_ldap.c.
struct proto_ldap_cookie_load_retry_ctx |
Context for "load Cookie" retry timed event.
Definition at line 128 of file proto_ldap_sync_ldap.c.
Data Fields | ||
---|---|---|
proto_ldap_sync_ldap_t const * | inst | |
size_t | sync_no | |
proto_ldap_sync_ldap_thread_t * | thread |
struct proto_ldap_dir_ctx |
Context used when looking up Directory types.
Definition at line 119 of file proto_ldap_sync_ldap.c.
Data Fields | ||
---|---|---|
fr_listen_t * | child_listen | |
connection_t * | conn | |
fr_listen_t * | main_listen | |
int | msgid |
#define LOG_PREFIX "proto_ldap_sync_ldap" |
Definition at line 26 of file proto_ldap_sync_ldap.c.
|
static |
Callback for closure of LDAP connection.
Schedules re-start of the connection if appropriate
Definition at line 1154 of file proto_ldap_sync_ldap.c.
|
static |
Allocate a child listener.
Called as a watch function when the LDAP connection enters the INIT state
Definition at line 1126 of file proto_ldap_sync_ldap.c.
|
static |
Query an LDAP server to establish its type.
Called as a watch function once the LDAP connection enters the CONNECTED state
There are three different forms of LDAP sync/persistent search - so we need to know what we're dealing with, and whether the relevant options have been enabled.
Definition at line 1181 of file proto_ldap_sync_ldap.c.
|
static |
Callback for socket errors when running initial root query.
Definition at line 1044 of file proto_ldap_sync_ldap.c.
|
static |
Callback to process results of initial root query, identifying directory type.
Definition at line 1056 of file proto_ldap_sync_ldap.c.
void ldap_sync_cookie_event | ( | fr_event_list_t * | el, |
UNUSED fr_time_t | now, | ||
void * | uctx | ||
) |
Event to handle storing of cookies on a timed basis.
Looks at the head of the list of pending sync packets for a cookie. A cookie at the head says that all the previous changes have been completed, so the cookie can be sent.
Definition at line 255 of file proto_ldap_sync_ldap.c.
int ldap_sync_cookie_send | ( | sync_packet_ctx_t * | sync_packet_ctx | ) |
Enqueue a new cookie store packet.
Create a new internal packet containing the cookie we received from the LDAP server. This allows the administrator to store the cookie and provide it on a future call to load Cookie.
[in] | sync_packet_ctx | packet context containing the cookie to store. |
Definition at line 286 of file proto_ldap_sync_ldap.c.
int ldap_sync_cookie_store | ( | sync_state_t * | sync, |
bool | refresh | ||
) |
Add a new cookie packet ctx to the pending list.
Does not actually send the packet.
[in] | sync | the cookie was received for. |
[in] | refresh | the sync after storing this cookie. |
Definition at line 228 of file proto_ldap_sync_ldap.c.
int ldap_sync_entry_send | ( | sync_state_t * | sync, |
uint8_t const | uuid[SYNC_UUID_LENGTH], | ||
struct berval * | orig_dn, | ||
LDAPMessage * | msg, | ||
sync_op_t | op | ||
) |
Enqueue a new entry change packet.
[in] | sync | notification has arrived for. |
[in] | uuid | of the entry (RFC 4533 only). |
[in] | orig_dn | original DN of the entry - provided by those directories implementing persistent search, when an entry is renamed. |
[in] | msg | containing the entry. |
[in] | op | The type of modification we need to perform to our representation of the entry. |
Definition at line 419 of file proto_ldap_sync_ldap.c.
|
static |
Send a change packet to the workers.
Called each time a change packet is received and also from a timer event retrying packets which previously failed to send.
sync_packet_ctx | Packet to send |
Definition at line 351 of file proto_ldap_sync_ldap.c.
|
static |
Event to handle sending of any change packets which failed to send.
Looks at the head of the list of pending sync packets for unsent change packets and sends any up to the first cookie.
Definition at line 374 of file proto_ldap_sync_ldap.c.
|
static |
Callback triggered when parent listener app_io has its event list set.
Initiates the actual outbound LDAP connection
[in] | li | The parent listener. |
[in] | el | Event list for this listener. |
[in] | nr | Network handler. |
Definition at line 1258 of file proto_ldap_sync_ldap.c.
|
static |
|
static |
Child listener mod_close.
Ensures the LDAP connection is signalled to close gracefully when the listener is closed.
Definition at line 585 of file proto_ldap_sync_ldap.c.
|
static |
LDAP sync mod_read for child listener.
Called when there is data to read on the LDAP connection
Actual packets are created by the various callbacks since a single LDAP message can result in multiple packets to process e.g.:
Definition at line 605 of file proto_ldap_sync_ldap.c.
|
static |
LDAP sync mod_write for child listener.
Handle any returned data after the worker has processed the packet and, for packets where tracking structures were used, ensure they are freed.
Definition at line 877 of file proto_ldap_sync_ldap.c.
|
static |
Attempt to (re)initialise a connection.
Performs complete re-initialization of a connection. Called during socket_open to create the initial connection and again any time we need to reopen the connection.
[in] | el | the event list managing listen event. |
[in] | now | current time. |
[in] | user_ctx | Listener. |
Definition at line 539 of file proto_ldap_sync_ldap.c.
|
static |
Timer event to retry running "load Cookie" on failures.
Definition at line 855 of file proto_ldap_sync_ldap.c.
|
static |
Send a fake packet to run the "load Cookie" section.
ctx | Context to allocate temporary pairs in. |
inst | LDAP sync configuration. |
sync_no | Id of the sync whose. |
thread | Thread specific LDAP sync data. |
Definition at line 771 of file proto_ldap_sync_ldap.c.
sync_state_t* sync_state_alloc | ( | TALLOC_CTX * | ctx, |
fr_ldap_connection_t * | conn, | ||
proto_ldap_sync_t const * | inst, | ||
size_t | sync_no, | ||
sync_config_t const * | config | ||
) |
Allocate a sync state.
[in] | ctx | to allocate the sync state in. |
[in] | conn | which the sync will run on. |
[in] | inst | module instance for the sync. |
[in] | sync_no | number of the sync in the array of configs. |
[in] | config | for the sync. |
Definition at line 188 of file proto_ldap_sync_ldap.c.
int8_t sync_state_cmp | ( | void const * | one, |
void const * | two | ||
) |
Compare two sync state structures on msgid.
[in] | one | first sync to compare. |
[in] | two | second sync to compare. |
Definition at line 140 of file proto_ldap_sync_ldap.c.
|
static |
Tell the remote server to stop the sync.
Terminates the search informing the remote server that we no longer want to receive results for this sync. A RFC 4511 abandon request is used to inform the server.
This allows individual syncs to be stopped without destroying the underlying connection.
Removes the sync's msgid from the tree of msgids associated with the connection.
[in] | sync | to abandon. |
Definition at line 159 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 86 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 80 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 81 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 82 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 83 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 79 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 84 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 85 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 70 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 69 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 44 of file proto_ldap_sync_ldap.c.
fr_app_io_t proto_ldap_sync_child |
Definition at line 1315 of file proto_ldap_sync_ldap.c.
fr_app_io_t proto_ldap_sync_ldap |
Definition at line 1328 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 49 of file proto_ldap_sync_ldap.c.
fr_dict_autoload_t proto_ldap_sync_ldap_dict |
Definition at line 73 of file proto_ldap_sync_ldap.c.
fr_dict_attr_autoload_t proto_ldap_sync_ldap_dict_attr |
Definition at line 89 of file proto_ldap_sync_ldap.c.
global_lib_autoinst_t const * proto_ldap_sync_ldap_lib |
Definition at line 102 of file proto_ldap_sync_ldap.c.
fr_table_num_sorted_t const sync_op_table[] |
Operations performed on entries.
Definition at line 109 of file proto_ldap_sync_ldap.c.
size_t sync_op_table_len = NUM_ELEMENTS(sync_op_table) |
Definition at line 115 of file proto_ldap_sync_ldap.c.
|
static |
Definition at line 399 of file proto_ldap_sync_ldap.c.