The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
base.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 9e95c09892b813104c3d6ac38a879ef1851a8287 $
19 * @file src/process/radius/base.c
20 * @brief RADIUS process module
21 *
22 * @copyright 2021 The FreeRADIUS server project.
23 * @copyright 2021 Network RADIUS SAS (legal@networkradius.com)
24 */
25#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
26
27#include <freeradius-devel/radius/radius.h>
28
29#include <freeradius-devel/server/main_config.h>
30#include <freeradius-devel/server/module.h>
31#include <freeradius-devel/server/pair.h>
32#include <freeradius-devel/server/protocol.h>
33#include <freeradius-devel/server/state.h>
34#include <freeradius-devel/server/rcode.h>
35#include <freeradius-devel/server/log.h>
36#include <freeradius-devel/unlang/xlat.h>
37
38#include <freeradius-devel/unlang/module.h>
39#include <freeradius-devel/unlang/interpret.h>
40#include <freeradius-devel/unlang/xlat_func.h>
41
42#include <freeradius-devel/util/debug.h>
43#include <freeradius-devel/util/pair.h>
44#include <freeradius-devel/util/value.h>
45
47static fr_dict_t const *dict_radius;
48
51 { .out = &dict_freeradius, .proto = "freeradius" },
52 { .out = &dict_radius, .proto = "radius" },
54};
55
60
69
72 { .out = &attr_auth_type, .name = "Auth-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
73 { .out = &attr_module_failure_message, .name = "Module-Failure-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
74 { .out = &attr_module_success_message, .name = "Module-Success-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
75 { .out = &attr_stripped_user_name, .name = "Stripped-User-Name", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
76
77 { .out = &attr_acct_status_type, .name = "Acct-Status-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
78 { .out = &attr_proxy_state, .name = "Proxy-State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
79 { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
80 { .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
81 { .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
82 { .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
83
84 { .out = &attr_original_packet_code, .name = "Extended-Attribute-1.Original-Packet-Code", .type = FR_TYPE_UINT32, .dict = &dict_radius },
85 { .out = &attr_error_cause, .name = "Error-Cause", .type = FR_TYPE_UINT32, .dict = &dict_radius },
86
88};
89
92
95 { .out = &enum_auth_type_accept, .name = "Accept", .attr = &attr_auth_type },
96 { .out = &enum_auth_type_reject, .name = "Reject", .attr = &attr_auth_type },
98};
99
100/*
101 * RADIUS state machine configuration
102 */
131
132typedef struct {
133 fr_state_config_t session; //!< track state session information.
134 fr_state_tree_t *state_tree; //!< State tree to link multiple requests/responses.
136
137typedef struct {
138 CONF_SECTION *server_cs; //!< Our virtual server.
139 process_radius_sections_t sections; //!< Pointers to various config sections
140 ///< we need to execute.
141 process_radius_auth_t auth; //!< Authentication configuration.
143
144/** Records fields from the original request so we have a known good copy
145 */
146typedef struct {
147 fr_value_box_list_head_t proxy_state; //!< These need to be copied into the response in exactly
148 ///< the same order as they were added.
151
152#define FR_RADIUS_PROCESS_CODE_VALID(_x) (FR_RADIUS_PACKET_CODE_VALID(_x) || (_x == FR_RADIUS_CODE_DO_NOT_RESPOND))
153
154#define PROCESS_PACKET_TYPE fr_radius_packet_code_t
155#define PROCESS_CODE_MAX FR_RADIUS_CODE_MAX
156#define PROCESS_CODE_DO_NOT_RESPOND FR_RADIUS_CODE_DO_NOT_RESPOND
157#define PROCESS_PACKET_CODE_VALID FR_RADIUS_PROCESS_CODE_VALID
158#define PROCESS_INST process_radius_t
159#define PROCESS_RCTX process_radius_rctx_t
160#define PROCESS_CODE_DYNAMIC_CLIENT FR_RADIUS_CODE_ACCESS_ACCEPT
161#include <freeradius-devel/server/process.h>
162
163static const conf_parser_t auth_config[] = {
164 { FR_CONF_POINTER("session", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) state_session_config },
165
167};
168
169static const conf_parser_t config[] = {
170 { FR_CONF_POINTER("Access-Request", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) auth_config,
171 .offset = offsetof(process_radius_t, auth), },
172
174};
175
176/*
177 * Debug the packet if requested.
178 */
179static void radius_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received)
180{
181#ifdef WITH_IFINDEX_NAME_RESOLUTION
182 char if_name[IFNAMSIZ];
183#endif
184
185 if (!packet) return;
186 if (!RDEBUG_ENABLED) return;
187
188 log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s ID %d from %s%pV%s:%i to %s%pV%s:%i "
189#ifdef WITH_IFINDEX_NAME_RESOLUTION
190 "%s%s%s"
191#endif
192 "",
193 received ? "Received" : "Sending",
195 packet->id,
196 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
197 fr_box_ipaddr(packet->socket.inet.src_ipaddr),
198 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "",
199 packet->socket.inet.src_port,
200 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "",
201 fr_box_ipaddr(packet->socket.inet.dst_ipaddr),
202 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
203 packet->socket.inet.dst_port
204#ifdef WITH_IFINDEX_NAME_RESOLUTION
205 , packet->socket.inet.ifindex ? "via " : "",
206 packet->socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "",
207 packet->socket.inet.ifindex ? " " : ""
208#endif
209 );
210
211 if (received || request->parent) {
212 log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL);
213 } else {
214 log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL);
215 }
216}
217
218/** Keep a copy of some attributes to keep them from being tampered with
219 *
220 */
221static inline CC_HINT(always_inline)
223{
224 fr_pair_t *proxy_state;
225
226 /*
227 * Don't bother allocing the struct if there's no proxy state to store
228 */
229 proxy_state = fr_pair_find_by_da(&request->request_pairs, NULL, attr_proxy_state);
230 if (!proxy_state) return;
231
232 fr_value_box_list_init(&rctx->proxy_state);
233
234 /*
235 * We don't use fr_pair_list_copy_by_da, to avoid doing the lookup for
236 * the first proxy-state attr again.
237 */
238 do {
239 fr_value_box_t *proxy_state_value;
240
241 MEM((proxy_state_value = fr_value_box_acopy(rctx, &proxy_state->data)));
242 fr_value_box_list_insert_tail(&rctx->proxy_state, proxy_state_value);
243 } while ((proxy_state = fr_pair_find_by_da(&request->request_pairs, proxy_state, attr_proxy_state)));
244}
245
246static inline CC_HINT(always_inline)
248{
249 /*
250 * Proxy-State is a link-level signal between RADIUS
251 * client and server. RFC 2865 Section 5.33 says that
252 * Proxy-State is an opaque field, and implementations
253 * most not examine it, interpret it, or assign it any
254 * meaning. Implementations must also copy all Proxy-State
255 * from the request to the reply.
256 *
257 * The rlm_radius module already deletes any Proxy-State
258 * from the reply before appending the proxy reply to the
259 * current reply.
260 *
261 * If any policy creates Proxy-State, that could affect
262 * individual RADIUS links (perhaps), and that would be
263 * wrong. As such, we nuke any nonsensical Proxy-State
264 * added by policies or errant modules, and instead just
265 * do exactly what the RFCs require us to do. No more.
266 */
267 fr_pair_delete_by_da(&request->reply_pairs, attr_proxy_state);
268
269 RDEBUG3("Adding Proxy-State attributes from request");
270 RINDENT();
271 fr_value_box_list_foreach(&rctx->proxy_state, proxy_state_value) {
272 fr_pair_t *vp;
273
274 MEM(vp = fr_pair_afrom_da(request->reply_ctx, attr_proxy_state));
275 if (unlikely(fr_value_box_copy(vp, &vp->data, proxy_state_value) < 0)) {
276 RDEBUG2("Failed to copy Proxy-State value %pV", proxy_state_value);
278 break;
279 }
280 fr_pair_append(&request->reply_pairs, vp);
281 RDEBUG3("reply.%pP", vp);
282 }
283 REXDENT();
284}
285
286/** A wrapper around recv generic which stores fields from the request
287 */
288RECV(generic_radius_request)
289{
290 radius_request_pairs_store(request, mctx->rctx);
291
292 return CALL_RECV(generic);
293}
294
295/** A wrapper around send generic which restores fields
296 *
297 */
298RESUME(generic_radius_response)
299{
300 radius_request_pairs_to_reply(request, talloc_get_type_abort(mctx->rctx, process_radius_rctx_t));
301
302 return CALL_RESUME(send_generic);
303}
304
305RECV(access_request)
306{
308
309 if (fr_state_restore(inst->auth.state_tree, request) < 0) {
310 return CALL_SEND_TYPE(FR_RADIUS_CODE_ACCESS_REJECT);
311 }
312
313 return CALL_RECV(generic_radius_request);
314}
315
316RESUME(auth_type);
317
318RESUME(access_request)
319{
320 rlm_rcode_t rcode = RESULT_RCODE;
321 fr_pair_t *vp;
322 CONF_SECTION *cs;
323 fr_dict_enum_value_t const *dv;
324 fr_process_state_t const *state;
326
328
330
331 /*
332 * See if the return code from "recv Access-Request" says we reject, or continue.
333 */
334 UPDATE_STATE(packet);
335
336 /*
337 * A policy or a module can hard-code the reply, in which case we can process that immediately,
338 * and bypass the "authenticate" section.
339 */
340 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_packet_type);
341 if (vp && FR_RADIUS_PROCESS_CODE_VALID(vp->vp_uint32)) {
342 request->reply->code = vp->vp_uint32;
343 (void) fr_pair_delete(&request->reply_pairs, vp);
344 } else {
345 /*
346 * Get the default reply packet based on the rcode.
347 */
348 request->reply->code = state->packet_type[rcode];
349 if (!request->reply->code) request->reply->code = state->default_reply;
350 }
351
352 /*
353 * Either the code above or a module set reject, we're done.
354 */
355 if (request->reply->code == FR_RADIUS_CODE_ACCESS_REJECT) {
356 RDEBUG("The 'recv Access-Request' section returned %s - rejecting the request",
357 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
358
360 UPDATE_STATE(reply);
361
362 fr_assert(state->send != NULL);
363 return CALL_SEND_STATE(state);
364 }
365
366 /*
367 * Something set a reply, bypass the "authenticate" section.
368 */
369 if (request->reply->code) {
370 goto send_reply;
371 }
372
373 /*
374 * Run authenticate foo { ... }
375 *
376 * If we can't find Auth-Type, OR if we can't find
377 * Auth-Type = foo, then it's a reject.
378 */
379 vp = fr_pair_find_by_da(&request->control_pairs, NULL, attr_auth_type);
380 if (!vp) {
381 RDEBUG("No 'Auth-Type' attribute found, cannot authenticate the user - rejecting the request");
382
383 reject:
384 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
385 goto send_reply;
386 }
387
388 dv = fr_dict_enum_by_value(vp->da, &vp->data);
389 if (!dv) {
390 RDEBUG("Invalid value for 'Auth-Type' attribute, cannot authenticate the user - rejecting the request");
391 goto reject;
392 }
393
394 /*
395 * The magic Auth-Type Accept value which means skip the authenticate section.
396 *
397 * And Reject means always reject. Tho the admin should instead just return "reject" from the
398 * section.
399 */
401 request->reply->code = FR_RADIUS_CODE_ACCESS_ACCEPT;
402 goto send_reply;
403
404 } else if (fr_value_box_cmp(enum_auth_type_reject, dv->value) == 0) {
405 goto reject;
406 }
407
408 cs = cf_section_find(inst->server_cs, "authenticate", dv->name);
409 if (!cs) {
410 RDEBUG2("No 'authenticate %s { ... }' section found - rejecting the request", dv->name);
411 goto reject;
412 }
413
414 /*
415 * Run the "Authenticate = foo" section.
416 *
417 * And continue with sending the generic reply.
418 */
419 RDEBUG("Running 'authenticate %s' from file %s", cf_section_name2(cs), cf_filename(cs));
420 return unlang_module_yield_to_section(RESULT_P, request,
421 cs, RLM_MODULE_NOOP, resume_auth_type,
422 NULL, 0, mctx->rctx);
423}
424
425RESUME(auth_type)
426{
427 static const fr_process_rcode_t auth_type_rcode = {
431 [RLM_MODULE_HANDLED] = 0,
438 };
439
440 rlm_rcode_t rcode = RESULT_RCODE;
441 fr_pair_t *vp;
442 fr_process_state_t const *state;
443
445
447
448 /*
449 * Allow user to specify response packet type here, too.
450 */
451 if (!auth_type_rcode[rcode]) {
452 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_packet_type);
453 if (vp && FR_RADIUS_PROCESS_CODE_VALID(vp->vp_uint32)) {
454 request->reply->code = vp->vp_uint32;
455 (void) fr_pair_delete(&request->reply_pairs, vp);
456 }
457 } else {
458 request->reply->code = auth_type_rcode[rcode];
459 }
460
461 switch (request->reply->code) {
462 case 0:
463 RDEBUG("No reply code was set. Forcing to Access-Reject");
464 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
466
467 /*
468 * Print complaints before running "send Access-Reject"
469 */
471 RDEBUG2("Failed to authenticate the user");
472
473 /*
474 * Maybe the shared secret is wrong?
475 */
476 vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_user_password);
477 if (vp) {
478 if (RDEBUG_ENABLED2) {
479 uint8_t const *p;
480
481 p = (uint8_t const *) vp->vp_strvalue;
482 while (*p) {
483 int size;
484
485 size = fr_utf8_char(p, -1);
486 if (!size) {
487 REDEBUG("Unprintable characters in the password. "
488 "Double-check the shared secret on the server "
489 "and the NAS!");
490 REDEBUG("For more information, please see " DOC_ROOT_URL "/troubleshooting/network/shared_secret.html");
491 break;
492 }
493 p += size;
494 }
495 }
496 }
497 break;
498
499 /*
500 * Access-Challenge sections require a State. If there is
501 * none, create one here. This is so that the State
502 * attribute is accessible in the "send Access-Challenge"
503 * section.
504 */
506 if ((vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_state)) == NULL) {
507 uint8_t buffer[16];
508
509 fr_rand_buffer(buffer, sizeof(buffer));
510
512 fr_pair_value_memdup(vp, buffer, sizeof(buffer), false);
513 }
514 break;
515
516 default:
517 break;
518 }
519 UPDATE_STATE(reply);
520
521 fr_assert(state->send != NULL);
522 return state->send(p_result, mctx, request);
523}
524
525RESUME_FLAG(access_accept,UNUSED,)
526{
527 fr_pair_t *vp;
529
531
532 /*
533 * Check that there is a name which can be used to
534 * identify the user. The configuration depends on
535 * User-Name or Stripped-User-Name existing, and being
536 * (mostly) unique to that user.
537 */
538 if (!request->parent &&
539 ((vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_user_name)) != NULL) &&
540 (vp->vp_strvalue[0] == '@') &&
541 !fr_pair_find_by_da(&request->request_pairs, NULL, attr_stripped_user_name)) {
542 RWDEBUG("User-Name is anonymized, and no Stripped-User-Name exists.");
543 RWDEBUG("It may be difficult or impossible to identify the user.");
544 RWDEBUG("Please update Stripped-User-Name with information which identifies the user.");
545 }
546
547 fr_state_discard(inst->auth.state_tree, request);
548 radius_request_pairs_to_reply(request, mctx->rctx);
550}
551
552RESUME_FLAG(access_reject,UNUSED,)
553{
555
557
558 fr_state_discard(inst->auth.state_tree, request);
559 radius_request_pairs_to_reply(request, mctx->rctx);
561}
562
563RESUME(access_challenge)
564{
566
568
569 /*
570 * Cache the state context, unless this is a subrequest.
571 * Subrequest state context will be handled by the caller.
572 *
573 * If this fails, don't respond to the request.
574 */
575 if (!request->parent && fr_state_store(inst->auth.state_tree, request) < 0) {
576 return CALL_SEND_TYPE(FR_RADIUS_CODE_DO_NOT_RESPOND);
577 }
578
579 fr_assert(request->reply->code == FR_RADIUS_CODE_ACCESS_CHALLENGE);
580 radius_request_pairs_to_reply(request, mctx->rctx);
582}
583
584/** A wrapper around recv generic which stores fields from the request
585 */
586RECV(accounting_request)
587{
588 radius_request_pairs_store(request, mctx->rctx);
589
590 return CALL_RECV(generic);
591}
592
593RESUME(acct_type)
594{
595 static const fr_process_rcode_t acct_type_rcode = {
602 };
603
604 rlm_rcode_t rcode = RESULT_RCODE;
605 fr_process_state_t const *state;
606
608
610 fr_assert(FR_RADIUS_PROCESS_CODE_VALID(request->reply->code));
611
612 if (acct_type_rcode[rcode]) {
613 fr_assert(acct_type_rcode[rcode] == FR_RADIUS_CODE_DO_NOT_RESPOND);
614
615 request->reply->code = acct_type_rcode[rcode];
616 UPDATE_STATE(reply);
617
618 RDEBUG("The 'accounting' section returned %s - not sending a response",
619 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
620
621 fr_assert(state->send != NULL);
622 return state->send(p_result, mctx, request);
623 }
624
625 request->reply->code = FR_RADIUS_CODE_ACCOUNTING_RESPONSE;
626 UPDATE_STATE(reply);
627
628 fr_assert(state->send != NULL);
629 return state->send(p_result, mctx, request);
630}
631
632RESUME(accounting_request)
633{
634 rlm_rcode_t rcode = RESULT_RCODE;
635 fr_pair_t *vp;
636 CONF_SECTION *cs;
637 fr_dict_enum_value_t const *dv;
638 fr_process_state_t const *state;
640
642
644
645 UPDATE_STATE(packet);
646 fr_assert(state->packet_type[rcode] != 0);
647
648 request->reply->code = state->packet_type[rcode];
649 UPDATE_STATE_CS(reply);
650
651 if (request->reply->code == FR_RADIUS_CODE_DO_NOT_RESPOND) {
652 RDEBUG("The 'recv Accounting-Request' section returned %s - not sending a response",
653 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
654
656 fr_assert(state->send != NULL);
657 return CALL_SEND_STATE(state);
658 }
659
660 /*
661 * Run accounting foo { ... }
662 */
663 vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_acct_status_type);
664 if (!vp) goto send_reply;
665
666 dv = fr_dict_enum_by_value(vp->da, &vp->data);
667 if (!dv) goto send_reply;
668
669 cs = cf_section_find(inst->server_cs, "accounting", dv->name);
670 if (!cs) {
671 RDEBUG2("No 'accounting %s { ... }' section found - skipping...", dv->name);
672 goto send_reply;
673 }
674
675 /*
676 * Run the "Acct-Status-Type = foo" section.
677 *
678 * And continue with sending the generic reply.
679 */
680 return unlang_module_yield_to_section(RESULT_P, request,
681 cs, RLM_MODULE_NOOP, resume_acct_type,
682 NULL, 0, mctx->rctx);
683}
684
685#if 0
686// @todo - send canned responses like in v3?
687RECV(status_server)
688{
690}
691
692RESUME(status_server)
693{
695}
696#endif
697
698RESUME_FLAG(protocol_error,UNUSED,)
699{
700 fr_pair_t *vp;
702
704
705 fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->reply->code));
706
707 /*
708 * https://tools.ietf.org/html/rfc7930#section-4
709 */
710 vp = fr_pair_find_by_da_nested(&request->reply_pairs, NULL, attr_original_packet_code);
711 if (!vp) {
712 vp = fr_pair_afrom_da(request->reply_ctx, attr_original_packet_code);
713 if (vp) {
714 vp->vp_uint32 = request->packet->code;
715 fr_pair_append(&request->reply_pairs, vp);
716 }
717 }
718
719 /*
720 * If there's no Error-Cause, then include a generic 404.
721 */
722 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_error_cause);
723 if (!vp) {
724 vp = fr_pair_afrom_da(request->reply_ctx, attr_error_cause);
725 if (vp) {
726 vp->vp_uint32 = FR_ERROR_CAUSE_VALUE_INVALID_REQUEST;
727 fr_pair_append(&request->reply_pairs, vp);
728 }
729 }
730
731 /*
732 * Discard any session state associated with the request.
733 */
734 if (request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) {
735 fr_state_discard(inst->auth.state_tree, request);
736 }
737
738 /*
739 * Add Proxy-State back.
740 */
741 radius_request_pairs_to_reply(request, talloc_get_type_abort(mctx->rctx, process_radius_rctx_t));
742
743 /*
744 * And do the generic processing after running a "send" section.
745 */
746 return CALL_RESUME(send_generic);
747}
748
749static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
750{
751 fr_process_state_t const *state;
752
754
756
757 request->component = "radius";
758 request->module = NULL;
759 fr_assert(request->proto_dict == dict_radius);
760
761 fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->packet->code));
762
763 UPDATE_STATE(packet);
764
765 if (!state->recv) {
766 REDEBUG("Invalid packet type (%u)", request->packet->code);
768 }
769
770 radius_packet_debug(request, request->packet, &request->request_pairs, true);
771
772 if (unlikely(request_is_dynamic_client(request))) {
773 return new_client(p_result, mctx, request);
774 }
775
776 return state->recv(p_result, mctx, request);
777}
778
780 { .required = true, .single = true, .type = FR_TYPE_OCTETS },
782};
783
784/** Validates a request against a know shared secret
785 *
786 * Designed for the specific purpose of verifying dynamic clients
787 * against a know shared secret.
788 *
789 * Example:
790@verbatim
791%radius.secret.verify(<secret>)
792@endverbatim
793 *
794 * @ingroup xlat_functions
795 */
797 request_t *request, fr_value_box_list_t *args)
798{
800 int ret;
801 bool require_message_authenticator = false;
802
804
805 if (request->proto_dict != dict_radius) return XLAT_ACTION_FAIL;
806
807 MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_BOOL, NULL));
808
809 /*
810 * Only Access-Requests require a Message-Authenticator.
811 * All the other packet types are signed using the
812 * authenticator field.
813 */
814 if (request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) require_message_authenticator = true;
815
816 ret = fr_radius_verify(request->packet->data, NULL, secret->vb_octets, secret->vb_length, require_message_authenticator, false);
817 switch (ret) {
818 case 0:
819 vb->vb_bool = true;
820 break;
821
822 default:
823 RPEDEBUG("Invalid packet");
824 return XLAT_ACTION_FAIL;
825
828 RPEDEBUG("Failed to verify the packet signature");
829 vb->vb_bool = false;
830 break;
831 }
833
834 return XLAT_ACTION_DONE;
835}
836
837static int mod_instantiate(module_inst_ctx_t const *mctx)
838{
839 process_radius_t *inst = talloc_get_type_abort(mctx->mi->data, process_radius_t);
840
841 inst->server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
842
843 FR_INTEGER_BOUND_CHECK("session.max_rounds", inst->auth.session.max_rounds, >=, 32);
844 FR_INTEGER_BOUND_CHECK("session.max_rounds", inst->auth.session.max_rounds, <=, 100);
845
846 inst->auth.session.thread_safe = main_config->spawn_workers;
847 inst->auth.session.context_id = fr_hash_string(cf_section_name2(inst->server_cs));
848
849 MEM(inst->auth.state_tree = fr_state_tree_init(inst, attr_state, &inst->auth.session));
850
851 return 0;
852}
853
854static int mod_bootstrap(module_inst_ctx_t const *mctx)
855{
856 CONF_SECTION *server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
857
858 if (virtual_server_section_attribute_define(server_cs, "authenticate", attr_auth_type) < 0) return -1;
859
860 return 0;
861}
862
863static int mod_load(void)
864{
865 xlat_t *xlat;
866
867 if (unlikely(!(xlat = xlat_func_register(NULL, "radius.secret.verify", xlat_func_radius_secret_verify,
868 FR_TYPE_BOOL)))) return -1;
869
871
872 return 0;
873}
874
875static void mod_unload(void)
876{
877 xlat_func_unregister("radius.secret.verify");
878}
879
880/*
881 * rcodes not listed under a packet_type
882 * mean that the packet code will not be
883 * changed.
884 */
885static fr_process_state_t const process_state[] = {
887 .packet_type = {
894 },
895 .default_rcode = RLM_MODULE_NOOP,
896 .recv = recv_access_request,
897 .resume = resume_access_request,
898 .section_offset = offsetof(process_radius_sections_t, access_request),
899 },
901 .packet_type = {
907 },
908 .default_rcode = RLM_MODULE_NOOP,
909 .result_rcode = RLM_MODULE_OK,
910 .send = send_generic,
911 .resume = resume_access_accept,
912 .section_offset = offsetof(process_radius_sections_t, access_accept),
913 },
915 .packet_type = {
921 },
922 .default_rcode = RLM_MODULE_NOOP,
923 .result_rcode = RLM_MODULE_REJECT,
924 .send = send_generic,
925 .resume = resume_access_reject,
926 .section_offset = offsetof(process_radius_sections_t, access_reject),
927 },
929 .packet_type = {
935 },
936 .default_rcode = RLM_MODULE_NOOP,
937 .result_rcode = RLM_MODULE_OK,
938 .send = send_generic,
939 .resume = resume_access_challenge,
940 .section_offset = offsetof(process_radius_sections_t, access_challenge),
941 },
942
944 .packet_type = {
949
956 },
957 .default_rcode = RLM_MODULE_NOOP,
958 .recv = recv_accounting_request,
959 .resume = resume_accounting_request,
960 .section_offset = offsetof(process_radius_sections_t, accounting_request),
961 },
963 .packet_type = {
970 },
971 .default_rcode = RLM_MODULE_NOOP,
972 .result_rcode = RLM_MODULE_OK,
973 .send = send_generic,
974 .resume = resume_generic_radius_response,
975 .section_offset = offsetof(process_radius_sections_t, accounting_response),
976 },
977 [ FR_RADIUS_CODE_STATUS_SERVER ] = { /* @todo - negotiation, stats, etc. */
978 .packet_type = {
981
989 },
990 .default_rcode = RLM_MODULE_NOOP,
991 .recv = recv_generic,
992 .resume = resume_recv_generic,
993 .section_offset = offsetof(process_radius_sections_t, status_server),
994 },
996 .packet_type = {
1001
1007 },
1008 .default_rcode = RLM_MODULE_NOOP,
1009 .recv = recv_generic_radius_request,
1010 .resume = resume_recv_generic,
1011 .section_offset = offsetof(process_radius_sections_t, coa_request),
1012 },
1014 .packet_type = {
1020 },
1021 .default_rcode = RLM_MODULE_NOOP,
1022 .result_rcode = RLM_MODULE_OK,
1023 .send = send_generic,
1024 .resume = resume_generic_radius_response,
1025 .section_offset = offsetof(process_radius_sections_t, coa_ack),
1026 },
1028 .packet_type = {
1034 },
1035 .default_rcode = RLM_MODULE_NOOP,
1036 .result_rcode = RLM_MODULE_NOTFOUND,
1037 .send = send_generic,
1038 .resume = resume_generic_radius_response,
1039 .section_offset = offsetof(process_radius_sections_t, coa_nak),
1040 },
1042 .packet_type = {
1047
1053 },
1054 .default_rcode = RLM_MODULE_NOOP,
1055 .recv = recv_generic_radius_request,
1056 .resume = resume_recv_generic,
1057 .section_offset = offsetof(process_radius_sections_t, disconnect_request),
1058 },
1060 .packet_type = {
1066 },
1067 .default_rcode = RLM_MODULE_NOOP,
1068 .result_rcode = RLM_MODULE_OK,
1069 .send = send_generic,
1070 .resume = resume_generic_radius_response,
1071 .section_offset = offsetof(process_radius_sections_t, disconnect_ack),
1072 },
1074 .packet_type = {
1080 },
1081 .default_rcode = RLM_MODULE_NOOP,
1082 .result_rcode = RLM_MODULE_NOTFOUND,
1083 .send = send_generic,
1084 .resume = resume_generic_radius_response,
1085 .section_offset = offsetof(process_radius_sections_t, disconnect_nak),
1086 },
1087 [ FR_RADIUS_CODE_PROTOCOL_ERROR ] = { /* @todo - fill out required fields */
1088 .packet_type = {
1094 },
1095 .default_rcode = RLM_MODULE_NOOP,
1096 .result_rcode = RLM_MODULE_OK,
1097 .send = send_generic,
1098 .resume = resume_protocol_error,
1099 .section_offset = offsetof(process_radius_sections_t, protocol_error),
1100 },
1102 .packet_type = {
1107
1114 },
1115 .default_rcode = RLM_MODULE_NOOP,
1116 .result_rcode = RLM_MODULE_HANDLED,
1117 .send = send_generic,
1118 .resume = resume_send_generic,
1119 .section_offset = offsetof(process_radius_sections_t, do_not_respond),
1120 }
1121};
1122
1124 {
1125 .section = SECTION_NAME("recv", "Access-Request"),
1126 .actions = &mod_actions_authorize,
1127 .offset = PROCESS_CONF_OFFSET(access_request),
1128 },
1129 {
1130 .section = SECTION_NAME("send", "Access-Accept"),
1132 .offset = PROCESS_CONF_OFFSET(access_accept),
1133 },
1134 {
1135 .section = SECTION_NAME("send", "Access-Challenge"),
1137 .offset = PROCESS_CONF_OFFSET(access_challenge),
1138 },
1139 {
1140 .section = SECTION_NAME("send", "Access-Reject"),
1142 .offset = PROCESS_CONF_OFFSET(access_reject),
1143 },
1144
1145 {
1146 .section = SECTION_NAME("recv", "Accounting-Request"),
1148 .offset = PROCESS_CONF_OFFSET(accounting_request),
1149 },
1150 {
1151 .section = SECTION_NAME("send", "Accounting-Response"),
1153 .offset = PROCESS_CONF_OFFSET(accounting_response),
1154 },
1155
1156 {
1157 .section = SECTION_NAME("recv", "Status-Server"),
1159 .offset = PROCESS_CONF_OFFSET(status_server),
1160 },
1161 {
1162 .section = SECTION_NAME("recv", "CoA-Request"),
1164 .offset = PROCESS_CONF_OFFSET(coa_request),
1165 },
1166 {
1167 .section = SECTION_NAME("send", "CoA-ACK"),
1169 .offset = PROCESS_CONF_OFFSET(coa_ack),
1170 },
1171 {
1172 .section = SECTION_NAME("send", "CoA-NAK"),
1174 .offset = PROCESS_CONF_OFFSET(coa_nak),
1175 },
1176 {
1177 .section = SECTION_NAME("recv", "Disconnect-Request"),
1179 .offset = PROCESS_CONF_OFFSET(disconnect_request),
1180 },
1181 {
1182 .section = SECTION_NAME("send", "Disconnect-ACK"),
1184 .offset = PROCESS_CONF_OFFSET(disconnect_ack),
1185 },
1186 {
1187 .section = SECTION_NAME("send", "Disconnect-NAK"),
1189 .offset = PROCESS_CONF_OFFSET(disconnect_nak),
1190 },
1191 {
1192 .section = SECTION_NAME("send", "Protocol-Error"),
1194 .offset = PROCESS_CONF_OFFSET(protocol_error),
1195 },
1196 {
1197 .section = SECTION_NAME("send", "Do-Not-Respond"),
1199 .offset = PROCESS_CONF_OFFSET(do_not_respond),
1200 },
1201 {
1202 .section = SECTION_NAME("authenticate", CF_IDENT_ANY),
1204 },
1205 {
1206 .section = SECTION_NAME("accounting", CF_IDENT_ANY),
1208 },
1209
1210 DYNAMIC_CLIENT_SECTIONS,
1211
1213};
1214
1217 .common = {
1218 .magic = MODULE_MAGIC_INIT,
1219 .name = "radius",
1220 .config = config,
1223
1224 .onload = mod_load,
1225 .unload = mod_unload,
1226 .bootstrap = mod_bootstrap,
1227 .instantiate = mod_instantiate
1228 },
1229 .process = mod_process,
1230 .compile_list = compile_list,
1231 .dict = &dict_radius,
1232 .packet_type = &attr_packet_type
1233};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
Definition action.h:37
static int const char char buffer[256]
Definition acutest.h:578
va_list args
Definition acutest.h:772
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
Definition build.h:324
#define unlikely(_x)
Definition build.h:383
#define UNUSED
Definition build.h:317
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:660
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:520
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition cf_parse.h:337
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition cf_parse.h:426
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:597
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
Definition cf_util.c:1184
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
Definition cf_util.c:1027
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition cf_util.c:683
#define cf_parent(_cf)
Definition cf_util.h:101
#define cf_filename(_cf)
Definition cf_util.h:107
#define CF_IDENT_ANY
Definition cf_util.h:78
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
Definition dcursor.h:408
#define MEM(x)
Definition debug.h:36
@ FR_RADIUS_CODE_ACCESS_CHALLENGE
RFC2865 - Access-Challenge.
Definition defs.h:43
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
Definition defs.h:33
@ FR_RADIUS_CODE_DISCONNECT_REQUEST
RFC3575/RFC5176 - Disconnect-Request.
Definition defs.h:46
@ FR_RADIUS_CODE_DO_NOT_RESPOND
Special rcode to indicate we will not respond.
Definition defs.h:54
@ FR_RADIUS_CODE_DISCONNECT_ACK
RFC3575/RFC5176 - Disconnect-Ack (positive)
Definition defs.h:47
@ FR_RADIUS_CODE_STATUS_SERVER
RFC2865/RFC5997 - Status Server (request)
Definition defs.h:44
@ FR_RADIUS_CODE_COA_REQUEST
RFC3575/RFC5176 - CoA-Request.
Definition defs.h:49
@ FR_RADIUS_CODE_ACCESS_ACCEPT
RFC2865 - Access-Accept.
Definition defs.h:34
@ FR_RADIUS_CODE_ACCOUNTING_RESPONSE
RFC2866 - Accounting-Response.
Definition defs.h:37
@ FR_RADIUS_CODE_COA_NAK
RFC3575/RFC5176 - CoA-Nak (not willing to perform)
Definition defs.h:51
@ FR_RADIUS_CODE_COA_ACK
RFC3575/RFC5176 - CoA-Ack (positive)
Definition defs.h:50
@ FR_RADIUS_CODE_DISCONNECT_NAK
RFC3575/RFC5176 - Disconnect-Nak (not willing to perform)
Definition defs.h:48
@ FR_RADIUS_CODE_PROTOCOL_ERROR
RFC7930 - Protocol-Error (generic NAK)
Definition defs.h:52
@ FR_RADIUS_CODE_ACCOUNTING_REQUEST
RFC2866 - Accounting-Request.
Definition defs.h:36
@ FR_RADIUS_CODE_ACCESS_REJECT
RFC2865 - Access-Reject.
Definition defs.h:35
fr_value_box_t const ** out
Enumeration value.
Definition dict.h:283
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:294
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:307
fr_value_box_t const * value
Enum value (what name maps to).
Definition dict.h:259
fr_dict_enum_value_t const * fr_dict_enum_by_value(fr_dict_attr_t const *da, fr_value_box_t const *value)
Lookup the structure representing an enum value in a fr_dict_attr_t.
Definition dict_util.c:3662
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:313
char const * name
Enum name.
Definition dict.h:256
Specifies an attribute which must be present for the module to function.
Definition dict.h:293
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:306
Specifies a value which must be present for the module to function.
Definition dict.h:282
Value of an enumerated attribute.
Definition dict.h:255
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
static xlat_action_t xlat_func_radius_secret_verify(TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args)
Validates a request against a know shared secret.
Definition base.c:796
uint32_t fr_hash_string(char const *p)
Definition hash.c:869
talloc_free(hp)
static fr_dict_t const * dict_freeradius
Definition base.c:37
fr_dict_attr_t const * attr_packet_type
Definition base.c:93
fr_dict_attr_t const * attr_state
Definition base.c:103
fr_dict_t const * dict_radius
Definition base.c:78
fr_dict_attr_t const * attr_user_name
Definition base.c:104
static fr_dict_attr_t const * attr_module_failure_message
Definition log.c:206
void log_request_proto_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a list of protocol fr_pair_ts.
Definition log.c:844
void log_request(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt,...)
Marshal variadic log arguments into a va_list and pass to normal logging functions.
Definition log.c:610
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a fr_pair_list_t.
Definition log.c:820
#define REXDENT()
Exdent (unindent) R* messages by one level.
Definition log.h:455
#define RWDEBUG(fmt,...)
Definition log.h:373
#define RDEBUG3(fmt,...)
Definition log.h:355
#define RPEDEBUG(fmt,...)
Definition log.h:388
#define RINDENT()
Indent R* messages by one level.
Definition log.h:442
@ L_DBG_LVL_1
Highest priority debug messages (-x).
Definition log.h:70
@ L_DBG
Only displayed when debugging is enabled.
Definition log.h:59
main_config_t const * main_config
Main server configuration.
Definition main_config.c:58
bool spawn_workers
Should the server spawn threads.
Definition main_config.h:58
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_OCTETS
Raw octets.
unsigned char uint8_t
unlang_mod_actions_t const mod_actions_preacct
Definition mod_action.c:62
unlang_mod_actions_t const mod_actions_authenticate
Definition mod_action.c:30
unlang_mod_actions_t const mod_actions_accounting
Definition mod_action.c:78
unlang_mod_actions_t const mod_actions_authorize
Definition mod_action.c:46
unlang_mod_actions_t const mod_actions_postauth
Definition mod_action.c:93
unlang_mod_action_t actions[RLM_MODULE_NUMCODES]
Definition mod_action.h:69
module_instance_t const * mi
Instance of the module being instantiated.
Definition module_ctx.h:42
module_instance_t * mi
Instance of the module being instantiated.
Definition module_ctx.h:51
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
Definition pair.c:2945
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.
Definition pair.c:781
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.
Definition pair.c:704
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
Definition pair.c:1349
int fr_pair_delete_by_da(fr_pair_list_t *list, fr_dict_attr_t const *da)
Delete matching pairs from the specified list.
Definition pair.c:1693
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
Definition pair.c:290
int fr_pair_delete(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list and free.
Definition pair.c:1830
size_t fr_utf8_char(uint8_t const *str, ssize_t inlen)
Checks for utf-8, taken from http://www.w3.org/International/questions/qa-forms-utf-8.
Definition print.c:39
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition base.c:188
static const virtual_server_compile_t compile_list[]
Definition base.c:214
static fr_process_state_t const process_state[]
Definition base.c:69
RESUME_FLAG(recv_bfd, UNUSED,)
Definition base.c:119
static fr_dict_attr_t const * attr_module_success_message
Definition base.c:37
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition base.c:752
RECV(for_any_server)
Validate a solicit/rebind/confirm message.
Definition base.c:400
static int mod_load(void)
Definition base.c:228
static void mod_unload(void)
Definition base.c:237
process_radius_auth_t auth
Authentication configuration.
Definition base.c:141
CONF_SECTION * access_challenge
Definition base.c:109
static fr_dict_attr_t const * attr_user_password
Definition base.c:66
CONF_SECTION * coa_nak
Definition base.c:118
static xlat_arg_parser_t const xlat_func_radius_secret_verify_args[]
Definition base.c:779
CONF_SECTION * disconnect_ack
Definition base.c:121
CONF_SECTION * protocol_error
Definition base.c:125
CONF_SECTION * new_client
Definition base.c:127
static fr_dict_attr_t const * attr_stripped_user_name
Definition base.c:59
fr_dict_attr_autoload_t process_radius_dict_attr[]
Definition base.c:71
CONF_SECTION * coa_request
Definition base.c:116
fr_value_box_list_head_t proxy_state
These need to be copied into the response in exactly the same order as they were added.
Definition base.c:147
fr_dict_enum_autoload_t process_radius_dict_enum[]
Definition base.c:94
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition base.c:854
fr_process_module_t process_radius
Definition base.c:1216
static fr_dict_attr_t const * attr_auth_type
Definition base.c:56
static void radius_request_pairs_to_reply(request_t *request, process_radius_rctx_t *rctx)
Definition base.c:247
#define FR_RADIUS_PROCESS_CODE_VALID(_x)
Definition base.c:152
CONF_SECTION * disconnect_nak
Definition base.c:122
CONF_SECTION * access_accept
Definition base.c:107
static fr_value_box_t const * enum_auth_type_reject
Definition base.c:91
static void radius_request_pairs_store(request_t *request, process_radius_rctx_t *rctx)
Keep a copy of some attributes to keep them from being tampered with.
Definition base.c:222
static fr_dict_attr_t const * attr_error_cause
Definition base.c:68
CONF_SECTION * add_client
Definition base.c:128
static const conf_parser_t auth_config[]
Definition base.c:163
CONF_SECTION * server_cs
Our virtual server.
Definition base.c:138
CONF_SECTION * access_request
Definition base.c:106
static fr_dict_attr_t const * attr_proxy_state
Definition base.c:63
static void radius_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received)
Definition base.c:179
static fr_value_box_t const * enum_auth_type_accept
Definition base.c:90
CONF_SECTION * status_server
Definition base.c:114
CONF_SECTION * access_reject
Definition base.c:108
static fr_dict_attr_t const * attr_acct_status_type
Definition base.c:61
CONF_SECTION * disconnect_request
Definition base.c:120
CONF_SECTION * accounting_request
Definition base.c:111
CONF_SECTION * coa_ack
Definition base.c:117
CONF_SECTION * do_not_respond
Definition base.c:124
fr_state_config_t session
track state session information.
Definition base.c:133
process_radius_sections_t sections
Pointers to various config sections we need to execute.
Definition base.c:139
static fr_dict_attr_t const * attr_original_packet_code
Definition base.c:67
unlang_result_t result
Definition base.c:149
static const conf_parser_t config[]
Definition base.c:169
fr_dict_autoload_t process_radius_dict[]
Definition base.c:50
fr_state_tree_t * state_tree
State tree to link multiple requests/responses.
Definition base.c:134
CONF_SECTION * accounting_response
Definition base.c:112
CONF_SECTION * deny_client
Definition base.c:129
Records fields from the original request so we have a known good copy.
Definition base.c:146
#define PROCESS_TRACE
Trace each state function as it's entered.
Definition process.h:55
#define PROCESS_CONF_OFFSET(_x)
Definition process.h:79
module_t common
Common fields for all loadable modules.
Common public symbol definition for all process modules.
int fr_radius_verify(uint8_t *packet, uint8_t const *vector, uint8_t const *secret, size_t secret_len, bool require_message_authenticator, bool limit_proxy_state)
Verify a request / response packet.
Definition base.c:800
char const * fr_radius_packet_name[FR_RADIUS_CODE_MAX]
Definition base.c:116
#define fr_assert(_expr)
Definition rad_assert.h:38
static char * secret
#define REDEBUG(fmt,...)
#define RDEBUG_ENABLED2()
#define RDEBUG2(fmt,...)
#define RDEBUG(fmt,...)
#define RDEBUG_ENABLED()
static void send_reply(int sockfd, fr_channel_data_t *reply)
@ FR_RADIUS_FAIL_VERIFY
Definition radius.h:113
@ FR_RADIUS_FAIL_MA_INVALID
Definition radius.h:110
#define FR_RADIUS_PACKET_CODE_VALID(_x)
Definition radius.h:52
void fr_rand_buffer(void *start, size_t length)
Definition rand.c:125
fr_table_num_sorted_t const rcode_table[]
Definition rcode.c:35
#define RETURN_UNLANG_FAIL
Definition rcode.h:63
rlm_rcode_t
Return codes indicating the result of the module call.
Definition rcode.h:44
@ RLM_MODULE_INVALID
The module considers the request invalid.
Definition rcode.h:51
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:49
@ RLM_MODULE_FAIL
Module failed, don't reply.
Definition rcode.h:48
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
Definition rcode.h:52
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:47
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
Definition rcode.h:56
@ RLM_MODULE_NOTFOUND
User not found.
Definition rcode.h:53
@ RLM_MODULE_UPDATED
OK (pairs modified).
Definition rcode.h:55
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
Definition rcode.h:54
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
Definition rcode.h:57
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
Definition rcode.h:50
#define request_is_dynamic_client(_x)
Definition request.h:188
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition section.h:40
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:349
void * data
Module's instance data.
Definition module.h:291
#define MODULE_RCTX(_ctype)
Definition module.h:257
#define MODULE_INST(_ctype)
Definition module.h:255
conf_parser_t const * config
How to convert a CONF_SECTION to a module instance.
Definition module.h:206
#define pair_update_reply(_attr, _da)
Return or allocate a fr_pair_t in the reply list.
Definition pair.h:129
int fr_state_restore(fr_state_tree_t *state, request_t *request)
Copy a pointer to the head of the list of state fr_pair_ts (and their ctx) into the request.
Definition state.c:741
void fr_state_discard(fr_state_tree_t *state, request_t *request)
Called when sending an Access-Accept/Access-Reject to discard state information.
Definition state.c:687
int fr_state_store(fr_state_tree_t *state, request_t *request)
Transfer ownership of the state fr_pair_ts and ctx, back to a state entry.
Definition state.c:817
const conf_parser_t state_session_config[]
Definition state.c:59
fr_state_tree_t * fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da, fr_state_config_t const *config)
Initialise a new state tree.
Definition state.c:232
unlang_action_t unlang_module_yield_to_section(unlang_result_t *p_result, request_t *request, CONF_SECTION *subcs, rlm_rcode_t default_rcode, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx)
Definition module.c:236
eap_aka_sim_process_conf_t * inst
#define RESUME(_x)
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
Definition pair.h:69
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
Definition table.h:772
#define talloc_get_type_abort_const
Definition talloc.h:245
#define XLAT_ARGS(_list,...)
Populate local variables with value boxes from the input list.
Definition xlat.h:383
unsigned int required
Argument must be present, and non-empty.
Definition xlat.h:146
#define XLAT_ARG_PARSER_TERMINATOR
Definition xlat.h:170
xlat_action_t
Definition xlat.h:37
@ XLAT_ACTION_FAIL
An xlat function failed.
Definition xlat.h:44
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
Definition xlat.h:43
Definition for a single argument consumend by an xlat function.
Definition xlat.h:145
unsigned int code
Packet code (type).
Definition packet.h:61
fr_socket_t socket
This packet was received on.
Definition packet.h:57
int id
Packet ID (used to link requests/responses).
Definition packet.h:60
int af
AF_INET, AF_INET6, or AF_UNIX.
Definition socket.h:78
#define DOC_ROOT_URL
Definition version.h:87
int8_t fr_value_box_cmp(fr_value_box_t const *a, fr_value_box_t const *b)
Compare two values.
Definition value.c:749
int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src)
Copy value data verbatim duplicating any buffers.
Definition value.c:4409
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
Definition value.h:644
#define fr_box_ipaddr(_val)
Definition value.h:317
static fr_value_box_t * fr_value_box_acopy(TALLOC_CTX *ctx, fr_value_box_t const *src)
Copy an existing box, allocating a new box to hold its contents.
Definition value.h:738
#define fr_value_box_list_foreach(_list_head, _iter)
Definition value.h:224
static size_t char ** out
Definition value.h:1024
int virtual_server_section_attribute_define(CONF_SECTION *server_cs, char const *subcs_name, fr_dict_attr_t const *da)
Define a values for Auth-Type attributes by the sections present in a virtual-server.
section_name_t const * section
Identifier for the section.
#define COMPILE_TERMINATOR
Processing sections which are allowed in this virtual server.
An xlat calling ctx.
Definition xlat_ctx.h:49
int xlat_func_args_set(xlat_t *x, xlat_arg_parser_t const args[])
Register the arguments of an xlat.
Definition xlat_func.c:363
xlat_t * xlat_func_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func, fr_type_t return_type)
Register an xlat function.
Definition xlat_func.c:216
void xlat_func_unregister(char const *name)
Unregister an xlat function.
Definition xlat_func.c:516