24 #define LOG_PREFIX "proto_ldap_sync"
26 #include <freeradius-devel/internal/internal.h>
27 #include <freeradius-devel/io/listen.h>
28 #include <freeradius-devel/server/module.h>
111 len = talloc_array_length(
config->attrs);
138 if (ret < 0)
return ret;
142 request->packet->code =
vp->vp_uint32;
146 request->packet->id =
vp->vp_uint32;
147 request->reply->id =
vp->vp_uint32;
160 TALLOC_CTX *local = NULL;
163 local = talloc_new(NULL);
181 if (!sync_vp)
goto send;
183 if ((
vp) && (
vp->data.vb_length > 0)) {
210 li->
name =
"ldap_sync main listener";
249 .allow_foreign =
false,
250 .allow_unknown =
false,
251 .allow_unresolved =
false,
260 if (!
inst->io_submodule) {
261 cf_log_err(
conf,
"Virtual server for LDAP sync requires a 'transport' configuration");
269 inst->app_io_instance =
inst->io_submodule->data;
270 inst->app_io_conf =
inst->io_submodule->conf;
276 if (!
inst->max_packet_size)
inst->max_packet_size =
inst->app_io->default_message_size;
277 if (!
inst->num_messages)
inst->num_messages = 2;
293 sync_conf =
inst->sync_config[i];
294 sync_conf->
cs = sync_cs;
300 if (sync_conf->
scope < 0) {
301 cf_log_err(
conf,
"Invalid 'search.scope' value \"%s\", expected 'sub', 'one', 'base' or 'children'",
317 sync_conf->
attrs = talloc_array(sync_conf,
char const *, 1);
318 sync_conf->
attrs[0] = NULL;
320 if (map_list_empty(&sync_conf->
entry_map)) {
330 while ((map = map_list_next(&sync_conf->
entry_map, map))) {
332 cf_log_err(map->
ci,
"Structural attribute \"%s\" invalid for LDAP sync update",
343 cf_log_err(map->
ci,
"Operator \"%s\" invalid for LDAP sync update",
348 DEBUG3(
"Adding %s to attribute list", map->
rhs->name);
static int const char char buffer[256]
module_t common
Common fields to all loadable modules.
Public structure describing an I/O path for a protocol.
module_t common
Common fields provided by all modules.
Describes a new application (protocol)
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#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_SUBSECTION_ALLOC(_name, _type, _flags, _struct, _field, _subcs)
A conf_parser_t multi-subsection.
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
@ CONF_FLAG_MULTI
CONF_PAIR can have multiple copies.
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Defines a CONF_PAIR to C data type mapping.
A section grouping multiple CONF_PAIR.
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
CONF_SECTION * cf_section_find_next(CONF_SECTION const *cs, CONF_SECTION const *prev, char const *name1, char const *name2)
Return the next matching section.
#define cf_log_err(_cf, _fmt,...)
#define cf_log_warn(_cf, _fmt,...)
#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.
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.
bool allow_name_only
Allow name only pairs.
size_t num_messages
for the message ring buffer
bool non_socket_listener
special internal listener that does not use sockets.
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.
int fr_io_listen_free(fr_listen_t *li)
CONF_SECTION * server_cs
CONF_SECTION of the server.
void * thread_instance
thread / socket context
fr_app_io_t const * app_io
I/O path functions.
int fr_ldap_map_verify(map_t *map, void *instance)
int fr_ldap_attrs_check(char const **attrs, char const *attr)
Check that a particular attribute is included in an attribute list.
#define LDAP_MAX_ATTRMAP
Maximum number of mappings between LDAP and.
fr_table_num_sorted_t const fr_ldap_scope[]
int map_afrom_cs(TALLOC_CTX *ctx, map_list_t *out, CONF_SECTION *cs, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules, map_validate_t validate, void *uctx, unsigned int max)
Convert a config section into an attribute map.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_OCTETS
Raw octets.
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_steal_append(TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp)
Change a vp's talloc ctx and insert it into a new list.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
static const conf_parser_t config[]
static conf_parser_t const ldap_sync_search_config[]
static fr_dict_attr_t const * attr_ldap_sync_filter
static fr_dict_attr_t const * attr_packet_type
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
Encode responses to processing LDAP sync sections.
static fr_dict_attr_t const * attr_ldap_sync_packet_id
static fr_dict_t const * dict_ldap_sync
fr_dict_attr_autoload_t proto_ldap_sync_dict_attr[]
int ldap_sync_conf_attr_add(sync_config_t *config, char const *attr)
Check if an attribute is in the config list and add if not present.
static conf_parser_t const proto_ldap_sync_config[]
static fr_dict_attr_t const * attr_ldap_sync_dn
static fr_dict_attr_t const * attr_ldap_sync
static fr_internal_encode_ctx_t encode_ctx
static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode an internal LDAP sync packet.
static fr_dict_attr_t const * attr_ldap_sync_scope
fr_dict_autoload_t proto_ldap_sync_dict[]
static fr_dict_attr_t const * attr_ldap_sync_cookie
static int mod_instantiate(module_inst_ctx_t const *mctx)
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
char const * filter
Filter to retrieve only user objects.
char const * scope_str
Scope (sub, one, base).
char const * base_dn
DN to search for users under.
int scope
Scope as its libldap value.
CONF_SECTION * cs
Config section where this sync was defined.
char const ** attrs
Zero terminated attribute array.
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.
An instance of a proto_ldap_sync listen section.
Areas of the directory to receive notifications for.
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.
fr_dict_attr_t const * request_attr_request
static int instantiate(module_inst_ctx_t const *mctx)
fr_network_t * fr_schedule_listen_add(fr_schedule_t *sc, fr_listen_t *li)
Add a fr_listen_t to a scheduler.
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
size_t thread_inst_size
Size of the module's thread-specific instance data.
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
tmpl_attr_rules_t attr
Rules/data for parsing attribute references.
@ TMPL_ATTR_LIST_FORBID
Attribute refs are forbidden from having a list.
Optional arguments passed to vp_tmpl functions.
static const uchar sc[16]
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
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.
CONF_ITEM * ci
Config item that the map was created from.
fr_dict_t const * dict_def
Default dictionary to use with unqualified attribute references.
Stores an attribute, a value and various bits of other data.
@ FR_LDAP_SYNC_CODE_COOKIE_LOAD_RESPONSE
Response with the returned cookie.
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
void ** talloc_array_null_terminate(void **array)
Add a NULL pointer to an array of pointers.
fr_table_num_ordered_t const fr_tokens_table[]
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(_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)
#define fr_pair_list_append_by_da_parent(_ctx, _vp, _list, _attr, _val, _tainted)
#define fr_type_is_structural(_x)
int virtual_server_listen_transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic conf_parser_t func for loading drivers.