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: b7c8e712189b21ef2926dd674f6e81b77c8d7133 $
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
35#include <freeradius-devel/unlang/module.h>
36#include <freeradius-devel/unlang/xlat_func.h>
37
38#include <freeradius-devel/util/debug.h>
39
41static fr_dict_t const *dict_radius;
42
45 { .out = &dict_freeradius, .proto = "freeradius" },
46 { .out = &dict_radius, .proto = "radius" },
48};
49
54
63
66 { .out = &attr_auth_type, .name = "Auth-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
67 { .out = &attr_module_failure_message, .name = "Module-Failure-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
68 { .out = &attr_module_success_message, .name = "Module-Success-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
69 { .out = &attr_stripped_user_name, .name = "Stripped-User-Name", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
70
71 { .out = &attr_acct_status_type, .name = "Acct-Status-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
72 { .out = &attr_proxy_state, .name = "Proxy-State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
73 { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
74 { .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
75 { .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
76 { .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
77
78 { .out = &attr_original_packet_code, .name = "Extended-Attribute-1.Original-Packet-Code", .type = FR_TYPE_UINT32, .dict = &dict_radius },
79 { .out = &attr_error_cause, .name = "Error-Cause", .type = FR_TYPE_UINT32, .dict = &dict_radius },
80
82};
83
86
89 { .out = &enum_auth_type_accept, .name = "Accept", .attr = &attr_auth_type },
90 { .out = &enum_auth_type_reject, .name = "Reject", .attr = &attr_auth_type },
92};
93
94/*
95 * RADIUS state machine configuration
96 */
125
126typedef struct {
127 fr_state_config_t session; //!< track state session information.
128 fr_state_tree_t *state_tree; //!< State tree to link multiple requests/responses.
130
131typedef struct {
132 CONF_SECTION *server_cs; //!< Our virtual server.
133 process_radius_sections_t sections; //!< Pointers to various config sections
134 ///< we need to execute.
135 process_radius_auth_t auth; //!< Authentication configuration.
137
138/** Records fields from the original request so we have a known good copy
139 */
140typedef struct {
141 fr_value_box_list_head_t proxy_state; //!< These need to be copied into the response in exactly
142 ///< the same order as they were added.
145
146#define FR_RADIUS_PROCESS_CODE_VALID(_x) (FR_RADIUS_PACKET_CODE_VALID(_x) || (_x == FR_RADIUS_CODE_DO_NOT_RESPOND))
147
148#define PROCESS_PACKET_TYPE fr_radius_packet_code_t
149#define PROCESS_CODE_MAX FR_RADIUS_CODE_MAX
150#define PROCESS_CODE_DO_NOT_RESPOND FR_RADIUS_CODE_DO_NOT_RESPOND
151#define PROCESS_PACKET_CODE_VALID FR_RADIUS_PROCESS_CODE_VALID
152#define PROCESS_INST process_radius_t
153#define PROCESS_RCTX process_radius_rctx_t
154#define PROCESS_CODE_DYNAMIC_CLIENT FR_RADIUS_CODE_ACCESS_ACCEPT
155#include <freeradius-devel/server/process.h>
156
157static const conf_parser_t auth_config[] = {
158 { FR_CONF_POINTER("session", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) state_session_config },
159
161};
162
163static const conf_parser_t config[] = {
164 { FR_CONF_POINTER("Access-Request", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) auth_config,
165 .offset = offsetof(process_radius_t, auth), },
166
168};
169
170/*
171 * Debug the packet if requested.
172 */
173static void radius_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received)
174{
175#ifdef WITH_IFINDEX_NAME_RESOLUTION
176 char if_name[IFNAMSIZ];
177#endif
178
179 if (!packet) return;
180 if (!RDEBUG_ENABLED) return;
181
182 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 "
183#ifdef WITH_IFINDEX_NAME_RESOLUTION
184 "%s%s%s"
185#endif
186 "",
187 received ? "Received" : "Sending",
189 packet->id,
190 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
191 fr_box_ipaddr(packet->socket.inet.src_ipaddr),
192 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "",
193 packet->socket.inet.src_port,
194 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "",
195 fr_box_ipaddr(packet->socket.inet.dst_ipaddr),
196 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
197 packet->socket.inet.dst_port
198#ifdef WITH_IFINDEX_NAME_RESOLUTION
199 , packet->socket.inet.ifindex ? "via " : "",
200 packet->socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "",
201 packet->socket.inet.ifindex ? " " : ""
202#endif
203 );
204
205 if (received || request->parent) {
206 log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL);
207 } else {
208 log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL);
209 }
210}
211
212/** Keep a copy of some attributes to keep them from being tampered with
213 *
214 */
215static inline CC_HINT(always_inline)
217{
218 fr_pair_t *proxy_state;
219
220 /*
221 * Don't bother allocing the struct if there's no proxy state to store
222 */
223 proxy_state = fr_pair_find_by_da(&request->request_pairs, NULL, attr_proxy_state);
224 if (!proxy_state) return;
225
226 fr_value_box_list_init(&rctx->proxy_state);
227
228 /*
229 * We don't use fr_pair_list_copy_by_da, to avoid doing the lookup for
230 * the first proxy-state attr again.
231 */
232 do {
233 fr_value_box_t *proxy_state_value;
234
235 MEM((proxy_state_value = fr_value_box_acopy(rctx, &proxy_state->data)));
236 fr_value_box_list_insert_tail(&rctx->proxy_state, proxy_state_value);
237 } while ((proxy_state = fr_pair_find_by_da(&request->request_pairs, proxy_state, attr_proxy_state)));
238}
239
240static inline CC_HINT(always_inline)
242{
243 /*
244 * Proxy-State is a link-level signal between RADIUS
245 * client and server. RFC 2865 Section 5.33 says that
246 * Proxy-State is an opaque field, and implementations
247 * most not examine it, interpret it, or assign it any
248 * meaning. Implementations must also copy all Proxy-State
249 * from the request to the reply.
250 *
251 * The rlm_radius module already deletes any Proxy-State
252 * from the reply before appending the proxy reply to the
253 * current reply.
254 *
255 * If any policy creates Proxy-State, that could affect
256 * individual RADIUS links (perhaps), and that would be
257 * wrong. As such, we nuke any nonsensical Proxy-State
258 * added by policies or errant modules, and instead just
259 * do exactly what the RFCs require us to do. No more.
260 */
261 fr_pair_delete_by_da(&request->reply_pairs, attr_proxy_state);
262
263 RDEBUG3("Adding Proxy-State attributes from request");
264 RINDENT();
265 fr_value_box_list_foreach(&rctx->proxy_state, proxy_state_value) {
266 fr_pair_t *vp;
267
268 MEM(vp = fr_pair_afrom_da(request->reply_ctx, attr_proxy_state));
269 if (unlikely(fr_value_box_copy(vp, &vp->data, proxy_state_value) < 0)) {
270 RDEBUG2("Failed to copy Proxy-State value %pV", proxy_state_value);
272 break;
273 }
274 fr_pair_append(&request->reply_pairs, vp);
275 RDEBUG3("reply.%pP", vp);
276 }
277 REXDENT();
278}
279
280/** A wrapper around recv generic which stores fields from the request
281 */
282RECV(generic_radius_request)
283{
284 radius_request_pairs_store(request, mctx->rctx);
285
286 return CALL_RECV(generic);
287}
288
289/** A wrapper around send generic which restores fields
290 *
291 */
292RESUME(generic_radius_response)
293{
294 radius_request_pairs_to_reply(request, talloc_get_type_abort(mctx->rctx, process_radius_rctx_t));
295
296 return CALL_RESUME(send_generic);
297}
298
299RECV(access_request)
300{
302
303 if (fr_state_restore(inst->auth.state_tree, request) < 0) {
304 return CALL_SEND_TYPE(FR_RADIUS_CODE_ACCESS_REJECT);
305 }
306
307 return CALL_RECV(generic_radius_request);
308}
309
310RESUME(auth_type);
311
312RESUME(access_request)
313{
314 rlm_rcode_t rcode = RESULT_RCODE;
315 fr_pair_t *vp;
316 CONF_SECTION *cs;
317 fr_dict_enum_value_t const *dv;
318 fr_process_state_t const *state;
320
322
324
325 /*
326 * See if the return code from "recv Access-Request" says we reject, or continue.
327 */
328 UPDATE_STATE(packet);
329
330 /*
331 * A policy or a module can hard-code the reply, in which case we can process that immediately,
332 * and bypass the "authenticate" section.
333 */
334 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_packet_type);
335 if (vp && FR_RADIUS_PROCESS_CODE_VALID(vp->vp_uint32)) {
336 request->reply->code = vp->vp_uint32;
337 (void) fr_pair_delete(&request->reply_pairs, vp);
338 } else {
339 /*
340 * Get the default reply packet based on the rcode.
341 */
342 request->reply->code = state->packet_type[rcode];
343 if (!request->reply->code) request->reply->code = state->default_reply;
344 }
345
346 /*
347 * Either the code above or a module set reject, we're done.
348 */
349 if (request->reply->code == FR_RADIUS_CODE_ACCESS_REJECT) {
350 RDEBUG("The 'recv Access-Request' section returned %s - rejecting the request",
351 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
352
354 UPDATE_STATE(reply);
355
356 fr_assert(state->send != NULL);
357 return CALL_SEND_STATE(state);
358 }
359
360 /*
361 * Something set a reply, bypass the "authenticate" section.
362 */
363 if (request->reply->code) {
364 goto send_reply;
365 }
366
367 /*
368 * Run authenticate foo { ... }
369 *
370 * If we can't find Auth-Type, OR if we can't find
371 * Auth-Type = foo, then it's a reject.
372 */
373 vp = fr_pair_find_by_da(&request->control_pairs, NULL, attr_auth_type);
374 if (!vp) {
375 RDEBUG("No 'Auth-Type' attribute found, cannot authenticate the user - rejecting the request");
376
377 reject:
378 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
379 goto send_reply;
380 }
381
382 dv = fr_dict_enum_by_value(vp->da, &vp->data);
383 if (!dv) {
384 RDEBUG("Invalid value for 'Auth-Type' attribute, cannot authenticate the user - rejecting the request");
385 goto reject;
386 }
387
388 /*
389 * The magic Auth-Type Accept value which means skip the authenticate section.
390 *
391 * And Reject means always reject. Tho the admin should instead just return "reject" from the
392 * section.
393 */
395 request->reply->code = FR_RADIUS_CODE_ACCESS_ACCEPT;
396 goto send_reply;
397
398 } else if (fr_value_box_cmp(enum_auth_type_reject, dv->value) == 0) {
399 goto reject;
400 }
401
402 cs = cf_section_find(inst->server_cs, "authenticate", dv->name);
403 if (!cs) {
404 RDEBUG2("No 'authenticate %s { ... }' section found - rejecting the request", dv->name);
405 goto reject;
406 }
407
408 /*
409 * Run the "Authenticate = foo" section.
410 *
411 * And continue with sending the generic reply.
412 */
413 RDEBUG("Running 'authenticate %s' from file %s", cf_section_name2(cs), cf_filename(cs));
414 return unlang_module_yield_to_section(RESULT_P, request,
415 cs, RLM_MODULE_NOOP, resume_auth_type,
416 NULL, 0, mctx->rctx);
417}
418
419RESUME(auth_type)
420{
421 static const fr_process_rcode_t auth_type_rcode = {
425 [RLM_MODULE_HANDLED] = 0,
432 };
433
434 rlm_rcode_t rcode = RESULT_RCODE;
435 fr_pair_t *vp;
436 fr_process_state_t const *state;
437
439
441
442 /*
443 * Allow user to specify response packet type here, too.
444 */
445 if (!auth_type_rcode[rcode]) {
446 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_packet_type);
447 if (vp && FR_RADIUS_PROCESS_CODE_VALID(vp->vp_uint32)) {
448 request->reply->code = vp->vp_uint32;
449 (void) fr_pair_delete(&request->reply_pairs, vp);
450 }
451 } else {
452 request->reply->code = auth_type_rcode[rcode];
453 }
454
455 switch (request->reply->code) {
456 case 0:
457 RDEBUG("No reply code was set. Forcing to Access-Reject");
458 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
460
461 /*
462 * Print complaints before running "send Access-Reject"
463 */
465 RDEBUG2("Failed to authenticate the user");
466
467 /*
468 * Maybe the shared secret is wrong?
469 */
470 vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_user_password);
471 if (vp) {
472 if (RDEBUG_ENABLED2) {
473 uint8_t const *p;
474
475 p = (uint8_t const *) vp->vp_strvalue;
476 while (*p) {
477 int size;
478
479 size = fr_utf8_char(p, -1);
480 if (!size) {
481 RWDEBUG("Unprintable characters in the password. "
482 "Double-check the shared secret on the server "
483 "and the NAS!");
484 RWDEBUG("For more information, please see " DOC_ROOT_URL "/troubleshooting/network/shared_secret.html");
485 break;
486 }
487 p += size;
488 }
489 }
490 }
491 break;
492
493 /*
494 * Access-Challenge sections require a State. If there is
495 * none, create one here. This is so that the State
496 * attribute is accessible in the "send Access-Challenge"
497 * section.
498 */
500 if ((vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_state)) == NULL) {
501 uint8_t buffer[16];
502
503 fr_rand_buffer(buffer, sizeof(buffer));
504
506 fr_pair_value_memdup(vp, buffer, sizeof(buffer), false);
507 }
508 break;
509
510 default:
511 break;
512 }
513 UPDATE_STATE(reply);
514
515 fr_assert(state->send != NULL);
516 return state->send(p_result, mctx, request);
517}
518
519RESUME_FLAG(access_accept,UNUSED,)
520{
521 fr_pair_t *vp;
523
525
526 /*
527 * Check that there is a name which can be used to
528 * identify the user. The configuration depends on
529 * User-Name or Stripped-User-Name existing, and being
530 * (mostly) unique to that user.
531 */
532 if (!request->parent &&
533 ((vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_user_name)) != NULL) &&
534 (vp->vp_strvalue[0] == '@') &&
535 !fr_pair_find_by_da(&request->request_pairs, NULL, attr_stripped_user_name)) {
536 RWDEBUG("User-Name is anonymized, and no Stripped-User-Name exists.");
537 RWDEBUG("It may be difficult or impossible to identify the user.");
538 RWDEBUG("Please update Stripped-User-Name with information which identifies the user.");
539 }
540
541 fr_state_discard(inst->auth.state_tree, request);
542 radius_request_pairs_to_reply(request, mctx->rctx);
544}
545
546RESUME_FLAG(access_reject,UNUSED,)
547{
549
551
552 fr_state_discard(inst->auth.state_tree, request);
553 radius_request_pairs_to_reply(request, mctx->rctx);
555}
556
557RESUME(access_challenge)
558{
560
562
563 /*
564 * Cache the state context, unless this is a subrequest.
565 * Subrequest state context will be handled by the caller.
566 *
567 * If this fails, don't respond to the request.
568 */
569 if (!request->parent && fr_state_store(inst->auth.state_tree, request) < 0) {
570 return CALL_SEND_TYPE(FR_RADIUS_CODE_DO_NOT_RESPOND);
571 }
572
573 fr_assert(request->reply->code == FR_RADIUS_CODE_ACCESS_CHALLENGE);
574 radius_request_pairs_to_reply(request, mctx->rctx);
576}
577
578/** A wrapper around recv generic which stores fields from the request
579 */
580RECV(accounting_request)
581{
582 radius_request_pairs_store(request, mctx->rctx);
583
584 return CALL_RECV(generic);
585}
586
587RESUME(acct_type)
588{
589 static const fr_process_rcode_t acct_type_rcode = {
596 };
597
598 rlm_rcode_t rcode = RESULT_RCODE;
599 fr_process_state_t const *state;
600
602
604 fr_assert(FR_RADIUS_PROCESS_CODE_VALID(request->reply->code));
605
606 if (acct_type_rcode[rcode]) {
607 fr_assert(acct_type_rcode[rcode] == FR_RADIUS_CODE_DO_NOT_RESPOND);
608
609 request->reply->code = acct_type_rcode[rcode];
610 UPDATE_STATE(reply);
611
612 RDEBUG("The 'accounting' section returned %s - not sending a response",
613 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
614
615 fr_assert(state->send != NULL);
616 return state->send(p_result, mctx, request);
617 }
618
619 request->reply->code = FR_RADIUS_CODE_ACCOUNTING_RESPONSE;
620 UPDATE_STATE(reply);
621
622 fr_assert(state->send != NULL);
623 return state->send(p_result, mctx, request);
624}
625
626RESUME(accounting_request)
627{
628 rlm_rcode_t rcode = RESULT_RCODE;
629 fr_pair_t *vp;
630 CONF_SECTION *cs;
631 fr_dict_enum_value_t const *dv;
632 fr_process_state_t const *state;
634
636
638
639 UPDATE_STATE(packet);
640 fr_assert(state->packet_type[rcode] != 0);
641
642 request->reply->code = state->packet_type[rcode];
643 UPDATE_STATE_CS(reply);
644
645 if (request->reply->code == FR_RADIUS_CODE_DO_NOT_RESPOND) {
646 RDEBUG("The 'recv Accounting-Request' section returned %s - not sending a response",
647 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
648
650 fr_assert(state->send != NULL);
651 return CALL_SEND_STATE(state);
652 }
653
654 /*
655 * Run accounting foo { ... }
656 */
657 vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_acct_status_type);
658 if (!vp) goto send_reply;
659
660 dv = fr_dict_enum_by_value(vp->da, &vp->data);
661 if (!dv) goto send_reply;
662
663 cs = cf_section_find(inst->server_cs, "accounting", dv->name);
664 if (!cs) {
665 RDEBUG2("No 'accounting %s { ... }' section found - skipping...", dv->name);
666 goto send_reply;
667 }
668
669 /*
670 * Run the "Acct-Status-Type = foo" section.
671 *
672 * And continue with sending the generic reply.
673 */
674 return unlang_module_yield_to_section(RESULT_P, request,
675 cs, RLM_MODULE_NOOP, resume_acct_type,
676 NULL, 0, mctx->rctx);
677}
678
679#if 0
680// @todo - send canned responses like in v3?
681RECV(status_server)
682{
684}
685
686RESUME(status_server)
687{
689}
690#endif
691
692RESUME_FLAG(protocol_error,UNUSED,)
693{
694 fr_pair_t *vp;
696
698
699 fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->reply->code));
700
701 /*
702 * https://tools.ietf.org/html/rfc7930#section-4
703 */
704 vp = fr_pair_find_by_da_nested(&request->reply_pairs, NULL, attr_original_packet_code);
705 if (!vp) {
706 vp = fr_pair_afrom_da(request->reply_ctx, attr_original_packet_code);
707 if (vp) {
708 vp->vp_uint32 = request->packet->code;
709 fr_pair_append(&request->reply_pairs, vp);
710 }
711 }
712
713 /*
714 * If there's no Error-Cause, then include a generic 404.
715 */
716 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_error_cause);
717 if (!vp) {
718 vp = fr_pair_afrom_da(request->reply_ctx, attr_error_cause);
719 if (vp) {
720 vp->vp_uint32 = FR_ERROR_CAUSE_VALUE_INVALID_REQUEST;
721 fr_pair_append(&request->reply_pairs, vp);
722 }
723 }
724
725 /*
726 * Discard any session state associated with the request.
727 */
728 if (request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) {
729 fr_state_discard(inst->auth.state_tree, request);
730 }
731
732 /*
733 * Add Proxy-State back.
734 */
735 radius_request_pairs_to_reply(request, talloc_get_type_abort(mctx->rctx, process_radius_rctx_t));
736
737 /*
738 * And do the generic processing after running a "send" section.
739 */
740 return CALL_RESUME(send_generic);
741}
742
743static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
744{
745 fr_process_state_t const *state;
746
748
750
751 request->component = "radius";
752 request->module = NULL;
753 fr_assert(request->proto_dict == dict_radius);
754
755 fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->packet->code));
756
757 UPDATE_STATE(packet);
758
759 if (!state->recv) {
760 REDEBUG("Invalid packet type (%u)", request->packet->code);
762 }
763
764 radius_packet_debug(request, request->packet, &request->request_pairs, true);
765
766 if (unlikely(request_is_dynamic_client(request))) {
767 return new_client(p_result, mctx, request);
768 }
769
770 return state->recv(p_result, mctx, request);
771}
772
774 { .required = true, .single = true, .type = FR_TYPE_OCTETS },
776};
777
778/** Validates a request against a know shared secret
779 *
780 * Designed for the specific purpose of verifying dynamic clients
781 * against a know shared secret.
782 *
783 * Example:
784@verbatim
785%radius.secret.verify(<secret>)
786@endverbatim
787 *
788 * @ingroup xlat_functions
789 */
791 request_t *request, fr_value_box_list_t *args)
792{
794 int ret;
795 bool require_message_authenticator = false;
796
798
799 if (request->proto_dict != dict_radius) return XLAT_ACTION_FAIL;
800
801 MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_BOOL, NULL));
802
803 /*
804 * Only Access-Requests require a Message-Authenticator.
805 * All the other packet types are signed using the
806 * authenticator field.
807 */
808 if (request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) require_message_authenticator = true;
809
810 ret = fr_radius_verify(request->packet->data, NULL, secret->vb_octets, secret->vb_length, require_message_authenticator, false);
811 switch (ret) {
812 case 0:
813 vb->vb_bool = true;
814 break;
815
816 default:
817 RPEDEBUG("Invalid packet");
818 return XLAT_ACTION_FAIL;
819
822 RPEDEBUG("Failed to verify the packet signature");
823 vb->vb_bool = false;
824 break;
825 }
827
828 return XLAT_ACTION_DONE;
829}
830
831static int mod_instantiate(module_inst_ctx_t const *mctx)
832{
833 process_radius_t *inst = talloc_get_type_abort(mctx->mi->data, process_radius_t);
834
835 inst->server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
836
837 FR_INTEGER_BOUND_CHECK("session.max_rounds", inst->auth.session.max_rounds, >=, 32);
838 FR_INTEGER_BOUND_CHECK("session.max_rounds", inst->auth.session.max_rounds, <=, 100);
839
840 inst->auth.session.thread_safe = main_config->spawn_workers;
841 inst->auth.session.context_id = fr_hash_string(cf_section_name2(inst->server_cs));
842
843 MEM(inst->auth.state_tree = fr_state_tree_init(inst, attr_state, &inst->auth.session));
844
845 return 0;
846}
847
848static int mod_bootstrap(module_inst_ctx_t const *mctx)
849{
850 CONF_SECTION *server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
851
852 if (virtual_server_section_attribute_define(server_cs, "authenticate", attr_auth_type) < 0) return -1;
853
854 return 0;
855}
856
857static int mod_load(void)
858{
859 xlat_t *xlat;
860
861 if (unlikely(!(xlat = xlat_func_register(NULL, "radius.secret.verify", xlat_func_radius_secret_verify,
862 FR_TYPE_BOOL)))) return -1;
863
865
866 return 0;
867}
868
869static void mod_unload(void)
870{
871 xlat_func_unregister("radius.secret.verify");
872}
873
874/*
875 * rcodes not listed under a packet_type
876 * mean that the packet code will not be
877 * changed.
878 */
879static fr_process_state_t const process_state[] = {
881 .packet_type = {
888 },
889 .default_rcode = RLM_MODULE_NOOP,
890 .recv = recv_access_request,
891 .resume = resume_access_request,
892 .section_offset = offsetof(process_radius_sections_t, access_request),
893 },
895 .packet_type = {
901 },
902 .default_rcode = RLM_MODULE_NOOP,
903 .result_rcode = RLM_MODULE_OK,
904 .send = send_generic,
905 .resume = resume_access_accept,
906 .section_offset = offsetof(process_radius_sections_t, access_accept),
907 },
909 .packet_type = {
915 },
916 .default_rcode = RLM_MODULE_NOOP,
917 .result_rcode = RLM_MODULE_REJECT,
918 .send = send_generic,
919 .resume = resume_access_reject,
920 .section_offset = offsetof(process_radius_sections_t, access_reject),
921 },
923 .packet_type = {
929 },
930 .default_rcode = RLM_MODULE_NOOP,
931 .result_rcode = RLM_MODULE_OK,
932 .send = send_generic,
933 .resume = resume_access_challenge,
934 .section_offset = offsetof(process_radius_sections_t, access_challenge),
935 },
936
938 .packet_type = {
943
950 },
951 .default_rcode = RLM_MODULE_NOOP,
952 .recv = recv_accounting_request,
953 .resume = resume_accounting_request,
954 .section_offset = offsetof(process_radius_sections_t, accounting_request),
955 },
957 .packet_type = {
964 },
965 .default_rcode = RLM_MODULE_NOOP,
966 .result_rcode = RLM_MODULE_OK,
967 .send = send_generic,
968 .resume = resume_generic_radius_response,
969 .section_offset = offsetof(process_radius_sections_t, accounting_response),
970 },
971 [ FR_RADIUS_CODE_STATUS_SERVER ] = { /* @todo - negotiation, stats, etc. */
972 .packet_type = {
975
983 },
984 .default_rcode = RLM_MODULE_NOOP,
985 .recv = recv_generic,
986 .resume = resume_recv_generic,
987 .section_offset = offsetof(process_radius_sections_t, status_server),
988 },
990 .packet_type = {
995
1001 },
1002 .default_rcode = RLM_MODULE_NOOP,
1003 .recv = recv_generic_radius_request,
1004 .resume = resume_recv_generic,
1005 .section_offset = offsetof(process_radius_sections_t, coa_request),
1006 },
1008 .packet_type = {
1014 },
1015 .default_rcode = RLM_MODULE_NOOP,
1016 .result_rcode = RLM_MODULE_OK,
1017 .send = send_generic,
1018 .resume = resume_generic_radius_response,
1019 .section_offset = offsetof(process_radius_sections_t, coa_ack),
1020 },
1022 .packet_type = {
1028 },
1029 .default_rcode = RLM_MODULE_NOOP,
1030 .result_rcode = RLM_MODULE_NOTFOUND,
1031 .send = send_generic,
1032 .resume = resume_generic_radius_response,
1033 .section_offset = offsetof(process_radius_sections_t, coa_nak),
1034 },
1036 .packet_type = {
1041
1047 },
1048 .default_rcode = RLM_MODULE_NOOP,
1049 .recv = recv_generic_radius_request,
1050 .resume = resume_recv_generic,
1051 .section_offset = offsetof(process_radius_sections_t, disconnect_request),
1052 },
1054 .packet_type = {
1060 },
1061 .default_rcode = RLM_MODULE_NOOP,
1062 .result_rcode = RLM_MODULE_OK,
1063 .send = send_generic,
1064 .resume = resume_generic_radius_response,
1065 .section_offset = offsetof(process_radius_sections_t, disconnect_ack),
1066 },
1068 .packet_type = {
1074 },
1075 .default_rcode = RLM_MODULE_NOOP,
1076 .result_rcode = RLM_MODULE_NOTFOUND,
1077 .send = send_generic,
1078 .resume = resume_generic_radius_response,
1079 .section_offset = offsetof(process_radius_sections_t, disconnect_nak),
1080 },
1081 [ FR_RADIUS_CODE_PROTOCOL_ERROR ] = { /* @todo - fill out required fields */
1082 .packet_type = {
1088 },
1089 .default_rcode = RLM_MODULE_NOOP,
1090 .result_rcode = RLM_MODULE_OK,
1091 .send = send_generic,
1092 .resume = resume_protocol_error,
1093 .section_offset = offsetof(process_radius_sections_t, protocol_error),
1094 },
1096 .packet_type = {
1101
1108 },
1109 .default_rcode = RLM_MODULE_NOOP,
1110 .result_rcode = RLM_MODULE_HANDLED,
1111 .send = send_generic,
1112 .resume = resume_send_generic,
1113 .section_offset = offsetof(process_radius_sections_t, do_not_respond),
1114 }
1115};
1116
1118 {
1119 .section = SECTION_NAME("recv", "Access-Request"),
1120 .actions = &mod_actions_authorize,
1121 .offset = PROCESS_CONF_OFFSET(access_request),
1122 },
1123 {
1124 .section = SECTION_NAME("send", "Access-Accept"),
1126 .offset = PROCESS_CONF_OFFSET(access_accept),
1127 },
1128 {
1129 .section = SECTION_NAME("send", "Access-Challenge"),
1131 .offset = PROCESS_CONF_OFFSET(access_challenge),
1132 },
1133 {
1134 .section = SECTION_NAME("send", "Access-Reject"),
1136 .offset = PROCESS_CONF_OFFSET(access_reject),
1137 },
1138
1139 {
1140 .section = SECTION_NAME("recv", "Accounting-Request"),
1142 .offset = PROCESS_CONF_OFFSET(accounting_request),
1143 },
1144 {
1145 .section = SECTION_NAME("send", "Accounting-Response"),
1147 .offset = PROCESS_CONF_OFFSET(accounting_response),
1148 },
1149
1150 {
1151 .section = SECTION_NAME("recv", "Status-Server"),
1153 .offset = PROCESS_CONF_OFFSET(status_server),
1154 },
1155 {
1156 .section = SECTION_NAME("recv", "CoA-Request"),
1158 .offset = PROCESS_CONF_OFFSET(coa_request),
1159 },
1160 {
1161 .section = SECTION_NAME("send", "CoA-ACK"),
1163 .offset = PROCESS_CONF_OFFSET(coa_ack),
1164 },
1165 {
1166 .section = SECTION_NAME("send", "CoA-NAK"),
1168 .offset = PROCESS_CONF_OFFSET(coa_nak),
1169 },
1170 {
1171 .section = SECTION_NAME("recv", "Disconnect-Request"),
1173 .offset = PROCESS_CONF_OFFSET(disconnect_request),
1174 },
1175 {
1176 .section = SECTION_NAME("send", "Disconnect-ACK"),
1178 .offset = PROCESS_CONF_OFFSET(disconnect_ack),
1179 },
1180 {
1181 .section = SECTION_NAME("send", "Disconnect-NAK"),
1183 .offset = PROCESS_CONF_OFFSET(disconnect_nak),
1184 },
1185 {
1186 .section = SECTION_NAME("send", "Protocol-Error"),
1188 .offset = PROCESS_CONF_OFFSET(protocol_error),
1189 },
1190 {
1191 .section = SECTION_NAME("send", "Do-Not-Respond"),
1193 .offset = PROCESS_CONF_OFFSET(do_not_respond),
1194 },
1195 {
1196 .section = SECTION_NAME("authenticate", CF_IDENT_ANY),
1198 },
1199 {
1200 .section = SECTION_NAME("accounting", CF_IDENT_ANY),
1202 },
1203
1204 DYNAMIC_CLIENT_SECTIONS,
1205
1207};
1208
1211 .common = {
1212 .magic = MODULE_MAGIC_INIT,
1213 .name = "radius",
1214 .config = config,
1217
1218 .onload = mod_load,
1219 .unload = mod_unload,
1220 .bootstrap = mod_bootstrap,
1221 .instantiate = mod_instantiate
1222 },
1223 .process = mod_process,
1224 .compile_list = compile_list,
1225 .dict = &dict_radius,
1226 .packet_type = &attr_packet_type
1227};
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:576
va_list args
Definition acutest.h:770
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
Definition build.h:325
#define unlikely(_x)
Definition build.h:384
#define UNUSED
Definition build.h:318
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:657
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:517
#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:334
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition cf_parse.h:423
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:594
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:98
#define cf_filename(_cf)
Definition cf_util.h:104
#define CF_IDENT_ANY
Definition cf_util.h:75
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
Definition dcursor.h:406
#define MEM(x)
Definition debug.h:46
@ 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:281
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:292
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:305
fr_value_box_t const * value
Enum value (what name maps to).
Definition dict.h:257
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:3655
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:311
char const * name
Enum name.
Definition dict.h:254
Specifies an attribute which must be present for the module to function.
Definition dict.h:291
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:304
Specifies a value which must be present for the module to function.
Definition dict.h:280
Value of an enumerated attribute.
Definition dict.h:253
#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:790
uint32_t fr_hash_string(char const *p)
Definition hash.c:900
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:91
fr_dict_attr_t const * attr_state
Definition base.c:101
fr_dict_t const * dict_radius
Definition base.c:76
fr_dict_attr_t const * attr_user_name
Definition base.c:102
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:855
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:831
#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:67
@ L_DBG
Only displayed when debugging is enabled.
Definition log.h:56
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:61
unlang_mod_actions_t const mod_actions_authenticate
Definition mod_action.c:29
unlang_mod_actions_t const mod_actions_accounting
Definition mod_action.c:77
unlang_mod_actions_t const mod_actions_authorize
Definition mod_action.c:45
unlang_mod_actions_t const mod_actions_postauth
Definition mod_action.c:92
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:2966
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:784
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:707
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:1352
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:1696
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:1833
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:135
CONF_SECTION * access_challenge
Definition base.c:103
static fr_dict_attr_t const * attr_user_password
Definition base.c:60
CONF_SECTION * coa_nak
Definition base.c:112
static xlat_arg_parser_t const xlat_func_radius_secret_verify_args[]
Definition base.c:773
CONF_SECTION * disconnect_ack
Definition base.c:115
CONF_SECTION * protocol_error
Definition base.c:119
CONF_SECTION * new_client
Definition base.c:121
static fr_dict_attr_t const * attr_stripped_user_name
Definition base.c:53
fr_dict_attr_autoload_t process_radius_dict_attr[]
Definition base.c:65
CONF_SECTION * coa_request
Definition base.c:110
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:141
fr_dict_enum_autoload_t process_radius_dict_enum[]
Definition base.c:88
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition base.c:848
fr_process_module_t process_radius
Definition base.c:1210
static fr_dict_attr_t const * attr_auth_type
Definition base.c:50
static void radius_request_pairs_to_reply(request_t *request, process_radius_rctx_t *rctx)
Definition base.c:241
#define FR_RADIUS_PROCESS_CODE_VALID(_x)
Definition base.c:146
CONF_SECTION * disconnect_nak
Definition base.c:116
CONF_SECTION * access_accept
Definition base.c:101
static fr_value_box_t const * enum_auth_type_reject
Definition base.c:85
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:216
static fr_dict_attr_t const * attr_error_cause
Definition base.c:62
CONF_SECTION * add_client
Definition base.c:122
static const conf_parser_t auth_config[]
Definition base.c:157
CONF_SECTION * server_cs
Our virtual server.
Definition base.c:132
CONF_SECTION * access_request
Definition base.c:100
static fr_dict_attr_t const * attr_proxy_state
Definition base.c:57
static void radius_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received)
Definition base.c:173
static fr_value_box_t const * enum_auth_type_accept
Definition base.c:84
CONF_SECTION * status_server
Definition base.c:108
CONF_SECTION * access_reject
Definition base.c:102
static fr_dict_attr_t const * attr_acct_status_type
Definition base.c:55
CONF_SECTION * disconnect_request
Definition base.c:114
CONF_SECTION * accounting_request
Definition base.c:105
CONF_SECTION * coa_ack
Definition base.c:111
CONF_SECTION * do_not_respond
Definition base.c:118
fr_state_config_t session
track state session information.
Definition base.c:127
process_radius_sections_t sections
Pointers to various config sections we need to execute.
Definition base.c:133
static fr_dict_attr_t const * attr_original_packet_code
Definition base.c:61
unlang_result_t result
Definition base.c:143
static const conf_parser_t config[]
Definition base.c:163
fr_dict_autoload_t process_radius_dict[]
Definition base.c:44
fr_state_tree_t * state_tree
State tree to link multiple requests/responses.
Definition base.c:128
CONF_SECTION * accounting_response
Definition base.c:106
CONF_SECTION * deny_client
Definition base.c:123
Records fields from the original request so we have a known good copy.
Definition base.c:140
#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:799
char const * fr_radius_packet_name[FR_RADIUS_CODE_MAX]
Definition base.c:115
#define fr_assert(_expr)
Definition rad_assert.h:37
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:124
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:39
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:351
void * data
Module's instance data.
Definition module.h:293
#define MODULE_RCTX(_ctype)
Definition module.h:259
#define MODULE_INST(_ctype)
Definition module.h:257
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:735
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:681
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:811
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:110
#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:75
#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:748
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:4408
#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:744
#define fr_value_box_list_foreach(_list_head, _iter)
Definition value.h:224
static size_t char ** out
Definition value.h:1030
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