The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
rlm_ftp.c File Reference

Fetch objects from FTP endpoints. More...

#include <freeradius-devel/curl/base.h>
#include <freeradius-devel/curl/xlat.h>
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/server/global_lib.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/server/log.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/uri.h>
#include <freeradius-devel/unlang/call_env.h>
#include <freeradius-devel/unlang/xlat_func.h>
+ Include dependency graph for rlm_ftp.c:

Go to the source code of this file.

Data Structures

struct  rlm_ftp_curl_context_t
 
struct  rlm_ftp_response_t
 
struct  rlm_ftp_t
 
struct  rlm_ftp_thread_t
 
struct  rlm_ftp_xlat_rctx_t
 

Macros

#define FTP_BODY_ALLOC_CHUNK   1024
 

Enumerations

enum  write_state_t {
  WRITE_STATE_INIT = 0 ,
  WRITE_STATE_POPULATED ,
  WRITE_STATE_DISCARD
}
 

Functions

static int _ftp_request_cleanup (fr_curl_io_request_t *randle, UNUSED void *uctx)
 Cleans up after a FTP request.
 
static int _mod_conn_free (fr_curl_io_request_t *randle)
 
static int ftp_conn_alloc (fr_curl_io_request_t *randle, void *uctx)
 
static xlat_action_t ftp_get_xlat (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
 Simple xlat to read data from an FTP URI.
 
static xlat_action_t ftp_get_xlat_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, UNUSED fr_value_box_list_t *in)
 
static void ftp_io_xlat_signal (xlat_ctx_t const *xctx, request_t *request, UNUSED fr_signal_t action)
 
static size_t ftp_response_body (void *in, size_t size, size_t nmemb, void *userdata)
 
static int ftp_uri_part_escape (fr_value_box_t *vb, UNUSED void *uctx)
 URL escape a single box forming part of a URL.
 
static int ftp_uri_part_escape (fr_value_box_t *vb, void *uctx)
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 
static int mod_thread_detach (module_thread_inst_ctx_t const *mctx)
 Cleanup all outstanding requests associated with this thread.
 
static int mod_thread_instantiate (module_thread_inst_ctx_t const *mctx)
 Create a thread specific multihandle.
 

Variables

static xlat_arg_parser_t const ftp_get_xlat_args []
 
static fr_uri_part_t const ftp_uri_parts []
 
static const conf_parser_t module_config []
 
module_rlm_t rlm_ftp
 
global_lib_autoinst_t const *const rlm_ftp_lib []
 

Detailed Description

Fetch objects from FTP endpoints.

Id
c2cc907ccdd203f13be0bc9e9122dc0345974839

Definition in file rlm_ftp.c.


Data Structure Documentation

◆ rlm_ftp_curl_context_t

struct rlm_ftp_curl_context_t

Definition at line 88 of file rlm_ftp.c.

+ Collaboration diagram for rlm_ftp_curl_context_t:
Data Fields
rlm_ftp_response_t response Response context data.

◆ rlm_ftp_response_t

struct rlm_ftp_response_t

Definition at line 74 of file rlm_ftp.c.

+ Collaboration diagram for rlm_ftp_response_t:
Data Fields
size_t alloc Space allocated for buffer.
char * buffer Raw incoming FTP data.
rlm_ftp_t const * instance This instance of rlm_ftp.
request_t * request Current request.
write_state_t state Decoder state.
size_t used Space used in buffer.

◆ rlm_ftp_t

struct rlm_ftp_t

Definition at line 42 of file rlm_ftp.c.

+ Collaboration diagram for rlm_ftp_t:
Data Fields
bool binary Do we expect binary data - and so output octets.
fr_curl_conn_config_t conn_config Configuration of slab allocated connection handles.
size_t max_resp_size Maximum size of incoming data.

◆ rlm_ftp_thread_t

struct rlm_ftp_thread_t

Definition at line 51 of file rlm_ftp.c.

