25 RCSID(
"$Id: 816e6231a0dd9558741e933e5a48c618899d517b $")
27 #include <freeradius-devel/curl/base.h>
28 #include <freeradius-devel/server/base.h>
29 #include <freeradius-devel/server/global_lib.h>
30 #include <freeradius-devel/server/module_rlm.h>
31 #include <freeradius-devel/util/slab.h>
89 RDEBUG2(
"Forcefully cancelling pending IMAP request");
92 if (ret != CURLM_OK) {
93 RERROR(
"Failed removing curl handle from multi-handle: %s (%i)", curl_multi_strerror(ret), ret);
97 imap_slab_release(randle);
116 curl_out_valid = curl_easy_getinfo(randle->
candle, CURLINFO_SSL_VERIFYRESULT, &curl_out);
117 if (curl_out_valid == CURLE_OK){
118 RDEBUG2(
"server certificate %s verified", curl_out ?
"was" :
"not");
120 RDEBUG2(
"server certificate result not found");
123 if (randle->
result != CURLE_OK) {
124 CURLcode result = randle->
result;
125 imap_slab_release(randle);
127 case CURLE_PEER_FAILED_VERIFICATION:
128 case CURLE_LOGIN_DENIED:
137 imap_slab_release(randle);
164 REDEBUG(
"Attribute \"User-Name\" is required for authentication");
169 RDEBUG2(
"Attribute \"User-Password\" is required for authentication");
173 if (password->vp_length == 0) {
174 RDEBUG2(
"\"User-Password\" must not be empty");
178 randle = imap_slab_reserve(t->
slab);
188 imap_slab_release(randle);
200 curl_easy_cleanup(randle->
candle);
212 randle->
candle = curl_easy_init();
221 #if CURL_AT_LEAST_VERSION(7,45,0)
225 #if CURL_AT_LEAST_VERSION(7,85,0)
249 if (!(t->
slab = imap_slab_list_alloc(t, mctx->
el, &
inst->conn_config.reuse,
252 ERROR(
"Connection handle pool instantiation failed");
257 if (!mhandle)
return -1;
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
#define CONF_PARSER_TERMINATOR
#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_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
Defines a CONF_PAIR to C data type mapping.
#define FR_CURL_REQUEST_SET_OPTION(_x, _y)
fr_curl_handle_t * fr_curl_io_init(TALLOC_CTX *ctx, fr_event_list_t *el, bool multiplex)
CURLcode result
Result of executing the request.
#define FR_CURL_SET_OPTION(_x, _y)
uint64_t transfers
How many transfers are current in progress.
CURLM * mandle
The multi handle.
int fr_curl_io_request_enqueue(fr_curl_handle_t *mhandle, request_t *request, fr_curl_io_request_t *creq)
Sends a request using libcurl.
CURL * candle
Request specific handle.
Uctx data for timer and I/O functions.
Structure representing an individual request being passed to curl for processing.
fr_dcursor_eval_t void const * uctx
static fr_time_delta_t timeout
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.
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.
#define GLOBAL_LIB_TERMINATOR
Structure to define how to initialise libraries with global configuration.
int fr_curl_response_certinfo(request_t *request, fr_curl_io_request_t *randle)
int fr_curl_easy_tls_init(fr_curl_io_request_t *randle, fr_curl_tls_t const *conf)
global_lib_autoinst_t fr_curl_autoinst
conf_parser_t fr_curl_conn_config[]
conf_parser_t fr_curl_tls_config[]
#define DEBUG_ENABLED3
True if global debug level 1-3 messages are enabled.
@ FR_TYPE_STRING
String of printable characters.
module_instance_t const * mi
Instance of the module being instantiated.
void * thread
Thread specific instance data.
void * rctx
Resume ctx that a module previously set.
fr_event_list_t * el
Event list to register any IO handlers and timers against.
void * thread
Thread instance data.
module_instance_t const * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for thread_instantiation calls.
module_t common
Common fields presented by all modules.
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.
#define RETURN_MODULE_REJECT
#define RETURN_MODULE_INVALID
rlm_rcode_t
Return codes indicating the result of the module call.
static fr_dict_attr_t const * attr_user_password
imap_slab_list_t * slab
Slab list for connection handles.
fr_time_delta_t timeout
Timeout for connection and server response.
static fr_dict_t const * dict_radius
static unlang_action_t mod_authenticate(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
static int imap_conn_alloc(fr_curl_io_request_t *randle, void *uctx)
Callback to configure a CURL handle when it is allocated.
static void imap_io_module_signal(module_ctx_t const *mctx, request_t *request, UNUSED fr_signal_t action)
char const * uri
URI of imap server.
fr_curl_conn_config_t conn_config
Reusable CURL handle config.
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
global_lib_autoinst_t const *const rlm_imap_lib[]
static unlang_action_t mod_authenticate_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
static fr_dict_attr_t const * attr_user_name
fr_dict_autoload_t rlm_imap_dict[]
fr_dict_attr_autoload_t rlm_imap_dict_attr[]
static const conf_parser_t module_config[]
static int _mod_conn_free(fr_curl_io_request_t *randle)
Clean up CURL handle on freeing.
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
fr_curl_handle_t * mhandle
Thread specific multi handle. Serves as the dispatch and coralling structure for imap requests.
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
void * data
Module's instance data.
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Named methods exported by a module.
#define FR_SLAB_FUNCS(_name, _type)
Define type specific wrapper functions for slabs and slab elements.
#define FR_SLAB_TYPES(_name, _type)
Define type specific wrapper structs for slabs and slab elements.
unlang_action_t unlang_module_yield(request_t *request, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx)
Yield a request back to the interpreter from within a module.
eap_aka_sim_process_conf_t * inst
Stores an attribute, a value and various bits of other data.
#define talloc_get_type_abort_const
static int64_t fr_time_delta_to_msec(fr_time_delta_t delta)
A time delta, a difference in time measured in nanoseconds.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.