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: 3aadd8ddac80ecc53bf53c4ab83190b3be8f075d $
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
70
73 { .out = &attr_auth_type, .name = "Auth-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
74 { .out = &attr_module_failure_message, .name = "Module-Failure-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
75 { .out = &attr_module_success_message, .name = "Module-Success-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
76 { .out = &attr_stripped_user_name, .name = "Stripped-User-Name", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
77
78 { .out = &attr_acct_status_type, .name = "Acct-Status-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
79 { .out = &attr_proxy_state, .name = "Proxy-State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
80 { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
81 { .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
82 { .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
83 { .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
84
85 { .out = &attr_original_packet_code, .name = "Extended-Attribute-1.Original-Packet-Code", .type = FR_TYPE_UINT32, .dict = &dict_radius },
86 { .out = &attr_error_cause, .name = "Error-Cause", .type = FR_TYPE_UINT32, .dict = &dict_radius },
87
88 { .out = &attr_event_timestamp, .name = "Event-Timestamp", .type = FR_TYPE_DATE, .dict = &dict_radius },
89
91};
92
95
98 { .out = &enum_auth_type_accept, .name = "Accept", .attr = &attr_auth_type },
99 { .out = &enum_auth_type_reject, .name = "Reject", .attr = &attr_auth_type },
101};
102
103/*
104 * RADIUS state machine configuration
105 */
134
135typedef struct {
136 fr_state_config_t session; //!< track state session information.
137 fr_state_tree_t *state_tree; //!< State tree to link multiple requests/responses.
139
140typedef struct {
141 CONF_SECTION *server_cs; //!< Our virtual server.
142 process_radius_sections_t sections; //!< Pointers to various config sections
143 ///< we need to execute.
144 process_radius_auth_t auth; //!< Authentication configuration.
146
147/** Records fields from the original request so we have a known good copy
148 */
149typedef struct {
150 fr_value_box_list_head_t proxy_state; //!< These need to be copied into the response in exactly
151 ///< the same order as they were added.
154
155#define FR_RADIUS_PROCESS_CODE_VALID(_x) (FR_RADIUS_PACKET_CODE_VALID(_x) || (_x == FR_RADIUS_CODE_DO_NOT_RESPOND))
156
157#define PROCESS_PACKET_TYPE fr_radius_packet_code_t
158#define PROCESS_CODE_MAX FR_RADIUS_CODE_MAX
159#define PROCESS_CODE_DO_NOT_RESPOND FR_RADIUS_CODE_DO_NOT_RESPOND
160#define PROCESS_PACKET_CODE_VALID FR_RADIUS_PROCESS_CODE_VALID
161#define PROCESS_INST process_radius_t
162#define PROCESS_RCTX process_radius_rctx_t
163#define PROCESS_CODE_DYNAMIC_CLIENT FR_RADIUS_CODE_ACCESS_ACCEPT
164#include <freeradius-devel/server/process.h>
165
166static const conf_parser_t auth_config[] = {
167 { FR_CONF_POINTER("session", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) state_session_config },
168
170};
171
172static const conf_parser_t config[] = {
173 { FR_CONF_POINTER("Access-Request", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) auth_config,
174 .offset = offsetof(process_radius_t, auth), },
175
177};
178
179/*
180 * Debug the packet if requested.
181 */
182static void radius_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received)
183{
184#ifdef WITH_IFINDEX_NAME_RESOLUTION
185 char if_name[IFNAMSIZ];
186#endif
187
188 if (!packet) return;
189 if (!RDEBUG_ENABLED) return;
190
191 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 "
192#ifdef WITH_IFINDEX_NAME_RESOLUTION
193 "%s%s%s"
194#endif
195 "",
196 received ? "Received" : "Sending",
198 packet->id,
199 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
200 fr_box_ipaddr(packet->socket.inet.src_ipaddr),
201 packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "",
202 packet->socket.inet.src_port,
203 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "",
204 fr_box_ipaddr(packet->socket.inet.dst_ipaddr),
205 packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
206 packet->socket.inet.dst_port
207#ifdef WITH_IFINDEX_NAME_RESOLUTION
208 , packet->socket.inet.ifindex ? "via " : "",
209 packet->socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "",
210 packet->socket.inet.ifindex ? " " : ""
211#endif
212 );
213
214 if (received || request->parent) {
215 log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL);
216 } else {
217 log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL);
218 }
219}
220
221/** Keep a copy of some attributes to keep them from being tamptered with
222 *
223 */
224static inline CC_HINT(always_inline)
226{
227 fr_pair_t *proxy_state;
228
229 /*
230 * Don't bother allocing the struct if there's no proxy state to store
231 */
232 proxy_state = fr_pair_find_by_da(&request->request_pairs, NULL, attr_proxy_state);
233 if (!proxy_state) return;
234
235 fr_value_box_list_init(&rctx->proxy_state);
236
237 /*
238 * We don't use fr_pair_list_copy_by_da, to avoid doing the lookup for
239 * the first proxy-state attr again.
240 */
241 do {
242 fr_value_box_t *proxy_state_value;
243
244 MEM((proxy_state_value = fr_value_box_acopy(rctx, &proxy_state->data)));
245 fr_value_box_list_insert_tail(&rctx->proxy_state, proxy_state_value);
246 } while ((proxy_state = fr_pair_find_by_da(&request->request_pairs, proxy_state, attr_proxy_state)));
247}
248
249static inline CC_HINT(always_inline)
251{
252 /*
253 * Proxy-State is a link-level signal between RADIUS
254 * client and server. RFC 2865 Section 5.33 says that
255 * Proxy-State is an opaque field, and implementations
256 * most not examine it, interpret it, or assign it any
257 * meaning. Implementations must also copy all Proxy-State
258 * from the request to the reply.
259 *
260 * The rlm_radius module already deletes any Proxy-State
261 * from the reply before appending the proxy reply to the
262 * current reply.
263 *
264 * If any policy creates Proxy-State, that could affect
265 * individual RADIUS links (perhaps), and that would be
266 * wrong. As such, we nuke any nonsensical Proxy-State
267 * added by policies or errant modules, and instead just
268 * do exactly what the RFCs require us to do. No more.
269 */
270 fr_pair_delete_by_da(&request->reply_pairs, attr_proxy_state);
271
272 RDEBUG3("Adding Proxy-State attributes from request");
273 RINDENT();
274 fr_value_box_list_foreach(&rctx->proxy_state, proxy_state_value) {
275 fr_pair_t *vp;
276
277 MEM(vp = fr_pair_afrom_da(request->reply_ctx, attr_proxy_state));
278 if (unlikely(fr_value_box_copy(vp, &vp->data, proxy_state_value) < 0)) {
279 RDEBUG2("Failed to copy Proxy-State value %pV", proxy_state_value);
281 break;
282 }
283 fr_pair_append(&request->reply_pairs, vp);
284 RDEBUG3("reply.%pP", vp);
285 }
286 REXDENT();
287}
288
289/** A wrapper around recv generic which stores fields from the request
290 */
291RECV(generic_radius_request)
292{
293 radius_request_pairs_store(request, mctx->rctx);
294
295 return CALL_RECV(generic);
296}
297
298/** A wrapper around send generic which restores fields
299 *
300 */
301RESUME(generic_radius_response)
302{
303 radius_request_pairs_to_reply(request, talloc_get_type_abort(mctx->rctx, process_radius_rctx_t));
304
305 return CALL_RESUME(send_generic);
306}
307
308RECV(access_request)
309{
311
312 if (fr_state_restore(inst->auth.state_tree, request) < 0) {
313 return CALL_SEND_TYPE(FR_RADIUS_CODE_ACCESS_REJECT);
314 }
315
316 return CALL_RECV(generic_radius_request);
317}
318
319RESUME(auth_type);
320
321RESUME(access_request)
322{
323 rlm_rcode_t rcode = RESULT_RCODE;
324 fr_pair_t *vp;
325 CONF_SECTION *cs;
326 fr_dict_enum_value_t const *dv;
327 fr_process_state_t const *state;
329
331
333
334 /*
335 * See if the return code from "recv Access-Request" says we reject, or continue.
336 */
337 UPDATE_STATE(packet);
338
339 request->reply->code = state->packet_type[rcode];
340 if (!request->reply->code) request->reply->code = state->default_reply;
341
342 /*
343 * Something set reject, we're done.
344 */
345 if (request->reply->code == FR_RADIUS_CODE_ACCESS_REJECT) {
346 RDEBUG("The 'recv Access-Request' section returned %s - rejecting the request",
347 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
348
350 UPDATE_STATE(reply);
351
352 fr_assert(state->send != NULL);
353 return CALL_SEND_STATE(state);
354 }
355
356 if (request->reply->code) {
357 goto send_reply;
358 }
359
360 /*
361 * A policy _or_ a module can hard-code the reply.
362 */
363 if (!request->reply->code) {
364 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_packet_type);
365 if (vp && FR_RADIUS_PROCESS_CODE_VALID(vp->vp_uint32)) {
366 request->reply->code = vp->vp_uint32;
367 goto send_reply;
368 }
369 }
370
371 /*
372 * Run authenticate foo { ... }
373 *
374 * If we can't find Auth-Type, OR if we can't find
375 * Auth-Type = foo, then it's a reject.
376 */
377 vp = fr_pair_find_by_da(&request->control_pairs, NULL, attr_auth_type);
378 if (!vp) {
379 RDEBUG("No 'Auth-Type' attribute found, cannot authenticate the user - rejecting the request");
380
381 reject:
382 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
383 goto send_reply;
384 }
385
386 dv = fr_dict_enum_by_value(vp->da, &vp->data);
387 if (!dv) {
388 RDEBUG("Invalid value for 'Auth-Type' attribute, cannot authenticate the user - rejecting the request");
389
390 goto reject;
391 }
392
393 /*
394 * The magic Auth-Type Accept value
395 * which means skip the authenticate
396 * section.
397 *
398 * And Reject means always reject. Tho the admin should
399 * just return "reject" from the section.
400 */
402 request->reply->code = FR_RADIUS_CODE_ACCESS_ACCEPT;
403 goto send_reply;
404
405 } else if (fr_value_box_cmp(enum_auth_type_reject, dv->value) == 0) {
406 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
407 goto send_reply;
408 }
409
410 cs = cf_section_find(inst->server_cs, "authenticate", dv->name);
411 if (!cs) {
412 RDEBUG2("No 'authenticate %s { ... }' section found - rejecting the request", dv->name);
413 goto reject;
414 }
415
416 /*
417 * Run the "Authenticate = foo" section.
418 *
419 * And continue with sending the generic reply.
420 */
421 RDEBUG("Running 'authenticate %s' from file %s", cf_section_name2(cs), cf_filename(cs));
422 return unlang_module_yield_to_section(RESULT_P, request,
423 cs, RLM_MODULE_NOOP, resume_auth_type,
424 NULL, 0, mctx->rctx);
425}
426
427RESUME(auth_type)
428{
429 static const fr_process_rcode_t auth_type_rcode = {
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 if (auth_type_rcode[rcode] == FR_RADIUS_CODE_DO_NOT_RESPOND) {
449 request->reply->code = auth_type_rcode[rcode];
450 UPDATE_STATE(reply);
451
452 RDEBUG("The 'authenticate' section returned %s - not sending a response",
453 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
454
455 fr_assert(state->send != NULL);
456 return state->send(p_result, mctx, request);
457 }
458
459 /*
460 * Most cases except handled...
461 */
462 if (auth_type_rcode[rcode]) request->reply->code = auth_type_rcode[rcode];
463
464 switch (request->reply->code) {
465 case 0:
466 RDEBUG("No reply code was set. Forcing to Access-Reject");
467 request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
469
470 /*
471 * Print complaints before running "send Access-Reject"
472 */
474 RDEBUG2("Failed to authenticate the user");
475
476 /*
477 * Maybe the shared secret is wrong?
478 */
479 vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_user_password);
480 if (vp) {
481 if (RDEBUG_ENABLED2) {
482 uint8_t const *p;
483
484 p = (uint8_t const *) vp->vp_strvalue;
485 while (*p) {
486 int size;
487
488 size = fr_utf8_char(p, -1);
489 if (!size) {
490 RWDEBUG("Unprintable characters in the password. "
491 "Double-check the shared secret on the server "
492 "and the NAS!");
493 break;
494 }
495 p += size;
496 }
497 }
498 }
499 break;
500
501 /*
502 * Access-Challenge sections require a State. If there is
503 * none, create one here. This is so that the State
504 * attribute is accessible in the "send Access-Challenge"
505 * section.
506 */
508 if ((vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_state)) != NULL) {
509 uint8_t buffer[16];
510
511 fr_rand_buffer(buffer, sizeof(buffer));
512
514 fr_pair_value_memdup(vp, buffer, sizeof(buffer), false);
515 }
516 break;
517
518 default:
519 break;
520
521 }
522 UPDATE_STATE(reply);
523
524 fr_assert(state->send != NULL);
525 return state->send(p_result, mctx, request);
526}
527
528RESUME_FLAG(access_accept,UNUSED,)
529{
530 fr_pair_t *vp;
532
534
535 /*
536 * Check that there is a name which can be used to
537 * identify the user. The configuration depends on
538 * User-Name or Stripped-User-Name existing, and being
539 * (mostly) unique to that user.
540 */
541 if (!request->parent &&
542 ((vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_user_name)) != NULL) &&
543 (vp->vp_strvalue[0] == '@') &&
544 !fr_pair_find_by_da(&request->request_pairs, NULL, attr_stripped_user_name)) {
545 RWDEBUG("User-Name is anonymized, and no Stripped-User-Name exists.");
546 RWDEBUG("It may be difficult or impossible to identify the user.");
547 RWDEBUG("Please update Stripped-User-Name with information which identifies the user.");
548 }
549
550 fr_state_discard(inst->auth.state_tree, request);
551 radius_request_pairs_to_reply(request, mctx->rctx);
553}
554
555RESUME_FLAG(access_reject,UNUSED,)
556{
558
560
561 fr_state_discard(inst->auth.state_tree, request);
562 radius_request_pairs_to_reply(request, mctx->rctx);
564}
565
566RESUME(access_challenge)
567{
569
571
572 /*
573 * Cache the state context, unless this is a subrequest.
574 * Subrequest state context will be handled by the caller.
575 *
576 * If this fails, don't respond to the request.
577 */
578 if (!request->parent && fr_state_store(inst->auth.state_tree, request) < 0) {
579 return CALL_SEND_TYPE(FR_RADIUS_CODE_DO_NOT_RESPOND);
580 }
581
582 fr_assert(request->reply->code == FR_RADIUS_CODE_ACCESS_CHALLENGE);
583 radius_request_pairs_to_reply(request, mctx->rctx);
585}
586
587/** A wrapper around recv generic which stores fields from the request
588 */
589RECV(accounting_request)
590{
591 fr_pair_t *acct_delay, *event_timestamp;
592
593 radius_request_pairs_store(request, mctx->rctx);
594
595 /*
596 * Acct-Delay-Time is horrific. Its existence in a packet means that any retransmissions can't
597 * be retransmissions! Instead, we have to send a brand new packet each time. This rewriting is
598 * expensive, causes ID churn, over-allocation of IDs, and makes it more difficult to discover
599 * end-to-end failures.
600 *
601 * As a result, we delete Acct-Delay-Time, and replace it with Event-Timestamp.
602 */
603 event_timestamp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_event_timestamp);
604 if (!event_timestamp) {
605 MEM(event_timestamp = fr_pair_afrom_da(request->request_ctx, attr_event_timestamp));
606 fr_pair_append(&request->request_pairs, event_timestamp);
607 event_timestamp->vp_date = fr_time_to_unix_time(request->packet->timestamp);
608
609 acct_delay = fr_pair_find_by_da(&request->request_pairs, NULL, attr_event_timestamp);
610 if (acct_delay) {
611 if (acct_delay->vp_uint32 < ((365 * 86400))) {
612 event_timestamp->vp_date = fr_unix_time_sub_time_delta(event_timestamp->vp_date, fr_time_delta_from_sec(acct_delay->vp_uint32));
613
614 RDEBUG("Accounting-Request packet contains %pP. Creating %pP",
615 acct_delay, event_timestamp);
616 }
617 } else {
618 RDEBUG("Accounting-Request packet is missing Event-Timestamp. Adding it to packet as %pP.", event_timestamp);
619 }
620 }
621
622 return CALL_RECV(generic);
623}
624
625RESUME(acct_type)
626{
627 static const fr_process_rcode_t acct_type_rcode = {
633 };
634
635 rlm_rcode_t rcode = RESULT_RCODE;
636 fr_process_state_t const *state;
637
639
641 fr_assert(FR_RADIUS_PROCESS_CODE_VALID(request->reply->code));
642
643 if (acct_type_rcode[rcode]) {
644 fr_assert(acct_type_rcode[rcode] == FR_RADIUS_CODE_DO_NOT_RESPOND);
645
646 request->reply->code = acct_type_rcode[rcode];
647 UPDATE_STATE(reply);
648
649 RDEBUG("The 'accounting' section returned %s - not sending a response",
650 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
651
652 fr_assert(state->send != NULL);
653 return state->send(p_result, mctx, request);
654 }
655
656 request->reply->code = FR_RADIUS_CODE_ACCOUNTING_RESPONSE;
657 UPDATE_STATE(reply);
658
659 fr_assert(state->send != NULL);
660 return state->send(p_result, mctx, request);
661}
662
663RESUME(accounting_request)
664{
665 rlm_rcode_t rcode = RESULT_RCODE;
666 fr_pair_t *vp;
667 CONF_SECTION *cs;
668 fr_dict_enum_value_t const *dv;
669 fr_process_state_t const *state;
671
673
675
676 UPDATE_STATE(packet);
677 fr_assert(state->packet_type[rcode] != 0);
678
679 request->reply->code = state->packet_type[rcode];
680 UPDATE_STATE_CS(reply);
681
682 if (request->reply->code == FR_RADIUS_CODE_DO_NOT_RESPOND) {
683 RDEBUG("The 'recv Accounting-Request' section returned %s - not sending a response",
684 fr_table_str_by_value(rcode_table, rcode, "<INVALID>"));
685
687 fr_assert(state->send != NULL);
688 return CALL_SEND_STATE(state);
689 }
690
691 /*
692 * Run accounting foo { ... }
693 */
694 vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_acct_status_type);
695 if (!vp) goto send_reply;
696
697 dv = fr_dict_enum_by_value(vp->da, &vp->data);
698 if (!dv) goto send_reply;
699
700 cs = cf_section_find(inst->server_cs, "accounting", dv->name);
701 if (!cs) {
702 RDEBUG2("No 'accounting %s { ... }' section found - skipping...", dv->name);
703 goto send_reply;
704 }
705
706 /*
707 * Run the "Acct-Status-Type = foo" section.
708 *
709 * And continue with sending the generic reply.
710 */
711 return unlang_module_yield_to_section(RESULT_P, request,
712 cs, RLM_MODULE_NOOP, resume_acct_type,
713 NULL, 0, mctx->rctx);
714}
715
716#if 0
717// @todo - send canned responses like in v3?
718RECV(status_server)
719{
721}
722
723RESUME(status_server)
724{
726}
727#endif
728
729RESUME_FLAG(protocol_error,UNUSED,)
730{
731 fr_pair_t *vp;
733
735
736 fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->reply->code));
737
738 /*
739 * https://tools.ietf.org/html/rfc7930#section-4
740 */
741 vp = fr_pair_find_by_da_nested(&request->reply_pairs, NULL, attr_original_packet_code);
742 if (!vp) {
743 vp = fr_pair_afrom_da(request->reply_ctx, attr_original_packet_code);
744 if (vp) {
745 vp->vp_uint32 = request->packet->code;
746 fr_pair_append(&request->reply_pairs, vp);
747 }
748 }
749
750 /*
751 * If there's no Error-Cause, then include a generic 404.
752 */
753 vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_error_cause);
754 if (!vp) {
755 vp = fr_pair_afrom_da(request->reply_ctx, attr_error_cause);
756 if (vp) {
757 vp->vp_uint32 = FR_ERROR_CAUSE_VALUE_INVALID_REQUEST;
758 fr_pair_append(&request->reply_pairs, vp);
759 }
760 }
761
762 /*
763 * Discard any session state associated with the request.
764 */
765 if (request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) {
766 fr_state_discard(inst->auth.state_tree, request);
767 }
768
769 /*
770 * And do the generic processing after running a "send" section.
771 */
772 return CALL_RESUME(send_generic);
773}
774
775static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
776{
777 fr_process_state_t const *state;
778
780
782
783 request->component = "radius";
784 request->module = NULL;
785 fr_assert(request->proto_dict == dict_radius);
786
787 fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->packet->code));
788
789 UPDATE_STATE(packet);
790
791 if (!state->recv) {
792 REDEBUG("Invalid packet type (%u)", request->packet->code);
794 }
795
796 radius_packet_debug(request, request->packet, &request->request_pairs, true);
797
798 if (unlikely(request_is_dynamic_client(request))) {
799 return new_client(p_result, mctx, request);
800 }
801
802 return state->recv(p_result, mctx, request);
803}
804
806 { .required = true, .single = true, .type = FR_TYPE_OCTETS },
808};
809
810/** Validates a request against a know shared secret
811 *
812 * Designed for the specific purpose of verifying dynamic clients
813 * against a know shared secret.
814 *
815 * Example:
816@verbatim
817%radius.secret.verify(<secret>)
818@endverbatim
819 *
820 * @ingroup xlat_functions
821 */
823 request_t *request, fr_value_box_list_t *args)
824{
826 int ret;
827 bool require_message_authenticator = false;
828
830
831 if (request->proto_dict != dict_radius) return XLAT_ACTION_FAIL;
832
833 MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_BOOL, NULL));
834
835 /*
836 * Only Access-Requests require a Message-Authenticator.
837 * All the other packet types are signed using the
838 * authenticator field.
839 */
840 if (request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) require_message_authenticator = true;
841
842 ret = fr_radius_verify(request->packet->data, NULL, secret->vb_octets, secret->vb_length, require_message_authenticator, false);
843 switch (ret) {
844 case 0:
845 vb->vb_bool = true;
846 break;
847
848 default:
849 RPEDEBUG("Invalid packet");
850 return XLAT_ACTION_FAIL;
851
854 RPEDEBUG("Failed to verify the packet signature");
855 vb->vb_bool = false;
856 break;
857 }
859
860 return XLAT_ACTION_DONE;
861}
862
863static int mod_instantiate(module_inst_ctx_t const *mctx)
864{
865 process_radius_t *inst = talloc_get_type_abort(mctx->mi->data, process_radius_t);
866
867 inst->server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
868
869 FR_INTEGER_BOUND_CHECK("session.max_rounds", inst->auth.session.max_rounds, >=, 32);
870 FR_INTEGER_BOUND_CHECK("session.max_rounds", inst->auth.session.max_rounds, <=, 100);
871
872 inst->auth.session.thread_safe = main_config->spawn_workers;
873 inst->auth.session.context_id = fr_hash_string(cf_section_name2(inst->server_cs));
874
875 inst->auth.state_tree = fr_state_tree_init(inst, attr_state, &inst->auth.session);
876
877 return 0;
878}
879
880static int mod_bootstrap(module_inst_ctx_t const *mctx)
881{
882 CONF_SECTION *server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
883
884 if (virtual_server_section_attribute_define(server_cs, "authenticate", attr_auth_type) < 0) return -1;
885
886 return 0;
887}
888
889static int mod_load(void)
890{
891 xlat_t *xlat;
892
893 if (unlikely(!(xlat = xlat_func_register(NULL, "radius.secret.verify", xlat_func_radius_secret_verify,
894 FR_TYPE_BOOL)))) return -1;
895
897
898 return 0;
899}
900
901static void mod_unload(void)
902{
903 xlat_func_unregister("radius.secret.verify");
904}
905
906/*
907 * rcodes not listed under a packet_type
908 * mean that the packet code will not be
909 * changed.
910 */
911static fr_process_state_t const process_state[] = {
913 .packet_type = {
920 },
921 .default_rcode = RLM_MODULE_NOOP,
922 .recv = recv_access_request,
923 .resume = resume_access_request,
924 .section_offset = offsetof(process_radius_sections_t, access_request),
925 },
927 .packet_type = {
933 },
934 .default_rcode = RLM_MODULE_NOOP,
935 .result_rcode = RLM_MODULE_OK,
936 .send = send_generic,
937 .resume = resume_access_accept,
938 .section_offset = offsetof(process_radius_sections_t, access_accept),
939 },
941 .packet_type = {
947 },
948 .default_rcode = RLM_MODULE_NOOP,
949 .result_rcode = RLM_MODULE_REJECT,
950 .send = send_generic,
951 .resume = resume_access_reject,
952 .section_offset = offsetof(process_radius_sections_t, access_reject),
953 },
955 .packet_type = {
961 },
962 .default_rcode = RLM_MODULE_NOOP,
963 .result_rcode = RLM_MODULE_OK,
964 .send = send_generic,
965 .resume = resume_access_challenge,
966 .section_offset = offsetof(process_radius_sections_t, access_challenge),
967 },
968
970 .packet_type = {
975
982 },
983 .default_rcode = RLM_MODULE_NOOP,
984 .recv = recv_accounting_request,
985 .resume = resume_accounting_request,
986 .section_offset = offsetof(process_radius_sections_t, accounting_request),
987 },
989 .packet_type = {
996 },
997 .default_rcode = RLM_MODULE_NOOP,
998 .result_rcode = RLM_MODULE_OK,
999 .send = send_generic,
1000 .resume = resume_generic_radius_response,
1001 .section_offset = offsetof(process_radius_sections_t, accounting_response),
1002 },
1003 [ FR_RADIUS_CODE_STATUS_SERVER ] = { /* @todo - negotiation, stats, etc. */
1004 .packet_type = {
1007
1015 },
1016 .default_rcode = RLM_MODULE_NOOP,
1017 .recv = recv_generic,
1018 .resume = resume_recv_generic,
1019 .section_offset = offsetof(process_radius_sections_t, status_server),
1020 },
1022 .packet_type = {
1027
1033 },
1034 .default_rcode = RLM_MODULE_NOOP,
1035 .recv = recv_generic_radius_request,
1036 .resume = resume_recv_generic,
1037 .section_offset = offsetof(process_radius_sections_t, coa_request),
1038 },
1040 .packet_type = {
1046 },
1047 .default_rcode = RLM_MODULE_NOOP,
1048 .result_rcode = RLM_MODULE_OK,
1049 .send = send_generic,
1050 .resume = resume_generic_radius_response,
1051 .section_offset = offsetof(process_radius_sections_t, coa_ack),
1052 },
1054 .packet_type = {
1060 },
1061 .default_rcode = RLM_MODULE_NOOP,
1062 .result_rcode = RLM_MODULE_NOTFOUND,
1063 .send = send_generic,
1064 .resume = resume_generic_radius_response,
1065 .section_offset = offsetof(process_radius_sections_t, coa_nak),
1066 },
1068 .packet_type = {
1073
1079 },
1080 .default_rcode = RLM_MODULE_NOOP,
1081 .recv = recv_generic,
1082 .resume = resume_recv_generic,
1083 .section_offset = offsetof(process_radius_sections_t, disconnect_request),
1084 },
1086 .packet_type = {
1092 },
1093 .default_rcode = RLM_MODULE_NOOP,
1094 .result_rcode = RLM_MODULE_OK,
1095 .send = send_generic,
1096 .resume = resume_generic_radius_response,
1097 .section_offset = offsetof(process_radius_sections_t, disconnect_ack),
1098 },
1100 .packet_type = {
1106 },
1107 .default_rcode = RLM_MODULE_NOOP,
1108 .result_rcode = RLM_MODULE_NOTFOUND,
1109 .send = send_generic,
1110 .resume = resume_generic_radius_response,
1111 .section_offset = offsetof(process_radius_sections_t, disconnect_nak),
1112 },
1113 [ FR_RADIUS_CODE_PROTOCOL_ERROR ] = { /* @todo - fill out required fields */
1114 .packet_type = {
1120 },
1121 .default_rcode = RLM_MODULE_NOOP,
1122 .result_rcode = RLM_MODULE_OK,
1123 .send = send_generic,
1124 .resume = resume_protocol_error,
1125 .section_offset = offsetof(process_radius_sections_t, protocol_error),
1126 },
1128 .packet_type = {
1133
1140 },
1141 .default_rcode = RLM_MODULE_NOOP,
1142 .result_rcode = RLM_MODULE_HANDLED,
1143 .send = send_generic,
1144 .resume = resume_send_generic,
1145 .section_offset = offsetof(process_radius_sections_t, do_not_respond),
1146 }
1147};
1148
1150 {
1151 .section = SECTION_NAME("recv", "Access-Request"),
1152 .actions = &mod_actions_authorize,
1153 .offset = PROCESS_CONF_OFFSET(access_request),
1154 },
1155 {
1156 .section = SECTION_NAME("send", "Access-Accept"),
1158 .offset = PROCESS_CONF_OFFSET(access_accept),
1159 },
1160 {
1161 .section = SECTION_NAME("send", "Access-Challenge"),
1163 .offset = PROCESS_CONF_OFFSET(access_challenge),
1164 },
1165 {
1166 .section = SECTION_NAME("send", "Access-Reject"),
1168 .offset = PROCESS_CONF_OFFSET(access_reject),
1169 },
1170
1171 {
1172 .section = SECTION_NAME("recv", "Accounting-Request"),
1174 .offset = PROCESS_CONF_OFFSET(accounting_request),
1175 },
1176 {
1177 .section = SECTION_NAME("send", "Accounting-Response"),
1179 .offset = PROCESS_CONF_OFFSET(accounting_response),
1180 },
1181
1182 {
1183 .section = SECTION_NAME("recv", "Status-Server"),
1185 .offset = PROCESS_CONF_OFFSET(status_server),
1186 },
1187 {
1188 .section = SECTION_NAME("recv", "CoA-Request"),
1190 .offset = PROCESS_CONF_OFFSET(coa_request),
1191 },
1192 {
1193 .section = SECTION_NAME("send", "CoA-ACK"),
1195 .offset = PROCESS_CONF_OFFSET(coa_ack),
1196 },
1197 {
1198 .section = SECTION_NAME("send", "CoA-NAK"),
1200 .offset = PROCESS_CONF_OFFSET(coa_nak),
1201 },
1202 {
1203 .section = SECTION_NAME("recv", "Disconnect-Request"),
1205 .offset = PROCESS_CONF_OFFSET(disconnect_request),
1206 },
1207 {
1208 .section = SECTION_NAME("send", "Disconnect-ACK"),
1210 .offset = PROCESS_CONF_OFFSET(disconnect_ack),
1211 },
1212 {
1213 .section = SECTION_NAME("send", "Disconnect-NAK"),
1215 .offset = PROCESS_CONF_OFFSET(disconnect_nak),
1216 },
1217 {
1218 .section = SECTION_NAME("send", "Protocol-Error"),
1220 .offset = PROCESS_CONF_OFFSET(protocol_error),
1221 },
1222 {
1223 .section = SECTION_NAME("send", "Do-Not-Respond"),
1225 .offset = PROCESS_CONF_OFFSET(do_not_respond),
1226 },
1227 {
1228 .section = SECTION_NAME("authenticate", CF_IDENT_ANY),
1230 },
1231 {
1232 .section = SECTION_NAME("accounting", CF_IDENT_ANY),
1234 },
1235
1236 DYNAMIC_CLIENT_SECTIONS,
1237
1239};
1240
1243 .common = {
1244 .magic = MODULE_MAGIC_INIT,
1245 .name = "radius",
1246 .config = config,
1249
1250 .onload = mod_load,
1251 .unload = mod_unload,
1252 .bootstrap = mod_bootstrap,
1253 .instantiate = mod_instantiate
1254 },
1255 .process = mod_process,
1256 .compile_list = compile_list,
1257 .dict = &dict_radius,
1258 .packet_type = &attr_packet_type
1259};
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:822
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:443
#define RWDEBUG(fmt,...)
Definition log.h:361
#define RDEBUG3(fmt,...)
Definition log.h:343
#define RPEDEBUG(fmt,...)
Definition log.h:376
#define RINDENT()
Indent R* messages by one level.
Definition log.h:430
@ 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_DATE
Unix time stamp, always has value >2^31.
@ 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:2944
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:780
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:703
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:1348
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:1692
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:289
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
RECV(request)
Store basic information from the request, and jump into the correct processing section.
Definition base.c:363
static int mod_load(void)
Definition base.c:228
static void mod_unload(void)
Definition base.c:237
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition base.c:213
process_radius_auth_t auth
Authentication configuration.
Definition base.c:144
CONF_SECTION * access_challenge
Definition base.c:112
static fr_dict_attr_t const * attr_user_password
Definition base.c:66
CONF_SECTION * coa_nak
Definition base.c:121
static xlat_arg_parser_t const xlat_func_radius_secret_verify_args[]
Definition base.c:805
CONF_SECTION * disconnect_ack
Definition base.c:124
CONF_SECTION * protocol_error
Definition base.c:128
CONF_SECTION * new_client
Definition base.c:130
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:72
CONF_SECTION * coa_request
Definition base.c:119
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:150
fr_dict_enum_autoload_t process_radius_dict_enum[]
Definition base.c:97
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition base.c:880
fr_process_module_t process_radius
Definition base.c:1242
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:250
#define FR_RADIUS_PROCESS_CODE_VALID(_x)
Definition base.c:155
CONF_SECTION * disconnect_nak
Definition base.c:125
CONF_SECTION * access_accept
Definition base.c:110
static fr_value_box_t const * enum_auth_type_reject
Definition base.c:94
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 tamptered with.
Definition base.c:225
static fr_dict_attr_t const * attr_error_cause
Definition base.c:68
CONF_SECTION * add_client
Definition base.c:131
static const conf_parser_t auth_config[]
Definition base.c:166
CONF_SECTION * server_cs
Our virtual server.
Definition base.c:141
CONF_SECTION * access_request
Definition base.c:109
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:182
static fr_value_box_t const * enum_auth_type_accept
Definition base.c:93
CONF_SECTION * status_server
Definition base.c:117
CONF_SECTION * access_reject
Definition base.c:111
static fr_dict_attr_t const * attr_acct_status_type
Definition base.c:61
CONF_SECTION * disconnect_request
Definition base.c:123
CONF_SECTION * accounting_request
Definition base.c:114
CONF_SECTION * coa_ack
Definition base.c:120
CONF_SECTION * do_not_respond
Definition base.c:127
fr_state_config_t session
track state session information.
Definition base.c:136
process_radius_sections_t sections
Pointers to various config sections we need to execute.
Definition base.c:142
static fr_dict_attr_t const * attr_original_packet_code
Definition base.c:67
unlang_result_t result
Definition base.c:152
static const conf_parser_t config[]
Definition base.c:172
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:137
static fr_dict_attr_t const * attr_event_timestamp
Definition base.c:69
CONF_SECTION * accounting_response
Definition base.c:115
CONF_SECTION * deny_client
Definition base.c:132
Records fields from the original request so we have a known good copy.
Definition base.c:149
#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,...)
Definition radclient.h:52
#define RDEBUG_ENABLED2()
Definition radclient.h:50
#define RDEBUG2(fmt,...)
Definition radclient.h:54
#define RDEBUG(fmt,...)
Definition radclient.h:53
#define RDEBUG_ENABLED()
Definition radclient.h:49
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:59
rlm_rcode_t
Return codes indicating the result of the module call.
Definition rcode.h:40
@ RLM_MODULE_INVALID
The module considers the request invalid.
Definition rcode.h:47
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:45
@ RLM_MODULE_FAIL
Module failed, don't reply.
Definition rcode.h:44
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
Definition rcode.h:48
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:43
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
Definition rcode.h:52
@ RLM_MODULE_NOTFOUND
User not found.
Definition rcode.h:49
@ RLM_MODULE_UPDATED
OK (pairs modified).
Definition rcode.h:51
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
Definition rcode.h:50
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
Definition rcode.h:53
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
Definition rcode.h:46
#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:738
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:684
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:814
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
static fr_unix_time_t fr_unix_time_sub_time_delta(fr_unix_time_t a, fr_time_delta_t b)
Definition time.h:341
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
Definition time.h:590
static fr_unix_time_t fr_time_to_unix_time(fr_time_t when)
Convert an fr_time_t (internal time) to our version of unix time (wallclock time)
Definition time.h:688
#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
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:4411
#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