25 RCSID(
"$Id: 2315b5b1a0548766d942c01dac61be07dedaaf6d $")
27 #include <freeradius-devel/radiusd.h>
28 #include <freeradius-devel/modules.h>
29 #include <freeradius-devel/rad_assert.h>
69 static char const special[] =
"\\'\"`<>|; \t\r\n()[]?#$^&*=";
85 if ((q + 3) >= end)
break;
87 if (strchr(special, *p) != NULL) {
118 RDEBUG(
"Program executed successfully");
124 REDEBUG(
"Program returned invalid code (greater than max rcode) (%i > %i): %s",
135 char *p = &answer[len - 1];
140 while((p > answer) && ((*p ==
'\r') || (*p ==
'\n'))) {
157 void const *mod_inst,
UNUSED void const *xlat_inst,
158 REQUEST *request,
char const *fmt)
166 REDEBUG(
"'wait' must be enabled to use exec xlat");
173 REDEBUG(
"Failed to find input pairs for xlat");
182 result =
radius_exec_program(request, *out, outlen, NULL, request, fmt, input_pairs ? *input_pairs : NULL,
184 if (result != 0)
return -1;
186 for (p = *out; *p !=
'\0'; p++) {
187 if (*p <
' ') *p =
' ';
239 cf_log_err_cs(conf,
"Cannot read output pairs if wait = no");
253 cf_log_err_cs(conf,
"Unknown packet type %s: See list of VALUEs for Packet-Type in "
291 VALUE_PAIR **input_pairs = NULL, **output_pairs = NULL;
293 TALLOC_CTX *ctx = NULL;
300 ERROR(
"rlm_exec (%s): We require a program to execute", inst->
xlat_name);
310 || (request->proxy && (request->proxy->code == inst->
packet_code)) ||
311 (request->proxy_reply && (request->proxy_reply->code == inst->
packet_code))
373 bool we_wait =
false;
387 rcode = mod_exec_dispatch(instance, request);
392 status =
radius_exec_program(request, out,
sizeof(out), &tmp, request, vp->vp_strvalue, request->packet->vps,
428 bool we_wait =
false;
436 return mod_exec_dispatch(instance, request);
449 status =
radius_exec_program(request, out,
sizeof(out), NULL, request, vp->vp_strvalue, request->packet->vps,
469 .config = module_config,
void fr_pair_list_free(VALUE_PAIR **)
Free memory used by a valuepair list.
5 methods index for preproxy section.
static rlm_rcode_t rlm_exec_status2rcode(REQUEST *request, char *answer, size_t len, int status)
Process the exit code returned by one of the exec functions.
int radius_exec_program(TALLOC_CTX *ctx, char *out, size_t outlen, VALUE_PAIR **output_pairs, REQUEST *request, char const *cmd, VALUE_PAIR *input_pairs, bool exec_wait, bool shell_escape, int timeout) CC_HINT(nonnull(5
int xlat_register(void *mod_inst, char const *name, xlat_func_t func, xlat_escape_t escape, xlat_instantiate_t instantiate, size_t inst_size, size_t buf_len)
Register an xlat function.
Main server configuration.
static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
Write accounting data to Couchbase documents.
The module is OK, continue.
static rlm_rcode_t mod_post_auth(void *instance, REQUEST *request) CC_HINT(nonnull)
Metadata exported by the module.
static int mod_bootstrap(CONF_SECTION *conf, void *instance)
7 methods index for postauth section.
TALLOC_CTX * radius_list_ctx(REQUEST *request, pair_lists_t list_name)
Return the correct TALLOC_CTX to alloc VALUE_PAIR in, for a list.
VALUE_PAIR ** radius_list(REQUEST *request, pair_lists_t list)
Resolve attribute pair_lists_t value to an attribute list.
#define RLM_TYPE_THREAD_SAFE
Module is threadsafe.
static rlm_rcode_t CC_HINT(nonnull)
#define CONF_PARSER_TERMINATOR
The module considers the request invalid.
#define XLAT_DEFAULT_BUF_LEN
Defines a CONF_PAIR to C data type mapping.
fr_dict_enum_t * fr_dict_enum_by_name(fr_dict_t *dict, fr_dict_attr_t const *da, char const *val)
static char const special[]
static ssize_t exec_xlat(char **out, size_t outlen, void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt)
static const CONF_PARSER module_config[]
uint32_t max_request_time
How long a request can be processed for before timing out.
#define PW_TYPE_XLAT
string will be dynamically expanded.
Immediately reject the request.
3 methods index for accounting section.
Stores an attribute, a value and various bits of other data.
void void cf_log_err_cs(CONF_SECTION const *cs, char const *fmt,...) CC_HINT(format(printf
0 methods index for authenticate section.
enum rlm_rcodes rlm_rcode_t
Return codes indicating the result of the module call.
char const * cf_section_name1(CONF_SECTION const *cs)
Module succeeded without doing anything.
void fr_pair_list_move(TALLOC_CTX *ctx, VALUE_PAIR **to, VALUE_PAIR **from)
Move pairs from source list to destination list respecting operator.
uint64_t magic
Used to validate module struct.
Module failed, don't reply.
#define FR_CONF_OFFSET(_n, _t, _s, _f)
size_t radius_list_name(pair_lists_t *out, char const *name, pair_lists_t default_list)
Resolve attribute name to a pair_lists_t value.
void module_failure_msg(REQUEST *request, char const *fmt,...) CC_HINT(format(printf
static size_t rlm_exec_shell_escape(UNUSED REQUEST *request, char *out, size_t outlen, char const *in, UNUSED void *inst)
enum pair_lists pair_lists_t
struct rlm_exec_t rlm_exec_t
6 methods index for postproxy section.
2 methods index for preacct section.
VALUE_PAIR * fr_pair_find_by_num(VALUE_PAIR *head, unsigned int vendor, unsigned int attr, int8_t tag)
Find the pair with the matching attribute.
8 methods index for recvcoa section.
9 methods index for sendcoa section.
fr_dict_attr_t const * fr_dict_attr_by_num(fr_dict_t *dict, unsigned int vendor, unsigned int attr)
Lookup a fr_dict_attr_t by its vendor and attribute numbers.
How many valid return codes there are.
String of printable characters.
1 methods index for authorize section.
Value of an enumerated attribute.
char const * cf_section_name2(CONF_SECTION const *cs)