26 #define LOG_PREFIX "proto_ldap_sync_ldap"
28 #include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
29 #include <freeradius-devel/internal/internal.h>
30 #include <freeradius-devel/server/protocol.h>
31 #include <freeradius-devel/server/request.h>
32 #include <freeradius-devel/io/listen.h>
33 #include <freeradius-devel/io/application.h>
34 #include <freeradius-devel/unlang/call.h>
35 #include <freeradius-devel/util/dbuff.h>
36 #include <freeradius-devel/ldap/base.h>
37 #include <freeradius-devel/ldap/conf.h>
208 talloc_array_length(
config->base_dn) - 1,
false);
234 sync_packet_ctx->
sync = sync;
237 if (cookie) sync_packet_ctx->
cookie = talloc_memdup(sync_packet_ctx, cookie, talloc_array_length(cookie));
238 sync_packet_ctx->
refresh = refresh;
293 TALLOC_CTX *local = NULL;
301 local = talloc_new(NULL);
323 cookie, talloc_array_length(cookie),
true);
393 if (sync_packet_ctx) {
428 sync_packet_ctx->
sync = sync;
431 pairs = &sync_packet_ctx->
pairs;
435 if (
msg) ldap_msgfree(
msg);
460 if (orig_dn && (orig_dn->bv_len > 0)) {
462 orig_dn->bv_val, orig_dn->bv_len,
true);
471 map_t const *map = NULL;
472 struct berval **values;
476 entry_dn, strlen(entry_dn),
true);
479 ldap_memfree(entry_dn);
486 if (!values)
goto next;
488 count = ldap_count_values_len(values);
490 for (i = 0; i <
count; i++) {
491 if (values[i]->bv_len == 0)
continue;
495 values[i]->bv_len, NULL,
true) < 0) {
504 ldap_value_free_len(values);
518 PERROR(
"Inserting LDAP sync retry timer failed");
553 PERROR(
"Failed (re)initialising connection, will retry in %pV seconds",
557 inst->handle_config.reconnection_delay,
610 struct timeval poll = { 1, 0 };
611 LDAPMessage *
msg = NULL;
617 LDAPControl **ctrls = NULL;
637 ret = ldap_result(conn->
handle, LDAP_RES_ANY, LDAP_MSG_ONE, &poll, &
msg);
665 msgid = ldap_msgid(
msg);
670 WARN(
"Ignoring unsolicited %s message",
673 if (ctrls) ldap_controls_free(ctrls);
680 WARN(
"Ignoring msgid %i, doesn't match any outstanding syncs", msgid);
699 if (
type != LDAP_RES_SEARCH_RESULT) {
700 PERROR(
"e-syncRefreshRequired result code received on wrong message type");
705 DEBUG2(
"LDAP Server returned e-syncRefreshRequired");
716 PERROR(
"Connection unusable");
726 DEBUG3(
"Got %s message for sync (msgid %i)",
730 case LDAP_RES_SEARCH_REFERENCE:
731 case LDAP_RES_SEARCH_ENTRY:
735 case LDAP_RES_INTERMEDIATE:
740 WARN(
"Ignoring unexpected message type (%i)",
type);
746 ret = callback(sync,
msg, ctrls);
747 if (ret < 0)
PERROR(
"Sync callback error");
756 ldap_controls_free(ctrls);
787 inst->parent->sync_config[sync_no]->user_ctx = thread;
794 if (strlen(
config->base_dn) < len)
continue;
847 fr_time(), NULL) < 0)
return -1;
858 DEBUG2(
"Retrying \"load Cookie\" for sync no %ld", retry_ctx->
sync_no);
861 ERROR(
"Failed retrying \"load Cookie\". Will try again in %pV seconds",
891 local = talloc_new(NULL);
894 if (packet_ctx) sync_packet_ctx = talloc_get_type_abort(packet_ctx,
sync_packet_ctx_t);
902 if (ret < 0)
goto finish;
909 packet_id =
vp->vp_uint32;
913 pcode =
vp->vp_uint32;
924 fr_assert (packet_id <= talloc_array_length(
inst->parent->sync_config));
930 if (
vp) cookie = talloc_memdup(
inst,
vp->vp_octets,
vp->vp_length);
932 if (
inst->parent->sync_config[packet_id]->init(thread->
conn->h, packet_id,
inst->parent, cookie) < 0) {
946 if (!sync_packet_ctx || !sync_packet_ctx->
refresh)
break;
952 DEBUG3(
"Restarting sync with base %s", sync_config->
base_dn);
954 if (
inst->parent->sync_config[packet_id]->init(thread->
conn->h, packet_id,
inst->parent,
955 sync_packet_ctx->
cookie) < 0) {
966 ERROR(
"Load Cookie failed for sync %d, retrying in %pV seconds", packet_id,
973 .sync_no = packet_id,
977 inst->handle_config.reconnection_delay,
983 ERROR(
"Invalid packet type returned %d", pcode);
987 if (sync_packet_ctx) {
1065 LDAPMessage *result;
1068 TALLOC_CTX *local = NULL;
1076 PERROR(
"Failed querying for directory type");
1077 if (result) ldap_msgfree(result);
1086 ldap_msgfree(result);
1093 ERROR(
"LDAP sync configured for directory which does not support any suitable control");
1106 DEBUG2(
"Starting sync(s)");
1108 local = talloc_new(NULL);
1114 for (i = 0; i < talloc_array_length(
inst->parent->sync_config); i++) {
1164 ERROR(
"LDAP connection closed. Scheduling restart in %pVs",
1167 inst->handle_config.reconnection_delay,
1192 if (ldap_conn->
fd < 0) {
1195 inst->handle_config.reconnection_delay,
1202 thread->
li->
fd = ldap_conn->
fd;
1205 if (!dir_ctx)
goto connection_failed;
1208 dir_ctx->
conn = conn;
1212 if (
inst->recv_buff_is_set) {
1215 opt =
inst->recv_buff;
1216 if (setsockopt(ldap_conn->
fd, SOL_SOCKET, SO_RCVBUF, &opt,
sizeof(
int)) < 0) {
1230 goto connection_failed;
1238 if (dir_ctx->
msgid < 0) {
1240 goto connection_failed;
1266 thread->
name =
inst->handle_config.name;
1293 if (
inst->recv_buff_is_set) {
1298 server =
inst->server;
1299 inst->handle_config.server = talloc_strdup(
inst,
"");
1301 if (ldap_is_ldap_url(server)) {
1307 inst->handle_config.server[talloc_array_length(
inst->handle_config.server) - 1] =
'\0';
1318 .name =
"ldap_sync_child"
1324 .default_message_size = 4096,
1325 .track_duplicates =
false,
1331 .name =
"ldap_sync_ldap",
1338 .default_message_size = 4096,
1339 .track_duplicates =
false,
int active_directory_sync_state_init(fr_ldap_connection_t *conn, size_t sync_no, proto_ldap_sync_t const *inst, UNUSED uint8_t const *cookie)
Allocate a sync state structure and issue the search.
int active_directory_sync_search_entry(sync_state_t *sync, LDAPMessage *msg, UNUSED LDAPControl **ctrls)
Handle a LDAP_RES_SEARCH_ENTRY (SearchResultEntry) response.
static int const char char buffer[256]
module_t common
Common fields to all loadable modules.
size_t default_message_size
Usually maximum message size.
Public structure describing an I/O path for a protocol.
#define USES_APPLE_DEPRECATED_API
#define L(_str)
Helper for initialising arrays of string literals.
#define CMP(_a, _b)
Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering.
#define CONF_PARSER_TERMINATOR
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
#define FR_CONF_OFFSET_IS_SET(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct,...
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Defines a CONF_PAIR to C data type mapping.
A section grouping multiple CONF_PAIR.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
char const * cf_section_name(CONF_SECTION const *cs)
Return name2 if set, else name1.
static int max_outstanding
@ CONNECTION_STATE_CLOSED
Connection has been closed.
@ CONNECTION_STATE_CONNECTED
File descriptor is open (ready for writing).
@ CONNECTION_STATE_INIT
Init state, sets up connection.
@ CONNECTION_FAILED
Connection is being reconnected because it failed.
#define fr_dbuff_used(_dbuff_or_marker)
Return the number of bytes remaining between the start of the dbuff or marker and the current positio...
#define fr_dbuff_init(_out, _start, _len_or_end)
Initialise an dbuff for encoding or decoding.
#define fr_dbuff_buff(_dbuff_or_marker)
Return the underlying buffer in a dbuff or one of marker.
#define FR_DBUFF_TALLOC_THREAD_LOCAL(_out, _init, _max)
Create a function local and thread local extensible dbuff.
fr_dcursor_eval_t void const * uctx
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
static void * fr_dlist_pop_head(fr_dlist_head_t *list_head)
Remove the head item in a list.
static void * fr_dlist_next(fr_dlist_head_t const *list_head, void const *ptr)
Get the next item in a list.
static void * fr_dlist_head(fr_dlist_head_t const *list_head)
Return the HEAD item of a list or NULL if the list is empty.
static int fr_dlist_insert_tail(fr_dlist_head_t *list_head, void *ptr)
Insert an item into the tail of a list.
#define fr_dlist_talloc_init(_head, _type, _field)
Initialise the head structure of a doubly linked list.
#define fr_event_fd_insert(...)
@ FR_EVENT_FILTER_IO
Combined filter for read/write functions/.
#define fr_event_timer_in(...)
#define GLOBAL_LIB_TERMINATOR
Structure to define how to initialise libraries with global configuration.
bool allow_name_only
Allow name only pairs.
char const * name
printable name for this socket - set by open
void const * app_instance
size_t default_message_size
copied from app_io, but may be changed
void const * app_io_instance
I/O path configuration context.
CONF_SECTION * server_cs
CONF_SECTION of the server.
void * thread_instance
thread / socket context
int fd
file descriptor for this socket - set by open
fr_app_io_t const * app_io
I/O path functions.
size_t fr_network_listen_outstanding(fr_network_t *nr, fr_listen_t *li)
Get the number of outstanding packets.
int fr_network_listen_send_packet(fr_network_t *nr, fr_listen_t *parent, fr_listen_t *li, const uint8_t *buffer, size_t buflen, fr_time_t recv_time, void *packet_ctx)
Send a packet to the worker.
int fr_network_listen_add(fr_network_t *nr, fr_listen_t *li)
Add a fr_listen_t to a network.
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.
int fr_ldap_conn_directory_alloc_async(fr_ldap_connection_t *ldap_conn)
Async extract useful information from the rootDSE of the LDAP server.
fr_ldap_sync_type_t sync_type
What kind of LDAP sync this directory supports.
LDAP * handle
libldap handle.
fr_ldap_directory_t * directory
The type of directory we're connected to.
int fd
File descriptor for this connection.
void fr_ldap_state_error(fr_ldap_connection_t *c)
Signal that there's been an error on the connection.
int fr_ldap_server_url_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION const *cs)
Check an LDAP server entry in URL format is valid.
fr_ldap_config_t const * config
rlm_ldap connection configuration.
int fr_ldap_server_config_check(fr_ldap_config_t *handle_config, char const *server, CONF_SECTION *cs)
Check an LDAP server config in server:port format is valid.
char const * name
Name of the module that created this connection.
fr_time_delta_t reconnection_delay
How long to wait before attempting to reconnect.
int fr_ldap_directory_result_parse(fr_ldap_directory_t *directory, LDAP *handle, LDAPMessage *result, char const *name)
void * uctx
User data associated with the handle.
@ FR_LDAP_SYNC_NONE
No support for LDAP sync.
@ FR_LDAP_SYNC_ACTIVE_DIRECTORY
Directory supports AD style persistent search.
@ FR_LDAP_SYNC_PERSISTENT_SEARCH
Directory supports persistent search.
@ FR_LDAP_SYNC_RFC4533
Directory supports RFC 4533.
connection_t * conn
Connection state handle.
char const ** naming_contexts
Databases served by this directory.
fr_ldap_rcode_t
Codes returned by fr_ldap internal functions.
@ LDAP_PROC_SUCCESS
Operation was successful.
@ LDAP_PROC_BAD_CONN
Transitory error, caller should retry the operation with a new connection.
@ LDAP_PROC_REFRESH_REQUIRED
Don't continue with the current refresh phase, exit, and retry the operation with a NULL cookie.
Tracks the state of a libldap connection handle.
#define FR_LDAP_COMMON_CONF(_conf)
fr_ldap_rcode_t fr_ldap_error_check(LDAPControl ***ctrls, fr_ldap_connection_t const *conn, LDAPMessage *msg, char const *dn)
Perform basic parsing of multiple types of messages, checking for error conditions.
LDAP * fr_ldap_handle_thread_local(void)
Get a thread local dummy LDAP handle.
global_lib_autoinst_t fr_libldap_global_config
fr_ldap_rcode_t fr_ldap_result(LDAPMessage **result, LDAPControl ***ctrls, fr_ldap_connection_t const *conn, int msgid, int all, char const *dn, fr_time_delta_t timeout)
Parse response from LDAP server dealing with any errors.
fr_time_t fr_event_list_time(fr_event_list_t *el)
Get the current server time according to the event list.
bool fr_event_loop_exiting(fr_event_list_t *el)
Check to see whether the event loop is in the process of exiting.
int fr_event_fd_delete(fr_event_list_t *el, int fd, fr_event_filter_t filter)
Remove a file descriptor from the event loop.
Stores all information relating to an event list.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_OCTETS
Raw octets.
int strncasecmp(char *s1, char *s2, int n)
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for instantiation calls.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
int fr_pair_list_copy(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
Duplicate a list of pairs.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
fr_pair_t * fr_pair_find_by_da_nested(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.
int persistent_sync_search_entry(sync_state_t *sync, LDAPMessage *msg, LDAPControl **ctrls)
Handle a SearchResultEntry response from Persistent Search LDAP servers.
int persistent_sync_state_init(fr_ldap_connection_t *conn, size_t sync_no, proto_ldap_sync_t const *inst, UNUSED uint8_t const *cookie)
Allocate and initialise sync queries for persistent searches.
static const conf_parser_t config[]
char const * filter
Filter to retrieve only user objects.
CONF_SECTION * server_cs
server CS for this listener.
sync_config_t ** sync_config
DNs and filters to monitor.
int(* sync_msg_t)(sync_state_t *sync, LDAPMessage *msg, LDAPControl **ctrls)
Received an LDAP message related to a sync.
sync_op_t
Operations to perform on entries.
@ SYNC_OP_ADD
Entry should be added to our copy.
@ SYNC_OP_MODIFY
Entry should be updated in our copy.
@ SYNC_OP_DELETE
Entry should be deleted from our copy.
@ SYNC_OP_PRESENT
Entry is present and unchanged on the server.
fr_event_timer_t const * ev
Event for retrying cookie load.
char const * base_dn
DN to search for users under.
sync_msg_t entry
Called when we receive a searchEntry message.
sync_msg_t refresh
Called when we receive a eSyncRefreshRequired code.
CONF_SECTION * cs
Config section where this sync was defined.
sync_msg_t intermediate
Called when we receive a syncIntermediate message.
map_list_t entry_map
How to convert attributes in entries to FreeRADIUS attributes.
fr_pair_list_t sync_pairs
Pairs representing the sync config sent to the worker with each request.
fr_time_delta_t cookie_interval
Interval between storing cookies.
uint32_t cookie_changes
Number of LDAP changes to process between each cookie store operation.
fr_time_delta_t retry_interval
Interval between retrying failed change packets.
void * user_ctx
User ctx to pass to the callbacks.
An instance of a proto_ldap_sync listen section.
Areas of the directory to receive notifications for.
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.
int ldap_sync_cookie_send(sync_packet_ctx_t *sync_packet_ctx)
Enqueue a new cookie store packet.
fr_app_io_t proto_ldap_sync_ldap
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.
static fr_dict_attr_t const * attr_packet_type
static fr_ldap_sync_packet_code_t const sync_packet_code_table[4]
static int proto_ldap_child_mod_close(fr_listen_t *li)
Child listener mod_close.
fr_listen_t * main_listen
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.
global_lib_autoinst_t const * proto_ldap_sync_ldap_lib[]
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.
static fr_dict_attr_t const * attr_ldap_sync_packet_id
static fr_dict_t const * dict_ldap_sync
proto_ldap_sync_ldap_t const * inst
static fr_dict_attr_t const * attr_ldap_sync_entry_dn
int ldap_sync_cookie_store(sync_state_t *sync, bool refresh)
Add a new cookie packet ctx to the pending list.
static int sync_state_free(sync_state_t *sync)
Tell the remote server to stop the sync.
static fr_dict_t const * dict_freeradius
static fr_dict_attr_t const * attr_ldap_sync_base_dn
static fr_dict_attr_t const * attr_ldap_sync_orig_dn
fr_listen_t * child_listen
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.
fr_app_io_t proto_ldap_sync_child
static conf_parser_t const proto_ldap_sync_ldap_config[]
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.
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.
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.
fr_table_num_sorted_t const sync_op_table[]
Operations performed on entries.
static fr_dict_attr_t const * attr_ldap_sync_root_dn
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.
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.
static fr_internal_encode_ctx_t encode_ctx
static int ldap_sync_entry_send_network(sync_packet_ctx_t *sync_packet_ctx)
Send a change packet to the workers.
int8_t sync_state_cmp(void const *one, void const *two)
Compare two sync state structures on msgid.
static fr_dict_attr_t const * attr_ldap_sync_entry_uuid
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.
fr_dict_attr_autoload_t proto_ldap_sync_ldap_dict_attr[]
static fr_dict_attr_t const * attr_ldap_sync_cookie
proto_ldap_sync_ldap_thread_t * thread
fr_dict_autoload_t proto_ldap_sync_ldap_dict[]
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.
static int mod_instantiate(module_inst_ctx_t const *mctx)
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.
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.
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.
Context for "load Cookie" retry timed event.
Context used when looking up Directory types.
uint32_t pending_cookies
How many cookies are in the pending heap.
uint8_t * cookie
Opaque cookie, used to resume synchronisation.
size_t sync_no
Array position of config for this sync.
@ SYNC_PACKET_TYPE_CHANGE
Packet is an entry change.
@ SYNC_PACKET_TYPE_COOKIE
sync_phases_t phase
Phase this sync is in.
uint32_t max_outstanding
Maximum number of outstanding packets.
int msgid
The unique identifier for this sync session.
uint8_t * cookie
Cookie to store - can be NULL.
fr_pair_list_t pairs
Pairs to send with change packets.
fr_dlist_head_t pending
List of pending changes in progress.
sync_config_t const * config
Configuration for this sync.
static fr_table_num_sorted_t const sync_ldap_msg_table[]
Types of LDAP messages relevant to LDAP sync.
sync_state_t * sync
Sync packet relates to.
sync_packet_status_t status
Status of this packet.
fr_event_timer_t const * conn_retry_ev
When to retry re-establishing the conn.
@ SYNC_PACKET_PREPARING
Packet being prepared.
@ SYNC_PACKET_PENDING
Packet not yet sent.
@ SYNC_PACKET_PROCESSING
Packet sent to worker.
@ SYNC_PACKET_COMPLETE
Packet response received from worker.
fr_listen_t * li
Our listener.
connection_t * conn
Our connection to the LDAP directory.
proto_ldap_sync_t const * inst
Module instance for this sync.
fr_ldap_config_t handle_config
Connection configuration instance.
fr_network_t * nr
Network handler.
fr_listen_t * parent
master IO handler.
proto_ldap_sync_t * parent
The module that spawned us.
bool refresh
Does the sync require a refresh.
@ SYNC_PHASE_INIT
We haven't entered any of the refresh phases.
sync_packet_type_t type
Type of packet.
uint32_t changes_since_cookie
How many changes have been added since the last cookie was stored.
char const * name
socket name
fr_event_timer_t const * cookie_ev
Timer event for sending cookies.
fr_ldap_connection_t * conn
Connection the sync is running on.
fr_pair_list_t trigger_args
Arguments to make available in triggers.
fr_event_timer_t const * retry_ev
Timer event for retrying failed changes.
fr_event_list_t * el
Network side event list.
proto_ldap_sync_ldap_t const * inst
instance data
Tracking structure for ldap sync packets.
State of an individual sync.
ssize_t fr_internal_decode_list_dbuff(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *dbuff, void *decode_ctx)
Retrieve all pairs from the dbuff.
ssize_t fr_internal_encode_list(fr_dbuff_t *dbuff, fr_pair_list_t const *list, void *encode_ctx)
Encode a list of pairs using the internal encoder.
bool fr_rb_delete(fr_rb_tree_t *tree, void const *data)
void * fr_rb_find(fr_rb_tree_t const *tree, void const *data)
The main red black tree structure.
int rfc4533_sync_refresh_required(sync_state_t *sync, LDAPMessage *msg, LDAPControl **ctrls)
Handle result code of e-syncRefreshRequired.
int rfc4533_sync_search_entry(sync_state_t *sync, LDAPMessage *msg, LDAPControl **ctrls)
Handle a SearchResultEntry or SearchResultReference response from an RFC 4533 server.
int rfc4533_sync_init(fr_ldap_connection_t *conn, size_t sync_no, proto_ldap_sync_t const *inst, uint8_t const *cookie)
Allocate and initialise RFC 4533 sync queries.
int rfc4533_sync_intermediate(sync_state_t *sync, LDAPMessage *msg, UNUSED LDAPControl **ctrls)
Handle a LDAP_RES_INTERMEDIATE (SyncInfo) response.
void connection_signal_shutdown(connection_t *conn)
Shuts down a connection gracefully.
void connection_signal_halt(connection_t *conn)
Shuts down a connection ungracefully.
void connection_signal_reconnect(connection_t *conn, connection_reason_t reason)
Asynchronously signal the connection should be reconnected.
void connection_signal_init(connection_t *conn)
Asynchronously signal a halted connection to start.
connection_watch_entry_t * connection_add_watch_post(connection_t *conn, connection_state_t state, connection_watch_t watch, bool oneshot, void const *uctx)
Add a callback to be executed after a state function has been called.
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
module_instance_t const * parent
Parent module's instance (if any).
int pair_append_by_tmpl_parent(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, tmpl_t const *vpt, bool skip_list))
Allocate and insert a leaf vp from a tmpl_t, building the parent vps if needed.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
fr_aka_sim_id_type_t type
#define fr_time()
Allow us to arbitrarily manipulate time.
fr_token_t op
The operator that controls insertion of the dst attribute.
tmpl_t * lhs
Typically describes the attribute to add, modify or compare.
tmpl_t * rhs
Typically describes a literal value or a src attribute to copy or compare.
Stores an attribute, a value and various bits of other data.
fr_ldap_sync_packet_code_t
Types of the internal packets for processing LDAP sync messages.
@ FR_LDAP_SYNC_CODE_PRESENT
LDAP server indicates a particular object is present and unchanged.
@ FR_LDAP_SYNC_CODE_COOKIE_STORE_RESPONSE
Response to storing the new cookie.
@ FR_LDAP_SYNC_CODE_ENTRY_RESPONSE
Response packet to present / add / modify / delete.
@ FR_LDAP_SYNC_CODE_COOKIE_LOAD_FAIL
Response when coolie load fails.
@ FR_LDAP_SYNC_CODE_ADD
Object has been added to the LDAP directory.
@ FR_LDAP_SYNC_CODE_COOKIE_STORE
The server has sent a new cookie.
@ FR_LDAP_SYNC_CODE_COOKIE_LOAD_RESPONSE
Response with the returned cookie.
@ FR_LDAP_SYNC_CODE_DELETE
Object has been deleted.
@ FR_LDAP_SYNC_CODE_COOKIE_LOAD
Before the sync starts, request any previously stored cookie.
@ FR_LDAP_SYNC_CODE_MODIFY
Object has been modified.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
An element in a lexicographically sorted array of name to num mappings.
char * talloc_typed_asprintf(TALLOC_CTX *ctx, char const *fmt,...)
Call talloc vasprintf, setting the type on the new chunk correctly.
#define talloc_get_type_abort_const
static fr_time_delta_t fr_time_delta_from_msec(int64_t msec)
int trigger_exec(unlang_interpret_t *intp, CONF_SECTION const *cs, char const *name, bool rate_limit, fr_pair_list_t *args)
Execute a trigger - call an executable to process an event.
static fr_event_list_t * el
fr_pair_t * fr_pair_remove(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list without freeing.
#define fr_pair_list_append_by_da_len(_ctx, _vp, _list, _attr, _val, _len, _tainted)
Append a pair to a list, assigning its value.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
#define fr_pair_list_append_by_da(_ctx, _vp, _list, _attr, _val, _tainted)
Append a pair to a list, assigning its value.
#define fr_pair_list_append_by_da_parent_len(_ctx, _vp, _list, _attr, _val, _len, _tainted)
char const * fr_strerror(void)
Get the last library error.
ssize_t fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, char const *in, size_t inlen, fr_sbuff_unescape_rules_t const *erules, bool tainted)
#define fr_box_time_delta(_val)