+ Collaboration diagram for rlm_ftp_thread_t:
Data Fields
rlm_ftp_t const * inst Instance of rlm_ftp.
fr_curl_handle_t * mhandle Thread specific multi handle.

Serves as the dispatch and coralling structure for FTP requests.

ftp_slab_list_t * slab Slab list for connection handles.

◆ rlm_ftp_xlat_rctx_t

struct rlm_ftp_xlat_rctx_t

Definition at line 58 of file rlm_ftp.c.

+ Collaboration diagram for rlm_ftp_xlat_rctx_t:
Data Fields
fr_curl_io_request_t * handle curl easy handle servicing our request.

Macro Definition Documentation

◆ FTP_BODY_ALLOC_CHUNK

#define FTP_BODY_ALLOC_CHUNK   1024

Definition at line 40 of file rlm_ftp.c.

Enumeration Type Documentation

◆ write_state_t

Enumerator
WRITE_STATE_INIT 
WRITE_STATE_POPULATED 
WRITE_STATE_DISCARD 

Definition at line 65 of file rlm_ftp.c.

Function Documentation

◆ _ftp_request_cleanup()

static int _ftp_request_cleanup ( fr_curl_io_request_t randle,
UNUSED void *  uctx 
)
static

Cleans up after a FTP request.

Resets all options associated with a CURL handle, and frees any headers associated with it.

Calls ftp_read_ctx_free and ftp_response_free to free any memory used by context data.

Parameters
[in]randleto cleanup.
[in]uctxunused.

Definition at line 337 of file rlm_ftp.c.

+ Here is the caller graph for this function:

◆ _mod_conn_free()

static int _mod_conn_free ( fr_curl_io_request_t randle)
static

Definition at line 374 of file rlm_ftp.c.

+ Here is the caller graph for this function:

◆ ftp_conn_alloc()

static int ftp_conn_alloc ( fr_curl_io_request_t randle,
void *  uctx 
)
static

Definition at line 380 of file rlm_ftp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ftp_get_xlat_resume()

static xlat_action_t ftp_get_xlat_resume ( TALLOC_CTX *  ctx,
fr_dcursor_t out,
xlat_ctx_t const *  xctx,
UNUSED request_t request,
UNUSED fr_value_box_list_t *  in 
)
static

Definition at line 148 of file rlm_ftp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ftp_io_xlat_signal()

static void ftp_io_xlat_signal ( xlat_ctx_t const *  xctx,
request_t request,
UNUSED fr_signal_t  action 
)
static

Definition at line 186 of file rlm_ftp.c.

+ Here is the caller graph for this function:

◆ ftp_response_body()

static size_t ftp_response_body ( void *  in,
size_t  size,
size_t  nmemb,
void *  userdata 
)
static

Definition at line 206 of file rlm_ftp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ftp_uri_part_escape() [1/2]

static int ftp_uri_part_escape ( fr_value_box_t vb,
UNUSED void *  uctx 
)
static

URL escape a single box forming part of a URL.

Parameters
[in]vbto escape
[in]uctxUNUSED context containing CURL handle
Returns
  • 0 on success
  • -1 on failure

Definition at line 125 of file rlm_ftp.c.

+ Here is the call graph for this function:

◆ ftp_uri_part_escape() [2/2]

static int ftp_uri_part_escape ( fr_value_box_t vb,
void *  uctx 
)
static

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 452 of file rlm_ftp.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Definition at line 464 of file rlm_ftp.c.

◆ mod_thread_detach()

static int mod_thread_detach ( module_thread_inst_ctx_t const *  mctx)
static

Cleanup all outstanding requests associated with this thread.

Destroys all curl easy handles, and then the multihandle associated with this thread.

Parameters
[in]mctxdata to destroy.
Returns
0

Definition at line 442 of file rlm_ftp.c.

+ Here is the call graph for this function:

◆ mod_thread_instantiate()

static int mod_thread_instantiate ( module_thread_inst_ctx_t const *  mctx)
static

Create a thread specific multihandle.

