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: ca2a30ac23c5886dfb9a9cfe3551840198c9b6cb $
19 * @file src/process/tls/base.c
20 * @brief TLS processing.
21 *
22 * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
23 */
24#include <freeradius-devel/server/protocol.h>
25#include <freeradius-devel/util/debug.h>
26#include <freeradius-devel/protocol/tls/freeradius.h>
27
28static fr_dict_t const *dict_tls;
29
32 { .out = &dict_tls, .proto = "tls" },
33 { NULL }
34};
35
37
40 { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_tls},
41 { NULL }
42};
43
52
56
57#define FR_TLS_PACKET_CODE_VALID(_code) (((_code) > 0) && ((_code) <= FR_PACKET_TYPE_VALUE_NOTFOUND))
58
59#define PROCESS_INST process_tls_t
60#define PROCESS_PACKET_TYPE uint32_t
61#define PROCESS_PACKET_CODE_VALID FR_TLS_PACKET_CODE_VALID
62
63#include <freeradius-devel/server/process.h>
64
65static fr_process_state_t const process_state[] = {
66 [FR_PACKET_TYPE_VALUE_LOAD_SESSION] = {
67 .packet_type = {
68 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_SUCCESS,
69 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_SUCCESS,
70
71 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_FAILURE,
72 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_FAILURE,
73 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_FAILURE,
74 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_FAILURE,
75 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_FAILURE,
76 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_NOTFOUND,
77 },
78 .rcode = RLM_MODULE_NOOP,
79 .recv = recv_generic,
80 .resume = resume_recv_no_send,
81 .section_offset = PROCESS_CONF_OFFSET(load_session),
82 },
83 [FR_PACKET_TYPE_VALUE_STORE_SESSION] = {
84 .packet_type = {
85 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_SUCCESS,
86 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_SUCCESS,
87
88 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_FAILURE,
89 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_FAILURE,
90 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_FAILURE,
91 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_FAILURE,
92 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_FAILURE,
93 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_NOTFOUND,
94 },
95 .rcode = RLM_MODULE_NOOP,
96 .recv = recv_generic,
97 .resume = resume_recv_no_send,
98 .section_offset = PROCESS_CONF_OFFSET(store_session),
99 },
100 [FR_PACKET_TYPE_VALUE_CLEAR_SESSION] = {
101 .packet_type = {
102 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_SUCCESS,
103 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_SUCCESS,
104
105 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_FAILURE,
106 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_FAILURE,
107 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_FAILURE,
108 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_FAILURE,
109 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_FAILURE,
110 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_NOTFOUND,
111 },
112 .rcode = RLM_MODULE_NOOP,
113 .recv = recv_generic,
114 .resume = resume_recv_no_send,
115 .section_offset = PROCESS_CONF_OFFSET(clear_session),
116 },
117 [FR_PACKET_TYPE_VALUE_VERIFY_CERTIFICATE] = {
118 .packet_type = {
119 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_SUCCESS,
120 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_SUCCESS,
121 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_SUCCESS,
122
123 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_FAILURE,
124 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_FAILURE,
125 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_FAILURE,
126 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_FAILURE,
127 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_NOTFOUND,
128 },
129 .rcode = RLM_MODULE_NOOP,
130 .recv = recv_generic,
131 .resume = resume_recv_no_send,
132 .section_offset = PROCESS_CONF_OFFSET(verify_certificate),
133 },
134 [FR_PACKET_TYPE_VALUE_NEW_SESSION] = {
135 .packet_type = {
136 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_SUCCESS,
137 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_SUCCESS,
138 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_SUCCESS,
139
140 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_FAILURE,
141 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_FAILURE,
142 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_FAILURE,
143 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_FAILURE,
144 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_NOTFOUND,
145 },
146 .rcode = RLM_MODULE_NOOP,
147 .recv = recv_generic,
148 .resume = resume_recv_no_send,
149 .section_offset = PROCESS_CONF_OFFSET(new_session),
150 },
151 [FR_PACKET_TYPE_VALUE_ESTABLISH_SESSION] = {
152 .packet_type = {
153 [RLM_MODULE_OK] = FR_PACKET_TYPE_VALUE_SUCCESS,
154 [RLM_MODULE_UPDATED] = FR_PACKET_TYPE_VALUE_SUCCESS,
155 [RLM_MODULE_NOOP] = FR_PACKET_TYPE_VALUE_SUCCESS,
156
157 [RLM_MODULE_REJECT] = FR_PACKET_TYPE_VALUE_FAILURE,
158 [RLM_MODULE_FAIL] = FR_PACKET_TYPE_VALUE_FAILURE,
159 [RLM_MODULE_INVALID] = FR_PACKET_TYPE_VALUE_FAILURE,
160 [RLM_MODULE_DISALLOW] = FR_PACKET_TYPE_VALUE_FAILURE,
161 [RLM_MODULE_NOTFOUND] = FR_PACKET_TYPE_VALUE_NOTFOUND,
162 },
163 .rcode = RLM_MODULE_NOOP,
164 .recv = recv_generic,
165 .resume = resume_recv_no_send,
166 .section_offset = PROCESS_CONF_OFFSET(establish_session),
167 },
168};
169
170static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
171{
172 fr_process_state_t const *state;
173
175
177
178 request->component = "tls";
179 request->module = NULL;
180 fr_assert(request->dict == dict_tls);
181
182 UPDATE_STATE(packet);
183
184 log_request_pair_list(L_DBG_LVL_1, request, NULL, &request->request_pairs, NULL);
185
186 return state->recv(p_result, mctx, request);
187}
188
190 {
191 .section = SECTION_NAME("store", "session"),
192 .actions = &mod_actions_authorize,
193 .offset = PROCESS_CONF_OFFSET(store_session)
194 },
195 {
196 .section = SECTION_NAME("load", "session"),
198 .offset = PROCESS_CONF_OFFSET(load_session)
199 },
200 {
201 .section = SECTION_NAME("clear", "session"),
203 .offset = PROCESS_CONF_OFFSET(clear_session)
204 },
205 {
206 .section = SECTION_NAME("verify", "certificate"),
208 .offset = PROCESS_CONF_OFFSET(verify_certificate)
209 },
210 {
211 .section = SECTION_NAME("new", "session"),
213 .offset = PROCESS_CONF_OFFSET(new_session)
214 },
215 {
216 .section = SECTION_NAME("establish", "session"),
218 .offset = PROCESS_CONF_OFFSET(establish_session)
219 },
221};
222
223
226 .common = {
227 .magic = MODULE_MAGIC_INIT,
228 .name = "tls",
229 .inst_size = sizeof(process_tls_t)
230 },
231 .process = mod_process,
232 .compile_list = compile_list,
233 .dict = &dict_tls,
234};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:268
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:281
Specifies an attribute which must be present for the module to function.
Definition dict.h:267
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:280
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
fr_dict_attr_t const * attr_packet_type
Definition base.c:93
fr_dict_t const * dict_tls
Definition base.c:79
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:830
@ L_DBG_LVL_1
Highest priority debug messages (-x).
Definition log.h:70
@ FR_TYPE_UINT32
32 Bit unsigned integer.
unlang_mod_actions_t const mod_actions_authorize
Definition mod_action.c:44
unlang_mod_action_t actions[RLM_MODULE_NUMCODES]
Definition mod_action.h:62
module_instance_t const * mi
Instance of the module being instantiated.
Definition module_ctx.h:42
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition base.c:179
static const virtual_server_compile_t compile_list[]
Definition base.c:205
static fr_process_state_t const process_state[]
Definition base.c:68
CONF_SECTION * establish_session
Definition base.c:50
fr_process_module_t process_tls
Definition base.c:225
CONF_SECTION * store_session
Definition base.c:46
fr_dict_autoload_t process_tls_dict[]
Definition base.c:31
CONF_SECTION * load_session
Definition base.c:45
CONF_SECTION * clear_session
Definition base.c:47
fr_dict_attr_autoload_t process_tls_dict_attr[]
Definition base.c:39
CONF_SECTION * verify_certificate
Definition base.c:48
CONF_SECTION * new_session
Definition base.c:49
process_tls_sections_t sections
Definition base.c:54
#define PROCESS_TRACE
Trace each state function as it's entered.
Definition process.h:65
module_t common
Common fields for all loadable modules.
Definition process.h:55
Common public symbol definition for all process modules.
Definition process.h:54
#define fr_assert(_expr)
Definition rad_assert.h:38
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:45
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:43
@ RLM_MODULE_FAIL
Module failed, don't reply.
Definition rcode.h:42
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
Definition rcode.h:46
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:41
@ RLM_MODULE_NOTFOUND
User not found.
Definition rcode.h:47
@ RLM_MODULE_UPDATED
OK (pairs modified).
Definition rcode.h:49
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
Definition rcode.h:48
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition section.h:40
size_t inst_size
Size of the module's instance data.
Definition module.h:203
void * data
Module's instance data.
Definition module.h:271
#define talloc_get_type_abort_const
Definition talloc.h:282
#define COMPILE_TERMINATOR
section_name_t const * section
Identifier for the section.
Processing sections which are allowed in this virtual server.