Easy handles representing requests are added to the curl multihandle with the multihandle used for mux/demux.

Parameters
[in]mctxThread instantiation data.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 412 of file rlm_ftp.c.

+ Here is the call graph for this function:

Variable Documentation

◆ ftp_get_xlat_args

xlat_arg_parser_t const ftp_get_xlat_args[]
static
Initial value:
= {
{ .required = true, .safe_for = CURL_URI_SAFE_FOR, .type = FR_TYPE_STRING, .will_escape = true },
}
#define CURL_URI_SAFE_FOR
safe for value suitable for all users of the curl library
Definition xlat.h:36
@ FR_TYPE_STRING
String of printable characters.
#define XLAT_ARG_PARSER_TERMINATOR
Definition xlat.h:170

Definition at line 243 of file rlm_ftp.c.

◆ ftp_uri_parts

fr_uri_part_t const ftp_uri_parts[]
static
Initial value:
= {
{ .name = "scheme", .safe_for = CURL_URI_SAFE_FOR, .terminals = &FR_SBUFF_TERMS(L(":")), .part_adv = { [':'] = 1 }, .extra_skip = 2 },
{ .name = "host", .safe_for = CURL_URI_SAFE_FOR, .terminals = &FR_SBUFF_TERMS(L(":"), L("/")), .part_adv = { [':'] = 1, ['/'] = 2 }, .func = ftp_uri_part_escape },
{ .name = "port", .safe_for = CURL_URI_SAFE_FOR, .terminals = &FR_SBUFF_TERMS(L("/")), .part_adv = { ['/'] = 1 } },
{ .name = "method", .safe_for = CURL_URI_SAFE_FOR, .func = ftp_uri_part_escape },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:209
static int ftp_uri_part_escape(fr_value_box_t *vb, void *uctx)
#define FR_SBUFF_TERMS(...)
Initialise a terminal structure with a list of sorted strings.
Definition sbuff.h:192
#define XLAT_URI_PART_TERMINATOR
Definition uri.h:66

Definition at line 94 of file rlm_ftp.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_TYPE_FLAGS("max_resp_size", FR_TYPE_SIZE, 0, rlm_ftp_t, max_resp_size), .dflt = "16k" },
{ FR_CONF_OFFSET("binary", rlm_ftp_t, binary), .dflt = "no" },
{ FR_CONF_OFFSET_SUBSECTION("connection", 0, rlm_ftp_t, conn_config, fr_curl_conn_config) },
}
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:658
#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
Definition cf_parse.h:284
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
Definition cf_parse.h:313
#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
Definition cf_parse.h:241
conf_parser_t fr_curl_conn_config[]
Definition base.c:97
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.

Definition at line 102 of file rlm_ftp.c.

◆ rlm_ftp

module_rlm_t rlm_ftp
Initial value:
= {
.common = {
.name = "ftp",
.inst_size = sizeof(rlm_ftp_t),
.thread_inst_size = sizeof(rlm_ftp_thread_t),
.config = module_config,
.bootstrap = mod_bootstrap,
.instantiate = mod_instantiate,
.thread_instantiate = mod_thread_instantiate,
.thread_detach = mod_thread_detach
},
.method_group = {
.bindings = (module_method_binding_t[]){
}
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition rlm_ftp.c:452
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
Create a thread specific multihandle.
Definition rlm_ftp.c:412
static const conf_parser_t module_config[]
Definition rlm_ftp.c:102
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
Cleanup all outstanding requests associated with this thread.
Definition rlm_ftp.c:442
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition rlm_ftp.c:464
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Definition module.h:152
Named methods exported by a module.
Definition module.h:174

Definition at line 484 of file rlm_ftp.c.

◆ rlm_ftp_lib

global_lib_autoinst_t const *const rlm_ftp_lib
Initial value:
= {
}
#define GLOBAL_LIB_TERMINATOR
Definition global_lib.h:51
global_lib_autoinst_t fr_curl_autoinst
Definition base.c:387

Definition at line 112 of file rlm_ftp.c.